-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(generativeai): Create genai_sdk_supervised_checkpoints_view_chec… #13348
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
…kpoints_example.py
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 @yishan-pu, 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 adds a new example, genai_sdk_supervised_checkpoints_view_checkpoints_example.py
, to demonstrate how to view checkpoints from a tuning job using the genai SDK. The example retrieves a tuning job and then iterates through the checkpoints associated with the tuned model, printing the details of each checkpoint.
Highlights
- New Example: A new example script,
genai_sdk_supervised_checkpoints_view_checkpoints_example.py
, has been added to showcase how to view checkpoints from a tuning job. - Checkpoint Retrieval: The example demonstrates how to retrieve a tuning job and access its checkpoints using the genai SDK.
- Checkpoint Printing: The example iterates through the checkpoints and prints their details, including checkpoint ID, epoch, step, and endpoint.
Changelog
- generative_ai/model_tuning/genai_sdk_supervised_checkpoints_view_checkpoints_example.py
- Added a new file containing an example of how to view checkpoints from a tuning job using the genai SDK.
- The example retrieves a tuning job by its name.
- The example iterates through the checkpoints associated with the tuning job's tuned model.
- The example prints the details of each checkpoint, including checkpoint ID, epoch, step, and endpoint.
- The example includes a
TODO
comment to remind the user to update thePROJECT_ID
variable.
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.
A checkpoint's gleam,
A step in the tuning stream,
Progress we can see.
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 code introduces a new example for viewing checkpoints from a tuning job using the genai SDK. The example seems straightforward and helpful for users who want to monitor their tuning jobs. However, there are a few areas that could be improved for clarity and robustness.
Summary of Findings
- Missing Error Handling: The code lacks error handling for the
client.tunings.get
call. If the tuning job does not exist or there's an issue retrieving it, the program will likely crash. Adding error handling would make the example more robust. - Hardcoded values: The
name
variable contains hardcoded project and tuning job IDs. While this is an example, it would be better to either fetch these values dynamically or provide clear instructions on how to replace them with the user's own values. - TODO comment: The TODO comment on line 27 should be addressed, either by providing a default value or removing the comment if it's no longer relevant.
Merge Readiness
The code is a good starting point, but I recommend addressing the missing error handling and hardcoded values before merging. The TODO comment should also be resolved. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.
name = ( | ||
"projects/123456789012/locations/us-central1/tuningJobs/123456789012345" | ||
) | ||
tuning_job = client.tunings.get(name=name) |
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.
It's important to handle potential errors when calling the get
method. What happens if the tuning job does not exist, or the user does not have permissions to view it? Consider adding a try-except block to catch exceptions and provide a more informative error message.
try:
tuning_job = client.tunings.get(name=name)
except Exception as e:
print(f"Error getting tuning job: {e}")
return None # Or raise the exception, depending on desired behavior
# TODO(developer): Update and un-comment below lines | ||
# PROJECT_ID = "your-project-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.
Consider providing a default value for PROJECT_ID
if it's not found in the environment, or removing this comment if it's no longer needed.
# TODO(developer): Update and un-comment below lines | |
# PROJECT_ID = "your-project-id" | |
# PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT", "your-project-id") |
name = ( | ||
"projects/123456789012/locations/us-central1/tuningJobs/123456789012345" | ||
) |
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.
This name
variable is hardcoded. While this is an example, it would be beneficial to provide instructions on how to replace these values with the user's own project and tuning job IDs. Consider adding a comment explaining this.
# TODO(developer): Replace with your project and tuning job IDs
name = (
"projects/123456789012/locations/us-central1/tuningJobs/123456789012345"
)
Here is the summary of possible violations 😱 There is a possible violation for not having product prefix.
The end of the violation section. All the stuff below is FYI purposes only. Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
Add an example to view checkpoints from a tuning job.