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

Do not raise if branch exists and no write permission #2426

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jul 29, 2024

Fix #2419 (and huggingface/datasets#7067 / huggingface/datasets#7069).

When creating a repo with exists_ok=True, if the user do not have permission to create it but the repo already exists, an HTTP 403 is returned by the server. We catch this error client-side and ignore it since the repo exists. This PR adds the same logic for create_branch.

cc @albertvillanova @lhoestq

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

src/huggingface_hub/hf_api.py Outdated Show resolved Hide resolved
Co-authored-by: Julien Chaumond <julien@huggingface.co>
Copy link
Member

@albertvillanova albertvillanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, @Wauplin.

Just to comment on another similar situation (reported as well by the community: https://discuss.huggingface.co/t/convert-to-parquet-fails-for-datasets-with-multiple-configs/86733/4).

When the user passes an existing PR branch, e.g. "refs/pr/1", and exists_ok=True:

  • In this case, a 400 Bad Request error is raised.
  • Should we raise or not in this case?

@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 30, 2024

Thanks for the reviews!

When the user passes an existing PR branch, e.g. "refs/pr/1", and exists_ok=True:

I think this should be something to fix in datasets directly. Having a 400 Bad request when trying to create the branch refs/pr/1 seems normal to me since it's not a branch.

@Wauplin Wauplin merged commit d432d2a into main Jul 30, 2024
12 of 17 checks passed
@Wauplin Wauplin deleted the 2419-do-not-raise-if-branch-exist-and-403 branch July 30, 2024 07: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.

Different behavior when passing exist_ok
5 participants