diff --git a/src/google/adk/cli/cli_deploy.py b/src/google/adk/cli/cli_deploy.py index 5082ba32..9b096d05 100644 --- a/src/google/adk/cli/cli_deploy.py +++ b/src/google/adk/cli/cli_deploy.py @@ -253,8 +253,8 @@ def to_agent_engine( temp_folder: str, adk_app: str, staging_bucket: str, - agent_engine_name: str, trace_to_cloud: bool, + agent_engine_id: Optional[str] = None, absolutize_imports: bool = True, project: Optional[str] = None, region: Optional[str] = None, @@ -294,9 +294,9 @@ def to_agent_engine( project (str): Google Cloud project id. region (str): Google Cloud region. staging_bucket (str): The GCS bucket for staging the deployment artifacts. - agent_engine_name (str): The name of the Agent Engine instance to update if - it exists. Format: `projects/{project}/locations/{location}/reasoningEngines/{resource_id}`. trace_to_cloud (bool): Whether to enable Cloud Trace. + agent_engine_id (str): The ID of the Agent Engine instance to update. If not + specified, a new Agent Engine instance will be created. absolutize_imports (bool): Whether to absolutize imports. If True, all relative imports will be converted to absolute import statements. Default is True. requirements_file (str): The filepath to the `requirements.txt` file to use. @@ -407,7 +407,7 @@ def to_agent_engine( click.echo('Deploying to agent engine...') agent_engine = agent_engines.ModuleAgent( - module_name='agent_engine_app', + module_name=adk_app, agent_name='adk_app', register_operations={ '': [ @@ -425,7 +425,7 @@ def to_agent_engine( 'async_stream': ['async_stream_query'], 'stream': ['stream_query', 'streaming_agent_run_with_events'], }, - sys_paths=[temp_folder], + sys_paths=[temp_folder[1:]], ) agent_config = dict( agent_engine=agent_engine, @@ -436,10 +436,11 @@ def to_agent_engine( extra_packages=[temp_folder], ) - if not agent_engine_name: + if not agent_engine_id: agent_engines.create(**agent_config) else: - agent_engines.update(resource_name=agent_engine_name, **agent_config) + name = f'projects/{project}/locations/{region}/reasoningEngines/{agent_engine_id}' + agent_engines.update(resource_name=name, **agent_config) finally: click.echo(f'Cleaning up the temp folder: {temp_folder}') shutil.rmtree(temp_folder) diff --git a/src/google/adk/cli/cli_tools_click.py b/src/google/adk/cli/cli_tools_click.py index 4124be22..c0671c58 100644 --- a/src/google/adk/cli/cli_tools_click.py +++ b/src/google/adk/cli/cli_tools_click.py @@ -947,14 +947,14 @@ def cli_deploy_cloud_run( help="Required. GCS bucket for staging the deployment artifacts.", ) @click.option( - "--agent_engine_name", + "--agent_engine_id", type=str, default=None, help=( - "Optional. Name of the Agent Engine instance to update if it exists" + "Optional. ID of the Agent Engine instance to update if it exists" " (default: None, which means a new instance will be created)." - " Format:" - " `projects/{project}/locations/{location}/reasoningEngines/{resource_id}`." + " The corresponding resource name in Agent Engine will be:" + " `projects/{project}/locations/{region}/reasoningEngines/{agent_engine_id}`." ), ) @click.option( @@ -1042,7 +1042,7 @@ def cli_deploy_agent_engine( project: str, region: str, staging_bucket: str, - agent_engine_name: Optional[str], + agent_engine_id: Optional[str], trace_to_cloud: bool, display_name: str, description: str, @@ -1065,7 +1065,7 @@ def cli_deploy_agent_engine( project=project, region=region, staging_bucket=staging_bucket, - agent_engine_name=agent_engine_name, + agent_engine_id=agent_engine_id, trace_to_cloud=trace_to_cloud, display_name=display_name, description=description, diff --git a/tests/unittests/cli/utils/test_cli_deploy.py b/tests/unittests/cli/utils/test_cli_deploy.py index 958a3879..3b708d10 100644 --- a/tests/unittests/cli/utils/test_cli_deploy.py +++ b/tests/unittests/cli/utils/test_cli_deploy.py @@ -454,7 +454,6 @@ def test_to_agent_engine_happy_path( temp_folder=str(temp_folder), adk_app="my_adk_app", staging_bucket="gs://my-staging-bucket", - agent_engine_name="", trace_to_cloud=True, project="my-gcp-project", region="us-central1",