-
Notifications
You must be signed in to change notification settings - Fork 235
Split the model store into multiple files #1640
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
Conversation
The source code for the model store is getting bigger, so splitting it into multiple source files under a directory helps keeping it easier to read. Signed-off-by: Michael Engel <[email protected]>
Reviewer's GuideRestructure the monolithic model_store.py into a modular package under ramalama/model_store, distributing core classes and constants into dedicated files and updating import paths accordingly. Class diagram for the new model store package structureclassDiagram
class ModelStore
class GlobalModelStore
class ModelFile
class RefFile
class SnapshotFile
class LocalSnapshotFile
class SnapshotFileType
ModelStore --> GlobalModelStore : uses
GlobalModelStore o-- ModelFile : contains
GlobalModelStore o-- RefFile : uses
RefFile <|-- RefFile : from_path (factory)
SnapshotFile <|-- LocalSnapshotFile
SnapshotFile --> SnapshotFileType : uses
LocalSnapshotFile --> SnapshotFileType : uses
GlobalModelStore --> SnapshotFileType : uses
%% File locations
class GlobalModelStore {
+__init__(base_path)
+list_models(engine, show_container)
+verify_snapshot()
+cleanup()
+path
}
class ModelFile {
+name: str
+modified: float
+size: int
+is_partial: bool
}
class RefFile {
+hash: str
+filenames: list[str]
+model_name: str
+chat_template_name: str
+mmproj_name: str
+path
+from_path(path)
+remove_file(name)
+serialize()
+write_to_file()
}
class SnapshotFile {
+url: str
+header: Dict
+hash: str
+name: str
+type: SnapshotFileType
+should_show_progress: bool
+should_verify_checksum: bool
+required: bool
+download(blob_file_path, snapshot_dir)
}
class LocalSnapshotFile {
+content: str
+download(blob_file_path, snapshot_dir)
}
class SnapshotFileType {
<<enum>>
Model
ChatTemplate
Other
Mmproj
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 @engelmi, 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 improves the maintainability and readability of the model_store
component by breaking down a large, single file into a well-organized directory structure with dedicated modules for different functionalities. This refactoring makes the codebase easier to navigate and understand for current and future developers.
Highlights
- Code Organization: The monolithic
ramalama/model_store.py
file has been refactored and split into a newramalama/model_store/
directory containing several specialized modules. - New Modules: Introduced
constants.py
for shared directory names,global_store.py
for theGlobalModelStore
class,reffile.py
for theRefFile
class, andsnapshot_file.py
forSnapshotFile
related classes and functions. - Import Path Updates: Updated import statements across various files (
cli.py
,hf_style_repo_base.py
,huggingface.py
,model.py
,modelscope.py
,ollama.py
,url.py
, and unit tests) to reflect the new modular structure of themodel_store
. - Core ModelStore: The main
ModelStore
class now resides inramalama/model_store/store.py
and imports its dependencies from the newly created, more granular modules.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @engelmi - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `ramalama/model_store/global_store.py:49` </location>
<code_context>
+ for snapshot_file in ref_file.filenames:
</code_context>
<issue_to_address>
Possible silent skipping of missing files.
Consider adding a warning or error log when both files are missing to aid debugging and clarify incomplete models.
</issue_to_address>
### Comment 2
<location> `ramalama/model_store/reffile.py:19` </location>
<code_context>
+ def path(self) -> str:
+ return self._path
+
+ def from_path(path: str) -> "RefFile":
+ ref_file = RefFile()
+ ref_file._path = path
</code_context>
<issue_to_address>
from_path should be a staticmethod or classmethod.
Since from_path doesn't use self and creates a new instance, it should be marked as @staticmethod or @classmethod for clarity.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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
The model store has been refactored into multiple files, which improves code maintainability. The changes include moving snapshot file logic, ref file logic, global store logic, store directory constants, and top-level store logic into separate modules. Import paths have been updated to reflect the new module structure.
Signed-off-by: Michael Engel <[email protected]>
LGTM |
The source code for the model store is getting bigger, so splitting it into multiple source files under a directory helps keeping it easier to read.
Summary by Sourcery
Split the monolithic model store into multiple focused modules and update references accordingly
Enhancements: