-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat(model_garden): add new samples to list models and deploy a model #13236
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
feat(model_garden): add new samples to list models and deploy a model #13236
Conversation
Here is the summary of changes. You are about to add 3 region tags.
This comment is generated by snippet-bot.
|
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.
Hello @wuliang229, 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
This pull request introduces new code samples for the Model Garden SDK, specifically focusing on deploying models and listing available models and deployment options. The samples are located in the /generative_ai/model_garden/sdk/
directory. The PR also includes a test file for the new SDK samples and updates the requirements files.
Highlights
- New code samples: Adds
default_deploy_example.py
,list_deployable_models_example.py
, andlist_deployment_options_example.py
to demonstrate the usage of the Model Garden SDK for deploying models and listing available options. - Test coverage: Includes
sdk_test.py
to provide test coverage for the new code samples, ensuring their functionality. - Dependency management: Updates
requirements.txt
andrequirements-test.txt
to include necessary dependencies for the new code samples and tests.
Changelog
Click here to see the changelog
- generative_ai/model_garden/claude_test.py
- Added tests for claude examples.
- generative_ai/model_garden/sdk/default_deploy_example.py
- Added a sample demonstrating how to deploy a model using the default configurations.
- generative_ai/model_garden/sdk/list_deployable_models_example.py
- Added a sample demonstrating how to list deployable models in Model Garden, with options to filter by Hugging Face models or model name.
- generative_ai/model_garden/sdk/list_deployment_options_example.py
- Added a sample demonstrating how to list verified deployment options for models in Model Garden.
- generative_ai/model_garden/sdk/noxfile_config.py
- Added noxfile configuration.
- generative_ai/model_garden/sdk/requirements-test.txt
- Added test requirements.
- generative_ai/model_garden/sdk/requirements.txt
- Added google-cloud-aiplatform as a requirement.
- generative_ai/model_garden/sdk/sdk_test.py
- Added tests for the new SDK samples, covering listing deployable models, listing deployment options, and default deployment.
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.
In gardens of code, where models reside,
SDK samples bloom, with functions to confide.
Deploying and listing, options unfold,
A tapestry woven, of stories untold.
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
The pull request introduces new code samples for the Model Garden SDK, covering functionalities like deploying models, listing deployable models, and listing deployment options. The samples seem well-structured and include necessary imports and basic usage examples. However, there are a few areas where improvements can be made to enhance clarity, robustness, and adherence to best practices.
Summary of Findings
- Missing Error Handling: The example code lacks explicit error handling. While these are examples, including basic error handling would demonstrate best practices and prevent unexpected crashes.
- Hardcoded Values: The examples use hardcoded values for model names and project locations. Consider using environment variables or configuration files to make the examples more flexible and reusable.
- TODO Comments: The examples contain TODO comments that should be addressed before merging. These comments indicate incomplete or placeholder code that needs to be finalized.
Merge Readiness
The pull request introduces valuable code samples for the Model Garden SDK. However, addressing the identified issues related to error handling, hardcoded values, and TODO comments is crucial before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.
model = model_garden.OpenModel(MODEL) | ||
endpoint = model.deploy() |
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.
Consider adding a try-except block to handle potential exceptions during model deployment. This will make the example more robust.
try:
model = model_garden.OpenModel(MODEL)
endpoint = model.deploy()
except Exception as e:
print(f"Error deploying model: {e}")
return None # Or raise the exception if appropriate
generative_ai/model_garden/sdk/list_deployable_models_example.py
Outdated
Show resolved
Hide resolved
generative_ai/model_garden/sdk/list_deployment_options_example.py
Outdated
Show resolved
Hide resolved
model = model_garden.OpenModel(MODEL) | ||
deploy_options = model.list_deploy_options() |
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.
Consider adding a try-except block to handle potential exceptions when listing deployment options. This will make the example more robust.
model = model_garden.OpenModel(MODEL) | |
deploy_options = model.list_deploy_options() | |
try: | |
model = model_garden.OpenModel(MODEL) | |
deploy_options = model.list_deploy_options() | |
except Exception as e: | |
print(f"Error listing deploy options: {e}") | |
return [] # Or raise the exception if appropriate |
…sdk to model_garden/sdk.
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.
Few more minor changes are required. Kindly check and update them.
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.
Last mile fixes
nit1: Use filenames as per the used regiontags. For aiplatform_modelgarden_gemma3_deploy
use filename as gemma3_deploy.py
nit2: vertexai.init
is missing in second samples
Description
model-garden/gemma
sub-folderChecklist