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

Exclude Colab Enterprise from Google Colab token retrieval #2529

Merged
merged 5 commits into from
Sep 10, 2024

Conversation

hanouticelina
Copy link
Contributor

Related to a request made by the Google Colab team in a private discussion on slack.

This PR changes the way token retrieval works in Google Colab environments by excluding Google Colab Enterprise. Colab Enterprise uses a different secrets manager, so we're excluding this environment from the Google Colab token retrieval method.

changes made:

  • Updated _get_token_from_google_colab() to detect and exclude Colab Enterprise

@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.

Comment on lines +306 to +308
def is_colab_enterprise() -> bool:
"""Return `True` if code is executed in a Google Colab Enterprise environment."""
return os.environ.get("VERTEX_PRODUCT") == "COLAB_ENTERPRISE"
Copy link
Member

Choose a reason for hiding this comment

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

maybe you could put this directly in is_google_colab? i.e. is_google_colab if on Colab but not on Colab Enterprise

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather keep it separated like this so that we have the correct information in the env dump (in case of a user reporting an issue)

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment on lines +306 to +308
def is_colab_enterprise() -> bool:
"""Return `True` if code is executed in a Google Colab Enterprise environment."""
return os.environ.get("VERTEX_PRODUCT") == "COLAB_ENTERPRISE"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather keep it separated like this so that we have the correct information in the env dump (in case of a user reporting an issue)

src/huggingface_hub/utils/_runtime.py Show resolved Hide resolved
@hanouticelina hanouticelina merged commit 3395e63 into main Sep 10, 2024
19 checks passed
@hanouticelina hanouticelina deleted the fix-colab-enterprise-token-detection branch September 10, 2024 13:35
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