401 Deadline exception when using Imagen Python
Maintainers usually reply within 5 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start with the supplied Imagen Python snippet and the Cloud Run error log showing a 401 Deadline failure. Check whether the failure can be reproduced around model.generate_images and determine the relevant Vertex AI request behavior; the issue is complete when the cause and a verified resolution are documented.
Written by the indexing model from the issue text.
Description
Example code:
vertexai.init(project=PROJECT_ID, location=LOCATION)
model: ImageGenerationModel = ImageGenerationModel.from_pretrained(model_name=MODEL_NAME)
Common.log_info(message='Handling image generation request')
Common.log_https_request(req=req)
data: dict = req.data
prompt: str = data.get(PROMPT_KEY, '')
user_id: str = req.auth.uid
if not user_id:
Common.log_info(message='Invalid user id, not generating image')
return
if not prompt:
Common.log_info(message='Invalid prompt, not generating image')
return
number_of_images: int = data.get(NUMBER_OF_IMAGES_KEY, 1)
guidance_scale: int = data.get(GUIDANCE_SCALE_KEY, MEDIUM_GUIDANCE_SCALE)
output_image_path: str = (GENERATED_IMAGE_PREFIX + user_id +
'/' +
Common.get_current_datetime() + '/' +
Common.replace_all_whitespace_with_underscore(
input_string=prompt) + JPEG_SUFFIX)
output_gcs_uri: str = BUCKET_URI_PREFIX + output_image_path
Common.log_info(message=f'Generating image at: {output_gcs_uri}')
model.generate_images(
prompt=prompt,
number_of_images=number_of_images,
aspect_ratio=Common.convert_to_aspect_ratio(input_string=data.get(ASPECT_RATIO_KEY, '')),
output_gcs_uri=BUCKET_URI_PREFIX + output_image_path,
language=AUTO_LANGUAGE_DETECTION,
guidance_scale=guidance_scale,
add_watermark=False,
safety_filter_level=STRICT_SAFETY_FILTER,
person_generation=ALLOW_ADULT_PERSON_GENERATION,
)
Common.log_info(message=f'Generated image at: {output_image_path}')
return {
GENERATED_IMAGE_PATH_KEY: output_image_path
}
Log output
{
insertId: "668e115800009112eb018410"
labels: {
execution_id: "RCyLEQaZkqtT"
goog-managed-by: "cloudfunctions"
instanceId: "0087244a805cf6d58e414f53f12334887c32a9193fd30e864537965aed11aef51420d9a28124761e498af43bce228ec8099599bc142b0e59e58e9ea6dac43d80"
}
logName: "projects/claptrap-project/logs/run.googleapis.com%2Fstderr"
receiveTimestamp: "2024-07-10T04:43:04.043022212Z"
resource: {
labels: {
configuration_name: "generate-images"
location: "us-central1"
project_id: "claptrap-project"
revision_name: "generate-images-00004-mil"
service_name: "generate-images"
}
type: "cloud_run_revision"
}
severity: "ERROR"
spanId: "10602671325904409459"
textPayload: "An exception occurred: 401 Image generation failed with the following error: Deadline"
timestamp: "2024-07-10T04:43:04.037138Z"
}
- Dominant language
- Jupyter Notebook
- Stars
- 8.1k
- Forks
- 6.7k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GoogleCloudPlatform/python-docs-samples
-
samples
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
GoogleCloudPlatform/python-docs-samples#14609 ·
Maintainers usually reply within 5 days
-
samples
Difficulty 1/5 Under an hour Newbie friendliness 92/100
GoogleCloudPlatform/python-docs-samples#14610 ·
Maintainers usually reply within 5 days
-
samples
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
GoogleCloudPlatform/python-docs-samples#14611 ·
Maintainers usually reply within 5 days
-
chore(generative_ai) Update model references for generative_ai samplesMay be free again @XrossFox claimed this 156 days ago, and no pull request is open. Opensamples
GoogleCloudPlatform/python-docs-samples#14117 · 1 assignee ·
Maintainers usually reply within 5 days
-
Fix Pipeline dependency issues for geospatial-classification/serving_appMay be free again @XrossFox claimed this 168 days ago, and no pull request is open. Opensamples
GoogleCloudPlatform/python-docs-samples#14091 · 1 assignee ·
Maintainers usually reply within 5 days
All issues in GoogleCloudPlatform/python-docs-samples
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
code-yeongyu/senpi#2456 · 1 comment ·
Maintainers usually reply within 1 day
-
python triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/semantic-kernel#14512 · 1 comment ·
Maintainers usually reply within 4 days
-
discussions enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
code-yeongyu/oh-my-openagent#9290 · 1 comment ·
Maintainers usually reply within 1 day
-
bug bughunt good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
rajveer43/VeloxQuant-MLX#656 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day