@@ -89,113 +89,122 @@ def main():
8989 """Agent Development Kit CLI tools."""
9090 pass
9191
92+
9293def add_common_deploy_options (command ):
93- """Add common options to deploy subcommands."""
94- options = [
94+ """Add common options to deploy subcommands."""
95+ options = [
96+ click .option (
97+ "--service_name" ,
98+ type = str ,
99+ default = "adk-default-service-name" ,
100+ help = (
101+ "Optional. The service name to use in target environment"
102+ " (default: 'adk-default-service-name')."
103+ ),
104+ ),
105+ click .option (
106+ "--env" ,
107+ multiple = True ,
108+ help = (
109+ "Optional. Environment variables as multiple --env key=value"
110+ " pairs."
111+ ),
112+ ),
113+ click .option (
114+ "--provider-args" ,
115+ multiple = True ,
116+ help = (
117+ "Optional. Provider-specific arguments as multiple"
118+ " --provider-args key=value pairs."
119+ ),
120+ ),
121+ click .option (
122+ "--app_name" ,
123+ type = str ,
124+ default = "" ,
125+ help = (
126+ "Optional. App name of the ADK API server (default: the folder"
127+ " name of the AGENT source code)."
128+ ),
129+ ),
130+ click .option (
131+ "--port" ,
132+ type = int ,
133+ default = 8000 ,
134+ help = "Optional. The port of the ADK API server (default: 8000)." ,
135+ ),
136+ click .option (
137+ "--trace_to_cloud" ,
138+ is_flag = True ,
139+ show_default = True ,
140+ default = False ,
141+ help = "Optional. Whether to enable cloud tracing for deployment." ,
142+ ),
143+ click .option (
144+ "--with_ui" ,
145+ is_flag = True ,
146+ show_default = True ,
147+ default = False ,
148+ help = (
149+ "Optional. Deploy ADK Web UI if set. (default: deploy ADK API"
150+ " server only)"
151+ ),
152+ ),
153+ click .option (
154+ "--temp_folder" ,
155+ type = str ,
156+ default = lambda : os .path .join (
157+ tempfile .gettempdir (),
158+ "deploy_src" ,
159+ datetime .now ().strftime ("%Y%m%d_%H%M%S" ),
160+ ),
161+ help = (
162+ "Optional. Temp folder for the generated source files"
163+ " (default: a timestamped folder in the system temp directory)."
164+ ),
165+ ),
166+ click .option (
167+ "--verbosity" ,
168+ type = click .Choice (
169+ ["debug" , "info" , "warning" , "error" , "critical" ],
170+ case_sensitive = False ,
171+ ),
172+ default = "WARNING" ,
173+ help = "Optional. Override the default verbosity level." ,
174+ ),
95175 click .option (
96- "--service_name" ,
97- type = str ,
98- default = "adk-default-service-name" ,
99- help = (
100- "Optional. The service name to use in target environment (default:"
101- " 'adk-default-service-name')."
102- ),
103- ),
104- click .option (
105- "--env" ,
106- multiple = True ,
107- help = "Optional. Environment variables as multiple --env key=value pairs." ,
108- ),
109- click .option (
110- "--provider-args" ,
111- multiple = True ,
112- help = "Optional. Provider-specific arguments as multiple --provider-args key=value pairs." ,
113- ),
114- click .option (
115- "--app_name" ,
116- type = str ,
117- default = "" ,
118- help = (
119- "Optional. App name of the ADK API server (default: the folder name"
120- " of the AGENT source code)."
121- ),
122- ),
123- click .option (
124- "--port" ,
125- type = int ,
126- default = 8000 ,
127- help = "Optional. The port of the ADK API server (default: 8000)." ,
128- ),
129- click .option (
130- "--trace_to_cloud" ,
131- is_flag = True ,
132- show_default = True ,
133- default = False ,
134- help = "Optional. Whether to enable cloud tracing for deployment." ,
135- ),
136- click .option (
137- "--with_ui" ,
138- is_flag = True ,
139- show_default = True ,
140- default = False ,
141- help = (
142- "Optional. Deploy ADK Web UI if set. (default: deploy ADK API server"
143- " only)"
144- ),
145- ),
146- click .option (
147- "--temp_folder" ,
148- type = str ,
149- default = lambda : os .path .join (
150- tempfile .gettempdir (),
151- "deploy_src" ,
152- datetime .now ().strftime ("%Y%m%d_%H%M%S" ),
153- ),
154- help = (
155- "Optional. Temp folder for the generated source files"
156- " (default: a timestamped folder in the system temp directory)."
157- ),
158- ),
159- click .option (
160- "--verbosity" ,
161- type = click .Choice (
162- ["debug" , "info" , "warning" , "error" , "critical" ], case_sensitive = False
163- ),
164- default = "WARNING" ,
165- help = "Optional. Override the default verbosity level." ,
166- ),
167- click .option (
168- "--session_db_url" ,
169- help = (
170- """Optional. The database URL to store the session.
176+ "--session_db_url" ,
177+ help = (
178+ """Optional. The database URL to store the session.
171179
172180 - Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
173181
174182 - Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
175183
176184 - See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
177- ),
178- ),
179- click .option (
180- "--adk_version" ,
181- type = str ,
182- default = version .__version__ ,
183- show_default = True ,
184- help = (
185- "Optional. The ADK version used in deployment. (default: the"
186- " version in the dev environment)"
187- ),
188- ),
189- click .argument (
190- "agent" ,
191- type = click .Path (
192- exists = True , dir_okay = True , file_okay = False , resolve_path = True
193- ),
194- ),
195- ]
196- for option in options :
197- command = option (command )
198- return command
185+ ),
186+ ),
187+ click .option (
188+ "--adk_version" ,
189+ type = str ,
190+ default = version .__version__ ,
191+ show_default = True ,
192+ help = (
193+ "Optional. The ADK version used in deployment. (default: the"
194+ " version in the dev environment)"
195+ ),
196+ ),
197+ click .argument (
198+ "agent" ,
199+ type = click .Path (
200+ exists = True , dir_okay = True , file_okay = False , resolve_path = True
201+ ),
202+ ),
203+ ]
204+ for option in options :
205+ command = option (command )
206+ return command
207+
199208
200209@main .group ()
201210def deploy ():
@@ -722,6 +731,7 @@ def cli_api_server(
722731 server = uvicorn .Server (config )
723732 server .run ()
724733
734+
725735@deploy .command ("cloud_run" , cls = HelpfulCommand )
726736@click .option (
727737 "--project" ,
@@ -785,6 +795,7 @@ def cli_deploy_to_cloud_run(
785795 except Exception as e :
786796 click .secho (f"Deploy failed: { e } " , fg = "red" , err = True )
787797
798+
788799@deploy .command ("docker" , cls = HelpfulCommand )
789800@add_common_deploy_options
790801def cli_deploy_docker (
@@ -801,30 +812,30 @@ def cli_deploy_docker(
801812 provider_args : Tuple [str ],
802813 env : Tuple [str ],
803814):
804- """Deploys an agent to Docker container.
815+ """Deploys an agent to Docker container.
805816
806- AGENT: The path to the agent source code folder.
817+ AGENT: The path to the agent source code folder.
807818
808- Example:
809- adk deploy docker path/to/my_agent
810- """
811- try :
812- cli_deploy .run (
813- agent_folder = agent ,
814- project = None ,
815- region = None ,
816- provider = "docker" ,
817- service_name = service_name ,
818- app_name = app_name ,
819- temp_folder = temp_folder ,
820- port = port ,
821- trace_to_cloud = trace_to_cloud ,
822- with_ui = with_ui ,
823- verbosity = verbosity ,
824- session_db_url = session_db_url ,
825- adk_version = adk_version ,
826- provider_args = provider_args ,
827- env = env ,
828- )
829- except Exception as e :
830- click .secho (f"Deploy failed: { e } " , fg = "red" , err = True )
819+ Example:
820+ adk deploy docker path/to/my_agent
821+ """
822+ try :
823+ cli_deploy .run (
824+ agent_folder = agent ,
825+ project = None ,
826+ region = None ,
827+ provider = "docker" ,
828+ service_name = service_name ,
829+ app_name = app_name ,
830+ temp_folder = temp_folder ,
831+ port = port ,
832+ trace_to_cloud = trace_to_cloud ,
833+ with_ui = with_ui ,
834+ verbosity = verbosity ,
835+ session_db_url = session_db_url ,
836+ adk_version = adk_version ,
837+ provider_args = provider_args ,
838+ env = env ,
839+ )
840+ except Exception as e :
841+ click .secho (f"Deploy failed: { e } " , fg = "red" , err = True )
0 commit comments