-
Notifications
You must be signed in to change notification settings - Fork 5
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
Download from HuggingFace with private token #390
base: main
Are you sure you want to change the base?
Conversation
I managed to adapt the Traceback (most recent call last):
File "/home/mazitov/apps/anaconda3/envs/metatrain/lib/python3.11/site-packages/metatrain/__main__.py", line 105, in main
export_model(**args.__dict__)
TypeError: export_model() got an unexpected keyword argument 'huggingface_api_token' which is related to the fact that in the Even though loading the model explicitly worked for me, it only worked while loading from the |
(Downloading private models is also supported, only through HuggingFace and using the | ||
``--huggingface_api_token`` flag.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Downloading private models is also supported, only through HuggingFace and using the | |
``--huggingface_api_token`` flag.) | |
Downloading private HuggingFace models is also supported, by specifying the corresponding API token with the ``--huggingface_api_token`` flag. |
|
||
if urlparse(str(path)).scheme: | ||
# Download from HuggingFace with a private token | ||
if kwargs.get("huggingface_api_token"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we/can we had a test for this on CI? Maybe creating a cosmo account on HuggingFace & uploading a dummy model+checkpoint there.
# make sure to copy the checkpoint to the current directory | ||
shutil.copy(path, Path.cwd() / str(path).split("/")[-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont understand why this is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if you want the file to be directly downloaded to the current directory you can do
path, _ = urlretrieve(
url=str(path),
filename=str(Path.cwd() / str(path).split("/")[-1]))
See https://docs.python.org/3/library/urllib.request.html#urllib.request.urlretrieve.
I like this! Down the line, we could maybe add a way to read the API token from env variables or a file; and use such mechanism for all external integrations (W&B seems like a very logical one to add next). |
If you have a private model on Hugging Face, there are effective third-party tools like As for W&B, it’s a different story, and I fully support adding a functionality, because users can’t access the benefits of W&B without us integrating it directly into the code. |
As in the title
Contributor (creator of pull-request) checklist
📚 Documentation preview 📚: https://metatrain--390.org.readthedocs.build/en/390/