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

✨ create_commit: more user-friendly errors on HTTP 400 #963

Merged
merged 4 commits into from
Aug 9, 2022

Conversation

SBrandeis
Copy link
Contributor

@SBrandeis SBrandeis commented Aug 2, 2022

Related to #962

This PR converts HTTP 400 errors from /api/preupload and /api/commit APIs into ValueErrors

Suggestions/feedback welcome

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 2, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

This looks nice, but it might cause some friction if users are catching those exceptions.

I'd suggest an exception class which inherits from ValueError and HTTPError so that existing user code would work.

The methods which can raise this exception can document it as ValueError, but if users are already catching HTTPError, their code wouldn't break after an upgrade.

WDYT?

@SBrandeis
Copy link
Contributor Author

That's a very valid point @adrinjalali, thanks for the suggestion!

Copy link
Contributor

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

src/huggingface_hub/_commit_api.py Show resolved Hide resolved
src/huggingface_hub/hf_api.py Show resolved Hide resolved
@SBrandeis SBrandeis requested a review from Wauplin August 2, 2022 09:32
@SBrandeis
Copy link
Contributor Author

cc @Wauplin

@Wauplin Wauplin merged commit f2e5c69 into huggingface:main Aug 9, 2022
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.

4 participants