-
Notifications
You must be signed in to change notification settings - Fork 869
fix:file already exist #1465
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:file already exist #1465
Conversation
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.
Summary of Changes
Hello @Koko-ry, 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 significantly enhances the AIGC (AI Generated Content) model creation and upload workflow. It introduces a crucial pre-upload mechanism for model weights to ensure server recognition of file hashes, thereby streamlining the process and preventing potential conflicts. Additionally, it improves the robustness of model creation by implementing stricter validation for model directories, ensuring that only valid and complete model data is processed. These changes aim to provide a more reliable and efficient experience for AIGC model management.
Highlights
- AIGC Model Weight Pre-upload: A new
preupload_weights
method has been introduced and integrated into the AIGC model creation process. This method performs a best-effort streaming upload of model weights to the LFS service, ensuring that the server recognizes the SHA256 hash of the weights before the model is formally created. This is crucial for preventing potential issues related to file existence or integrity during the main model upload. - Improved AIGC Model Directory Validation: Enhanced validation has been added for AIGC model directories. The system now checks if a provided directory is empty or if it contains only common placeholder files (e.g.,
.gitattributes
,configuration.json
,readme.md
). If such conditions are met, aValueError
is raised, ensuring that only directories with actual model files are accepted for AIGC model creation. - Generalized Repository URL Construction: The construction of the model repository URL has been generalized to use
repo_type
andrepo_id
, making the URL generation more flexible and adaptable to different repository types beyond just 'models'.
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 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
-
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.
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 introduces a pre-upload step for AIGC model creation to handle file existence checks on the server. The changes look mostly good, but I've found a critical issue in api.py
where undefined variables are used, which will cause a runtime error. I've also identified a potential AttributeError
in aigc.py
if headers are not provided. Please see my detailed comments for suggestions on how to fix these issues.
modelscope/hub/api.py
Outdated
@@ -270,9 +272,9 @@ def create_model(self, | |||
headers=self.builder_headers(self.headers)) | |||
handle_http_post_error(r, path, body) | |||
raise_on_error(r.json()) | |||
model_repo_url = f'{endpoint}/models/{model_id}' | |||
model_repo_url = f'{endpoint}/{repo_type}s/{repo_id}' |
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 variables repo_type
and repo_id
are not defined within the create_model
function's scope. This will cause a NameError
when this line is executed. The original implementation used model_id
, which is an available function parameter. It seems this line might have been copied from another method by mistake. To fix this, you should use model_id
and the hardcoded repo type models
as it was before.
model_repo_url = f'{endpoint}/{repo_type}s/{repo_id}' | |
model_repo_url = f'{endpoint}/models/{model_id}' |
modelscope/hub/utils/aigc.py
Outdated
headers.update({'Cookie': f"m_session_id={cookies['m_session_id']}"}) | ||
|
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 headers
parameter is optional and can be None
. If it is None
, the call to headers.update()
on line 269 will raise an AttributeError
. You should initialize headers
to an empty dictionary if it's None
before using it.
headers.update({'Cookie': f"m_session_id={cookies['m_session_id']}"}) | |
headers = headers or {} | |
headers.update({'Cookie': f"m_session_id={cookies['m_session_id']}"}) |
No description provided.