Closed rhatdan closed 6 days ago
This PR improves the handling of model paths and HuggingFace login functionality in RamaLama. The changes consolidate model path handling into the base class, standardize model type naming, and improve symlink management. The PR also enhances the login functionality for HuggingFace and updates model type handling.
classDiagram
class BaseModel {
+login(args)
+logout(args)
+pull(args)
+remove(args)
+garbage_collection(args)
+path(args)
+model_path(args)
+exists(args)
+check_valid_model_path(relative_target_path, model_path)
}
class Huggingface {
+login(args)
+logout(args)
+pull(args)
+push(source, args)
+exec(cmd_args, args)
}
BaseModel <|-- Huggingface
note for BaseModel "Consolidated model path handling and symlink management"
note for Huggingface "Enhanced login functionality and updated exec method"
Change | Details | Files |
---|---|---|
Refactored model path handling by moving common functionality to the base class |
|
ramalama/model.py ramalama/huggingface.py |
Improved HuggingFace integration and model type handling |
|
ramalama/huggingface.py ramalama/cli.py |
Enhanced symlink management in model operations |
|
ramalama/huggingface.py |
Updated repository paths and model type handling |
|
ramalama/model.py |
@bentito PTAL
@bmahabirbu @cooktheryan PTAL
@bentito PTAL
do you @rhatdan happen to know the pipx command to checkout the pr branch? I can't quite seem to get it right...
No idea, how to do this.
I would do a git clone of the repo and then run ./bin/ramalama
git clone git@github.com:containers/ramalama.git
cd ramalama
wget https://github.com/containers/ramalama/pull/467.patch
git am 467.patch
./bin/ramalama login --TOKEN XXXXX huggingface
@bmahabirbu @cooktheryan PTAL
Did a quick test and worked for me!
./bin/ramalama login --token=XXX huggingface
The token has not been saved to the git credentials helper. Pass `add_to_git_credential=True` in this function directly or `--add-to-git-credential` if using via `huggingface-cli` if you want to set the git credential as well.
Token is valid (permission: fineGrained).
The token `PC` has been saved to /home/bmahabir/.cache/huggingface/stored_tokens
Your token has been saved to /home/bmahabir/.cache/huggingface/token
Login successful.
The current active token is: `PC`
I was able to login huggingface thanks!
I am still getting 401 unauthorized when trying to pull from huggingface after successful login:
ramalama login --token=$HF_TOKEN huggingface
Token will not been saved to git credential helper. Pass `add_to_git_credential=True` if you want to set the git credential as well.
Token is valid (permission: read).
Your token has been saved to /Users/btofel/.cache/huggingface/token
Login successful
what's the part about: add_to_git_credential=True
how would I pass that in the command?
Is that related to my fail?:
$ ramalama pull huggingface://Qwen/Qwen2.5-Coder-32B-Instruct
Error: failed to pull https://huggingface.co/Qwen/raw/main/Qwen2.5-Coder-32B-Instruct: HTTP Error 401: Unauthorized
Tried:
$ ramalama pull --authfile /Users/btofel/.cache/huggingface/token huggingface://ibm-granite/granite-3.0-8b-instruct
Error: failed to pull https://huggingface.co/ibm-granite/raw/main/granite-3.0-8b-instruct: HTTP Error 401: Unauthorized
$ ramalama pull --authfile /Users/btofel/.cache/huggingface/foo huggingface://ibm-granite/granite-3.0-8b-instruct
Error: failed to pull https://huggingface.co/ibm-granite/raw/main/granite-3.0-8b-instruct: HTTP Error 401: Unauthorized
if the token is supposed to be referenced as the authfile, I'm not sure it's checking that b/c it doesn't seem to care if it doesn't exist.
ramalama login --token=$HF_TOKEN huggingface
Token will not been saved to git credential helper. Pass `add_to_git_credential=True` if you want to set the git credential as well.
Token is valid (permission: read).
Your token has been saved to /Users/btofel/.cache/huggingface/token
Login successful
Do you think we should do this by default?
If you just look at the login command with ramalama --debug login ...
It should show the command ramalama is executing, you could just take that command and execute it locally to see if this fixes your problem.
@bentito I have never worked with the hugginface login to pull images, so I don't know if this works, but I would love to work with you to make it work. Could you ping me on the matrix channel.
Fixes: https://github.com/containers/ramalama/issues/465
Summary by Sourcery
Fix the handling of HuggingFace login by refining command execution and model path logic, enhance code clarity with refactored methods, and update garbage collection to include more repository paths.
Bug Fixes:
Enhancements: