Skip to content

get_safetensors_metadata() has no actual filename parameter despite showing one in the documentation #2731

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

Closed
boyleconnor opened this issue Jan 4, 2025 · 1 comment · Fixed by #2738

Comments

@boyleconnor
Copy link

boyleconnor commented Jan 4, 2025

The docstring (and auto-generated web docs) for get_safetensors_metadata() claim there is a filename parameter, but there is none in the actual function signature. Example code:

>>> from huggingface_hub import get_safetensors_metadata
>>> x = get_safetensors_metadata("dslim/bert-base-NER")  # This works fine
>>> x = get_safetensors_metadata("dslim/bert-base-NER", filename="model.safetensors")  # This fails
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: HfApi.get_safetensors_metadata() got an unexpected keyword argument 'filename'
>>> import huggingface_hub
>>> huggingface_hub.__version__  # I'm using a slightly old version of HF Hub but the git blame says the function signature is entirely unchanged for the last 9 months
'0.24.6'

Ideally, an error like this should be caught by a pre-commit hook.

@hanouticelina
Copy link
Contributor

Hi @boyleconnor, thanks for catching this! it's indeed an oversight in the docstring, to parse parse metadata from a single safetensors file, we recommend using parse_safetensors_file_metadata() instead as get_safetensors_metadata() is meant to parse a safetensors repo.
a PR #2738 is open to fix this!

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 a pull request may close this issue.

2 participants