-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
adding batch gemini predict sample #12606
base: main
Are you sure you want to change the base?
adding batch gemini predict sample #12606
Conversation
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
|
||
|
||
def batch_prediction_gemini_example( | ||
input_uri: str = None, output_uri: str = None |
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.
input_uri: str = None, output_uri: str = None | |
input_uri: Optional[str] = None, output_uri: Optional[str] = None |
Also add:
from typing import Optional
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.
updated.
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.
I think this is the same as it was before. Also, should these parameters be optional/default None? Aren't those required parameters for the method?
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 is an old version
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.
updated params
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.
Looks like a duplicate file. Change the name to use all underscores and replace the previous file.
The issue was importing the preview resource. When I first created this sample it was working using the preview namespace (which as fine when I first started working on this sample), but the samples and testing in the batch predict folder uses the aiplatform namespace. Both aiplatform and vertexai.preview have a BatchPredictionJob class and they work a little different. I updated my sample to use the BatchPredictionJob class in the aiplatform namespace. |
I think this sample should be using the I'll defer to the Vertex AI SDK product team @Ark-kun (or other) This notebook from @gericdong also uses the https://github.com/GoogleCloudPlatform/generative-ai/pull/1138/files |
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.
Btw, something I missed in our sync. The older PaLM samples use aiplatform
instead of vertexai
because the Batch Prediction methods weren't implemented yet in vertexai
when PaLM was released.
import os | ||
from typing import Optional | ||
|
||
from google.cloud.aiplatform import BatchPredictionJob |
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.
from google.cloud.aiplatform import BatchPredictionJob | |
from vertexai.preview.batch_prediction import BatchPredictionJob |
""" | ||
|
||
# [START generativeaionvertexai_batch_predict_gemini_createjob] | ||
from google.cloud import aiplatform |
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.
from google.cloud import aiplatform | |
import vertexai | |
from vertexai.preview.batch_prediction import BatchPredictionJob |
# output_uri = bq://example_project.example_dataset.example_table or gs://mybucket/sampledataset.json | ||
|
||
# Initialize | ||
aiplatform.init(project=PROJECT_ID, location=LOCATION) |
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.
aiplatform.init(project=PROJECT_ID, location=LOCATION) | |
vertexai.init(project=PROJECT_ID, location=LOCATION) |
aiplatform.init(project=PROJECT_ID, location=LOCATION) | ||
|
||
# Create the batch prediction job using BatchPredictionJob | ||
batch_prediction_job = aiplatform.BatchPredictionJob.create( |
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.
batch_prediction_job = aiplatform.BatchPredictionJob.create( | |
batch_prediction_job = BatchPredictionJob.create( |
Looks like you're getting an error in the tests:
|
print(f"Job output location: {batch_prediction_job.output_location}") | ||
|
||
# Example response: | ||
# Job output location: gs://yourbucket/gen-ai-batch-prediction/prediction-model-year-month-dayThour:minute:second.12345 |
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.
# Job output location: gs://yourbucket/gen-ai-batch-prediction/prediction-model-year-month-dayThour:minute:second.12345 | |
# Job output location: gs://yourbucket/gen-ai-batch-prediction/prediction-model-year-month-day-hour:minute:second.12345 |
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.
updated.
|
||
|
||
def batch_prediction_gemini_example( | ||
input_uri: str = None, output_uri: str = None |
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.
I think this is the same as it was before. Also, should these parameters be optional/default None? Aren't those required parameters for the method?
Description
Fixes #
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
nox -s py-3.9
(see Test Environment Setup)nox -s lint
(see Test Environment Setup)