Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/google/adk/cli/cli_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def to_agent_engine(
absolutize_imports: bool = True,
project: Optional[str] = None,
region: Optional[str] = None,
service_account: Optional[str] = None,
display_name: Optional[str] = None,
description: Optional[str] = None,
requirements_file: Optional[str] = None,
Expand Down Expand Up @@ -395,6 +396,7 @@ def to_agent_engine(
import statements.
project (str): Optional. Google Cloud project id.
region (str): Optional. Google Cloud region.
service_account (str): Optional. Google Cloud service account
display_name (str): Optional. The display name of the Agent Engine.
description (str): Optional. The description of the Agent Engine.
requirements_file (str): Optional. The filepath to the `requirements.txt`
Expand Down Expand Up @@ -518,6 +520,19 @@ def to_agent_engine(
else:
region = env_region
click.echo(f'{region=} set by GOOGLE_CLOUD_LOCATION in {env_file}')
if 'GOOGLE_CLOUD_SERVICE_ACCOUNT' in env_vars:
env_sa = env_vars.pop('GOOGLE_CLOUD_SERVICE_ACCOUNT')
if env_sa:
if service_account:
click.secho(
'Ignoring GOOGLE_CLOUD_SERVICE_ACCOUNT as `--service_account`'
' was explicitly passed and takes precedence',
fg='yellow',
)
else:
service_account = env_sa
click.echo(f"""{service_account=} set by
GOOGLE_CLOUD_SERVICE_ACCOUNT in {env_file}""")
if env_vars:
if 'env_vars' in agent_config:
click.echo(
Expand All @@ -526,6 +541,9 @@ def to_agent_engine(
agent_config['env_vars'] = env_vars
# Set env_vars in agent_config to None if it is not set.
agent_config['env_vars'] = agent_config.get('env_vars', env_vars)
# set service account if specified
if service_account:
agent_config['service_account'] = service_account

vertexai.init(
project=project,
Expand Down
12 changes: 12 additions & 0 deletions src/google/adk/cli/cli_tools_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,16 @@ def cli_deploy_cloud_run(
" GOOGLE_CLOUD_LOCATION in the .env file (if it exists)."
),
)
@click.option(
"--service_account",
type=str,
help=(
"Optional. Google Cloud service account to be used by the agent."
"It will override GOOGLE_CLOUD_SERVICE_ACCOUNT in the .env file "
"(if it exists). If not provided, "
"the AI Platform Reasoning Engine Service Agent will be used."
),
)
@click.option(
"--staging_bucket",
type=str,
Expand Down Expand Up @@ -1222,6 +1232,7 @@ def cli_deploy_agent_engine(
agent: str,
project: str,
region: str,
service_account: Optional[str],
staging_bucket: str,
agent_engine_id: Optional[str],
trace_to_cloud: bool,
Expand All @@ -1247,6 +1258,7 @@ def cli_deploy_agent_engine(
agent_folder=agent,
project=project,
region=region,
service_account=service_account,
staging_bucket=staging_bucket,
agent_engine_id=agent_engine_id,
trace_to_cloud=trace_to_cloud,
Expand Down