Skip to content

[BC] Introduce decorator hack to preserve BC with incorrect usage of save_to_hub#2380

Merged
tomaarsen merged 1 commit intohuggingface:masterfrom
tomaarsen:bc/save_to_hub
Dec 14, 2023
Merged

[BC] Introduce decorator hack to preserve BC with incorrect usage of save_to_hub#2380
tomaarsen merged 1 commit intohuggingface:masterfrom
tomaarsen:bc/save_to_hub

Conversation

@tomaarsen
Copy link
Copy Markdown
Member

Related to #2376

Hello!

Pull Request overview

  • Introduce decorator hack to preserve BC with incorrect usage of save_to_hub

Details

By incorrect usage I am referring to providing keyword arguments using positional arguments & vice versa. Through this new decorator, you can once again do:

url = model.save_to_hub(repo_name="sentence-transformers-testing/stsb-bert-tiny-safetensors")

and

url = model.save_to_hub(
    "stsb-bert-tiny-safetensors", # repo_name
    "sentence-transformers-testing", # organization
    True, # private
    "Adding new awesome Model!", # commit message
    exist_ok=True,
)

I've added tests to ensure that the behaviour is indeed the same as before.

Note

This decorator hack can only be applied once, if another keyword argument is also introduced in a future version, then we can't allow positional arguments to be used with keyword arguments anymore.

cc: @osanseviero

  • Tom Aarsen

…to_hub

E.g. providing keyword arguments using positional arguments & vice versa.
@tomaarsen tomaarsen merged commit 9a2e415 into huggingface:master Dec 14, 2023
@tomaarsen tomaarsen deleted the bc/save_to_hub branch December 14, 2023 15:26
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.

1 participant