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

Add request ID to all requests #909

Merged
merged 6 commits into from
Jun 15, 2022
Merged

Conversation

LysandreJik
Copy link
Member

This adds the X-Request-ID header to all requests that have it.

This will result in the following change:

- requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/api/login
+ requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/api/login (Request ID: T97cILAtyKzdWeL6dRYYW)

Closes #906

@LysandreJik LysandreJik requested a review from Pierrci June 15, 2022 08:07
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 15, 2022

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

@LysandreJik LysandreJik added this to the v0.8 milestone Jun 15, 2022
@LysandreJik LysandreJik mentioned this pull request Jun 15, 2022
Copy link
Contributor

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

LGTM, just have small nits. Thanks!

src/huggingface_hub/utils/_errors.py Outdated Show resolved Hide resolved
if request_id is not None and len(e.args) and isinstance(e.args[0], str):
e.args = (e.args[0] + f" (Request ID: {request_id})",) + e.args[1:]

raise e.with_traceback(e.__traceback__)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I get this part. with_traceback is usually used when you raise a new exception from an old one (and now it's actually recommended to use exception chaining, but here it shouldn't be necessary since you raise the same exception, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Very good point, thank you @sgugger!

LysandreJik and others added 2 commits June 15, 2022 15:45
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
@LysandreJik LysandreJik merged commit 7e80140 into huggingface:main Jun 15, 2022
LysandreJik added a commit that referenced this pull request Jun 16, 2022
* Add request ID to all requests

* Typo

* Typo

* Review comments

* Update src/huggingface_hub/utils/_errors.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
TristanThrush pushed a commit that referenced this pull request Jun 19, 2022
* Add request ID to all requests

* Typo

* Typo

* Review comments

* Update src/huggingface_hub/utils/_errors.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
@Pierrci
Copy link
Member

Pierrci commented Jun 20, 2022

Thanks!! ❤️

adrinjalali pushed a commit that referenced this pull request Jun 21, 2022
* added autoeval fields to repocard types

* modified test, linted

* Fix typo (#902)

* Refine 404 errors (#878)

* Add errors

* Style

* Review

* hf_hub_download support

* Errors for hf_hub_download

* Typo

* Handle 401 error

* Tests for 401 error

* Typo

* Review comments

* added documentation for the repocard change in repocard, updated metadata_eval_result, added documentation

* 🏗 Use `hub-ci` for tests (#898)

* 🏗 Use `hub-ci` for tests

cc @XciD

* 🩹 Also update URL for staging mode

* ✅ 401 is raised when the user is not authenticated

* 🗑 Deprecare `identical_ok`

* Longer deprecation period

* ✅ Fix the last failing test

* Warning match docstring

* FIX Avoid creating repository when it exists on remote (#900)

* fix for spaces

* fix for spaces

* removed creating repository and added warning

* revert my changes

* added tests

* removed debugger 😐

* fixed repository removal

* Added tests and error

* import pytest

* fixed tests

* fixed tests

* style

* removed repo removal

* make style

* fixed test with Lysandres patch

* added fix

* Remove deprecations (#910)

* Remove deprecations

* Typo

* Update src/huggingface_hub/README.md

Co-authored-by: Julien Chaumond <julien@huggingface.co>

Co-authored-by: Julien Chaumond <julien@huggingface.co>

* Add request ID to all requests (#909)

* Add request ID to all requests

* Typo

* Typo

* Review comments

* Update src/huggingface_hub/utils/_errors.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Invert deprecation for create_repo (#912)

* Invert deprecation for create_repo

* Set to 0.10

* Constant was accidentally removed during deprecation transition (#913)

Co-authored-by: Lyle Nel <lyle@owlin.com>

* Update src/huggingface_hub/repocard_types.py

Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>

* Update repocard_types.py

* Update repocard_types.py

* reorded metadata_eval_request_docs, added metrics_config and metrics_verified to tests

Co-authored-by: lsb <leebutterman@gmail.com>
Co-authored-by: Lysandre Debut <lysandre.debut@reseau.eseo.fr>
Co-authored-by: Simon Brandeis <33657802+SBrandeis@users.noreply.github.com>
Co-authored-by: Merve Noyan <merveenoyan@gmail.com>
Co-authored-by: Julien Chaumond <julien@huggingface.co>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Lyle Nel <lyle-nel@users.noreply.github.com>
Co-authored-by: Lyle Nel <lyle@owlin.com>
Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>
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.

Hub API calls: print X-Request-Id value in case of server error
4 participants