Skip to content

Conversation

@Yunnglin
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 15, 2026 11:04
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 token parameter is correctly passed and utilized across a wider range of API operations, enhancing the consistency and security of authenticated interactions with the ModelScope Hub. Additionally, it includes a minor improvement to cookie handling and adjusts the cookie checking behavior for dataset access configurations.

Highlights

  • Token Propagation: The token parameter has been added and propagated through various HubAPI methods, including get_endpoint_for_read, repo_exists, create_model, Repository initialization, get_dataset_file_list, get_model, and get_dataset_id_and_type. This ensures that authentication tokens are consistently used across relevant API calls.
  • Cookie Handling Improvement: A check has been added in the get_cookies function to explicitly return None if the loaded cookies list is empty, preventing potential issues with subsequent cookie processing.
  • Dataset Access Configuration: The check_cookie parameter in get_dataset_access_config_session calls within oss_utils.py has been changed from True to False, modifying how dataset access credentials are retrieved.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Copy link

Copilot AI left a 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_session calls to use token-based authentication by setting check_cookie=False
  • Propagated the token parameter through multiple API methods including get_endpoint_for_read, repo_exists, get_dataset_files, get_model, get_dataset_id_and_type, create_model, and set_repo_visibility
  • Updated Repository initialization calls to include the auth_token parameter
  • 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:
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
if not cookies:
if cookies is not None and len(cookies) == 0:

Copilot uses AI. Check for mistakes.
@Yunnglin Yunnglin merged commit 599d60a into master Jan 15, 2026
8 of 9 checks passed
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.

3 participants