-
Notifications
You must be signed in to change notification settings - Fork 902
[Fix] HubAPI token usage #1593
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
[Fix] HubAPI token usage #1593
Conversation
Summary of ChangesHello @Yunnglin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses and refines the usage of authentication tokens within the HubAPI. The primary goal is to ensure that the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request consistently propagates the token parameter across various API methods to fix HubAPI token usage, which is a good and necessary change for handling authentication with private repositories. The changes are logical and well-implemented. I've identified one area for improvement in error handling when loading cookies, which could prevent potential unhandled exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes token authentication usage in the HubAPI by properly propagating the token parameter throughout the API call chain and changing dataset access configuration to use token-based authentication instead of cookie-based authentication.
Changes:
- Modified
get_dataset_access_config_sessioncalls to use token-based authentication by settingcheck_cookie=False - Propagated the
tokenparameter through multiple API methods includingget_endpoint_for_read,repo_exists,get_dataset_files,get_model,get_dataset_id_and_type,create_model, andset_repo_visibility - Updated
Repositoryinitialization calls to include theauth_tokenparameter - Added a null check for empty cookies in
ModelScopeConfig.get_cookies()
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| modelscope/msdatasets/utils/oss_utils.py | Changed dataset access configuration to use token authentication instead of cookies |
| modelscope/hub/file_download.py | Added token parameter to get_endpoint_for_read and get_dataset_files calls |
| modelscope/hub/api.py | Propagated token parameter through multiple API methods and added null check for empty cookies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if os.path.exists(cookies_path): | ||
| with open(cookies_path, 'rb') as f: | ||
| cookies = pickle.load(f) | ||
| if not cookies: |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check if not cookies: will evaluate to False for an empty CookieJar object, even though it's not None. This will prevent the function from returning None for empty cookie jars. Consider using if cookies is not None and len(cookies) == 0: instead to properly check for empty cookie jars.
| if not cookies: | |
| if cookies is not None and len(cookies) == 0: |
No description provided.