Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 18 commits into from
Mar 19, 2025

Conversation

wuliang229
Copy link
Contributor

@wuliang229 wuliang229 commented Mar 14, 2025

Description

  • Add 3 samples to model-garden/gemma sub-folder

Checklist

  • Please merge this PR for me once it is approved

@wuliang229 wuliang229 requested review from a team as code owners March 14, 2025 22:30
Copy link

snippet-bot bot commented Mar 14, 2025

Here is the summary of changes.

You are about to add 3 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Mar 14, 2025
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.

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, and list_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 and requirements-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

  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

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.

generative_ai/model_garden/sdk/default_deploy_example.py Outdated Show resolved Hide resolved
generative_ai/model_garden/sdk/default_deploy_example.py Outdated Show resolved Hide resolved
Comment on lines 38 to 39
model = model_garden.OpenModel(MODEL)
endpoint = model.deploy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Comment on lines 31 to 32
model = model_garden.OpenModel(MODEL)
deploy_options = model.list_deploy_options()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a try-except block to handle potential exceptions when listing deployment options. This will make the example more robust.

Suggested change
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

@msampathkumar msampathkumar self-assigned this Mar 17, 2025
generative_ai/model_garden/sdk/default_deploy_example.py Outdated Show resolved Hide resolved
generative_ai/model_garden/claude_test.py Outdated Show resolved Hide resolved
generative_ai/model_garden/sdk/sdk_test.py Outdated Show resolved Hide resolved
model_garden/deploy/deploy_gemma3_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployable_models_example.py Outdated Show resolved Hide resolved
model_garden/deploy/deploy_gemma3_example.py Outdated Show resolved Hide resolved
model_garden/deploy/deploy_gemma3_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployable_models_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployable_models_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployment_options_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployment_options_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployment_options_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployment_options_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployment_options_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployment_options_example.py Outdated Show resolved Hide resolved
model_garden/deploy/list_deployable_models_example.py Outdated Show resolved Hide resolved
Copy link
Member

@msampathkumar msampathkumar left a 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.

model_garden/gemma/deploy_gemma3_example.py Outdated Show resolved Hide resolved
model_garden/gemma/list_deployable_models_example.py Outdated Show resolved Hide resolved
Copy link
Member

@msampathkumar msampathkumar left a 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

@msampathkumar msampathkumar changed the title feat(generative-ai): Add code samples for the new Model Garden SDK feat(model-garden): add new code samples to list models and deploy a model with google-gemma3 as an example. Mar 19, 2025
@msampathkumar msampathkumar changed the title feat(model-garden): add new code samples to list models and deploy a model with google-gemma3 as an example. feat(model_garden): add new samples to list models and deploy a model Mar 19, 2025
@msampathkumar msampathkumar merged commit f0706ba into GoogleCloudPlatform:main Mar 19, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.