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

model.push_to_hub raises 409 Client Error #2972

Open
abedkhooli opened this issue Oct 5, 2024 · 3 comments
Open

model.push_to_hub raises 409 Client Error #2972

abedkhooli opened this issue Oct 5, 2024 · 3 comments

Comments

@abedkhooli
Copy link

After model trains and when calling push_to_hub, I get the following error. Was thinking due to multi GPU but happens on a single GPU as well.

HTTPError                                 Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_errors.py](https://localhost:8080/#) in hf_raise_for_status(response, endpoint_name)
    303     try:
--> 304         response.raise_for_status()
    305     except HTTPError as e:

5 frames
HTTPError: 409 Client Error: Conflict for url: https://huggingface.co/api/repos/create

The above exception was the direct cause of the following exception:

HfHubHTTPError                            Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_errors.py](https://localhost:8080/#) in hf_raise_for_status(response, endpoint_name)
    369         # Convert `HTTPError` into a `HfHubHTTPError` to display request information
    370         # as well (request id and/or server error message)
--> 371         raise HfHubHTTPError(str(e), response=response) from e
    372 
    373 

HfHubHTTPError: 409 Client Error: Conflict for url: https://huggingface.co/api/repos/create (Request ID: ...)

You already created this model repo
@CaoHaiNam
Copy link

If you are using the sentence-transformers library to push a model to the Hugging Face Hub, you can use the following command:

model.save_to_hub("your-model-name")

Alternatively, if you are using the transformers library directly, you can use:

model.push_to_hub("your-model-name")

The error you mentioned suggests that the model, in this case named your-model-name, has already been pushed to the Hugging Face Hub. In this case, you should delete the existing model from the Hub and then push it again. Hope this helps!

@pesuchin
Copy link
Contributor

pesuchin commented Oct 9, 2024

@abedkhooli
Hello!
The exist_ok option for model.push is set to False by default, so if you're pushing with the default setting, try changing it to True. Specifically, you can write it like this:

# model: SentenceTransformer
model.push_to_hub("your-model-name", exist_ok=True)

@tomaarsen
Copy link
Collaborator

Hello!

@pesuchin is right, I think that's the problem. By default, push_to_hub prevents you from overriding an existing model repository, just in case that was an accident. The exist_ok argument should allow you to push into an existing repository.

  • Tom Aarsen

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

No branches or pull requests

4 participants