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

Request for new pypi release of sentence-transformers, to fix bug with model.save_to_hub(...) #1925

Closed
Loquats opened this issue May 18, 2023 · 2 comments · Fixed by #2376
Closed

Comments

@Loquats
Copy link

Loquats commented May 18, 2023

Summary

When I call save_to_hub, it throws an exception: TypeError: HfApi.create_repo() got an unexpected keyword argument 'organization'. This is because it calls outdated API and doesn't work with the latest version of huggingface-hub.

The issue is actually fixed on master branch. Would it be possible to make a new pypi release of sentence-transformers so that we can use the fix? Thank you!

Details

Repro:

from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
model.save_to_hub("loquats")

Error message and stack trace:

File /databricks/python/lib/python3.10/site-packages/sentence_transformers/SentenceTransformer.py:467, in SentenceTransformer.save_to_hub(self, repo_name, organization, private, commit_message, local_model_path, exist_ok, replace_model_card, train_datasets)
    464         raise ValueError("You passed and invalid repository name: {}.".format(repo_name))
    466 endpoint = "https://huggingface.co"
--> 467 repo_url = HfApi(endpoint=endpoint).create_repo(
    468         token,
    469         repo_name,
    470         organization=organization,
    471         private=private,
    472         repo_type=None,
    473         exist_ok=exist_ok,
    474     )
    475 full_model_name = repo_url[len(endpoint)+1:].strip("/")
    477 with tempfile.TemporaryDirectory() as tmp_dir:
    478     # First create the repo (and clone its content if it's nonempty).

File /databricks/python/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:120, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
    117 if check_use_auth_token:
    118     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> 120 return fn(*args, **kwargs)

TypeError: HfApi.create_repo() got an unexpected keyword argument 'organization'

Package versions:

  • sentence-transformers 2.2.2
  • huggingface-hub 0.14.1

(both are latest version)

sentence-transformers 2.2.2 calls an outdated implementation of create_repo here

This is actually fixed on master branch, so a workaround is to install the master version using:

pip install --upgrade --force-reinstall --no-deps git+https://github.com/UKPLab/sentence-transformers.git

Then I can run save_to_hub and it works.

@ydennisy
Copy link

+1 on this!! @nreimers

@amansrivastava17
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants