Skip to content

Commit fda153f

Browse files
fix: address Gemini code review feedback
- Use specific ZoneInfoNotFoundError exception instead of generic Exception - Define REQUIREMENTS variable once and reuse to avoid duplication - Keep generic Exception as fallback for unexpected errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ad1f592 commit fda153f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

notebooks/community/agent_engine/adk_inline_source_deployment.ipynb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,13 @@
102102
"metadata": {},
103103
"outputs": [],
104104
"source": [
105-
"!pip install --upgrade --quiet \\\n",
106-
" \"google-cloud-aiplatform[adk,agent_engines]>=1.88.0\" \\\n",
107-
" \"google-adk>=1.18.0\""
105+
"# Define requirements once for reuse\n",
106+
"REQUIREMENTS = [\n",
107+
" \"google-cloud-aiplatform[adk,agent_engines]>=1.88.0\",\n",
108+
" \"google-adk>=1.18.0\",\n",
109+
"]\n",
110+
"\n",
111+
"!pip install --upgrade --quiet {\" \".join(REQUIREMENTS)}"
108112
]
109113
},
110114
{
@@ -247,8 +251,10 @@
247251
" tz = ZoneInfo(timezone)\n",
248252
" now = datetime.datetime.now(tz)\n",
249253
" return f\"The current time in {timezone} is {now.strftime('%Y-%m-%d %H:%M:%S %Z')}\"\n",
254+
" except ZoneInfoNotFoundError:\n",
255+
" return f\"Error: Timezone '{timezone}' not found. Please use a valid IANA timezone name (e.g., 'America/New_York', 'UTC').\"\n",
250256
" except Exception as e:\n",
251-
" return f\"Error getting time for timezone {timezone}: {e}\"\n",
257+
" return f\"An unexpected error occurred while getting time for timezone {timezone}: {e}\"\n",
252258
"\n",
253259
"\n",
254260
"# Create the agent\n",
@@ -358,10 +364,7 @@
358364
"# This may take a few minutes\n",
359365
"remote_app = agent_engines.create(\n",
360366
" app,\n",
361-
" requirements=[\n",
362-
" \"google-cloud-aiplatform[adk,agent_engines]>=1.88.0\",\n",
363-
" \"google-adk>=1.18.0\",\n",
364-
" ],\n",
367+
" requirements=REQUIREMENTS,\n",
365368
" display_name=\"time-agent-inline\",\n",
366369
")\n",
367370
"\n",

0 commit comments

Comments
 (0)