Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support huggingface-cli older than 0.25.0, like on Fedora 40 and 41 #468

Conversation

debarshiray
Copy link
Member

@debarshiray debarshiray commented Nov 19, 2024

Currently, on Fedora 40 and 41, pulling a model from Hugging Face fails with:

  $ ramalama pull
      huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf
  usage: huggingface-cli <command> [<args>]
  huggingface-cli: error: argument {env,login,whoami,logout,repo,upload,
      download,lfs-enable-largefiles,lfs-multipart-upload,scan-cache,
      delete-cache,tag}: invalid choice: 'version' (choose from 'env',
      'login', 'whoami', 'logout', 'repo', 'upload', 'download',
      'lfs-enable-largefiles', 'lfs-multipart-upload', 'scan-cache',
      'delete-cache', 'tag')
  Error: Command '['huggingface-cli', 'version']' returned non-zero exit
      status 2.

This is because the huggingface-cli version command is a recent addition in version 0.25.0 [1], and it's not present in any stable Fedora release [2].

Therefore, it might be worth using a slightly different signature to detect the presence of huggingface-cli - one that isn't bound to a huggingface-cli version and is used elsewhere in the code.

[1] huggingface_hub commit ebac1b2a1aa4a9f4
huggingface/huggingface_hub@ebac1b2a1aa4a9f4
huggingface/huggingface_hub#2441

[2] https://src.fedoraproject.org/rpms/python-huggingface-hub

Fixes: 5749154 ("Replace huggingface-cli with a simple ...")

Summary by Sourcery

Bug Fixes:

  • Fix compatibility issue with older versions of huggingface-cli on Fedora 40 and 41 by changing the command used to check its availability.

Copy link
Contributor

sourcery-ai bot commented Nov 19, 2024

Reviewer's Guide by Sourcery

The PR modifies the Hugging Face CLI availability check to support older versions of huggingface-cli (pre-0.25.0) by using the '--help' command instead of the 'version' command, which was only introduced in version 0.25.0.

Sequence diagram for Hugging Face CLI availability check

sequenceDiagram
    participant User
    participant System
    User->>System: Execute ramalama pull
    System->>System: run_cmd(["huggingface-cli", "--help"])
    alt huggingface-cli available
        System->>User: CLI is available
    else huggingface-cli not found
        System->>User: Print warning message
    end
Loading

File-Level Changes

Change Details Files
Modified the Hugging Face CLI detection mechanism to support older versions
  • Replaced 'version' command with '--help' command in the CLI check
  • Maintains backward compatibility with older huggingface-cli versions like those in Fedora 40 and 41
ramalama/huggingface.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @debarshiray - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rhatdan
Copy link
Member

rhatdan commented Nov 19, 2024

How about?

import shutil

path = shutil.which("huggingface-cli")

@debarshiray
Copy link
Member Author

How about?

import shutil

path = shutil.which("huggingface-cli")

Sure, why not? I am not much of a Python programmer. :)

Currently, on Fedora 40 and 41, pulling a model from Hugging Face fails
with:
  $ ramalama pull
      huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf
  usage: huggingface-cli <command> [<args>]
  huggingface-cli: error: argument {env,login,whoami,logout,repo,upload,
      download,lfs-enable-largefiles,lfs-multipart-upload,scan-cache,
      delete-cache,tag}: invalid choice: 'version' (choose from 'env',
      'login', 'whoami', 'logout', 'repo', 'upload', 'download',
      'lfs-enable-largefiles', 'lfs-multipart-upload', 'scan-cache',
      'delete-cache', 'tag')
  Error: Command '['huggingface-cli', 'version']' returned non-zero exit
      status 2.

This is because the 'huggingface-cli version' command is a recent
addition in version 0.25.0 [1], and it's not present in any stable
Fedora release [2].

Therefore, it might be worth using a slightly different signature to
detect the presence of huggingface-cli - one that isn't bound to a
huggingface-cli version and is used elsewhere in the code.

[1] huggingface_hub commit ebac1b2a1aa4a9f4
    huggingface/huggingface_hub@ebac1b2a1aa4a9f4
    huggingface/huggingface_hub#2441

[2] https://src.fedoraproject.org/rpms/python-huggingface-hub

Fixes: 5749154 ("Replace huggingface-cli with a simple ...")

Signed-off-by: Debarshi Ray <[email protected]>
@debarshiray debarshiray force-pushed the wip/rishi/huggingface-compatible-with-huggingface-cli-older-than-0.25.0 branch from 1d14439 to 19f1918 Compare November 19, 2024 21:53
@rhatdan
Copy link
Member

rhatdan commented Nov 19, 2024

LGTM

@rhatdan rhatdan merged commit f498bd6 into containers:main Nov 19, 2024
11 checks passed
@debarshiray debarshiray deleted the wip/rishi/huggingface-compatible-with-huggingface-cli-older-than-0.25.0 branch November 19, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants