I am testing the Vertex AI Agent: data_science. I need to save the AI generated chart png file to GCS bucket automatically when it is created. The file only save to the InMemoryArtifact now. I checked the ADK docs, it is so confusing, and it does not have a sample how to use the module: GcsArtifactService to save files. Is anybody knowing about it?
Based on that insight, here’s a solution that worked for me:
Step 1: Add an environment variable ARTIFACT_SERVICE_URI="gs://your-gs-bucket-name"
Step 2: Within python/agents/data-science/main.py, add
artifact_service_uri = os.getenv(“ARTIFACT_SERVICE_URI”, None)
if artifact_service_uri:
app_args["artifact_service_uri"] = artifact_service_uri
else:
logger.log_text(
"ARTIFACT_SERVICE_URI not provided. Using in-memory artifact service instead. "
"All artifacts will be lost when the server restarts or redeploys.",
severity="WARNING",
)