Repository navigation
[Bugfix] Fix modelscope token passed in - #19389
Conversation
Signed-off-by: wangli <wangli858794774@gmail.com>
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
There was a problem hiding this comment.
Hello @Potabk, 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!
Summary of Changes
Hello team, Gemini or gemini-code-assist here to provide a summary of this pull request by @Potabk.
This PR addresses a bug where, when the VLLM_USE_MODELSCOPE environment variable is set, the system was incorrectly passing a potentially wrong token (likely intended for Hugging Face) to the modelscope_list_repo_files function. The fix ensures that the correct environment variable, MODELSCOPE_API_TOKEN, is explicitly read and passed as the token for ModelScope operations, or None if the variable is not set.
Highlights
- Bugfix: ModelScope Token Handling: Corrects the logic for passing the API token when interacting with ModelScope repositories under the
VLLM_USE_MODELSCOPEflag. - Environment Variable Usage: Ensures that the
MODELSCOPE_API_TOKENenvironment variable is the source for the token used with ModelScope functions, preventing the use of an incorrect or unintended token.
Changelog
- vllm/transformers_utils/config.py
- Modified the
lookup_filesfunction to explicitly useos.getenv("MODELSCOPE_API_TOKEN")as the token when callingmodelscope_list_repo_filesifenvs.VLLM_USE_MODELSCOPEis true (lines 144-147).
- Modified the
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 is currently in preview and 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 to provide feedback.
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
-
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. ↩
There was a problem hiding this comment.
Code Review
The pull request addresses a bug where an incorrect token (HF_TOKEN) was being passed when VLLM_USE_MODELSCOPE was enabled. The fix correctly retrieves the MODELSCOPE_API_TOKEN directly from the environment variables. This is a clear and effective solution to the described problem.
Summary of Findings
- Maintainability: Environment Variable Name as String Literal: The environment variable name
"MODELSCOPE_API_TOKEN"is used directly as a string literal. For better maintainability and to avoid potential typos or inconsistencies if this key is used elsewhere, consider defining it as a constant. This could be a local constant in the file or, for broader consistency within the project, defined invllm.envs.py.
Merge Readiness
The bugfix provided in this pull request is correct and effectively addresses the issue of passing the wrong token for ModelScope. The code is clear and the change is well-targeted.
I've included one medium-severity suggestion regarding the use of a string literal for the environment variable name, proposing the use of a constant for enhanced maintainability. This is a suggestion for improvement and does not affect the correctness of the current fix.
Overall, the PR is in good shape. As an AI reviewer, I am not authorized to approve pull requests. Please ensure this change is reviewed and approved by human maintainers before merging.
| return modelscope_list_repo_files( | ||
| repo_id, | ||
| revision=revision, | ||
| token=os.getenv("MODELSCOPE_API_TOKEN")) |
There was a problem hiding this comment.
This change correctly sources the ModelScope API token, resolving the issue of the wrong token being used. Well done!
For improved maintainability, have you considered defining the environment variable name "MODELSCOPE_API_TOKEN" as a constant? This approach can make it easier to manage and update environment variable keys across the codebase.
Possible ways to implement this:
- Define a module-level constant within this file (e.g.,
_MODELSCOPE_API_TOKEN_KEY = "MODELSCOPE_API_TOKEN"at the top ofconfig.py) and useos.getenv(_MODELSCOPE_API_TOKEN_KEY). - For greater consistency with how other environment variables like
envs.VLLM_USE_MODELSCOPEare handled in this project, you could consider addingMODELSCOPE_API_TOKENtovllm.envs.py. This would involve defining it in theTYPE_CHECKINGblock and adding a loader to theenvironment_variablesdictionary invllm.envs.py. Then, it could be accessed here asenvs.MODELSCOPE_API_TOKEN.
While the current implementation is correct, centralizing environment variable names can be beneficial in the long run. What are your thoughts on this?
Signed-off-by: wangli <wangli858794774@gmail.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Done |
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
|
@jeejeelee thx for fix it! |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Signed-off-by: wangli <wangli858794774@gmail.com> Signed-off-by: Jee Jee Li <pandaleefree@gmail.com> Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
Signed-off-by: wangli <wangli858794774@gmail.com> Signed-off-by: Jee Jee Li <pandaleefree@gmail.com> Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
Signed-off-by: wangli <wangli858794774@gmail.com> Signed-off-by: Jee Jee Li <pandaleefree@gmail.com> Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
When we set env
VLLM_USE_MODELSCOPE, the token is delivered as HF_TOKEN by mistake, so when should pass the real token or None