mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Handle overriding of requirements when deploying to agent engine
Co-authored-by: Yeesian Ng <ysian@google.com> PiperOrigin-RevId: 850423017
This commit is contained in:
committed by
Copybara-Service
parent
26e77e1694
commit
38a30a44d2
@@ -771,25 +771,27 @@ def to_agent_engine(
|
||||
)
|
||||
agent_config['description'] = description
|
||||
|
||||
if not requirements_file:
|
||||
requirements_txt_path = os.path.join(agent_src_path, 'requirements.txt')
|
||||
if requirements_file:
|
||||
if os.path.exists(requirements_txt_path):
|
||||
click.echo(
|
||||
f'Overwriting {requirements_txt_path} with {requirements_file}'
|
||||
)
|
||||
shutil.copyfile(requirements_file, requirements_txt_path)
|
||||
elif 'requirements_file' in agent_config:
|
||||
if os.path.exists(requirements_txt_path):
|
||||
click.echo(
|
||||
f'Overwriting {requirements_txt_path} with'
|
||||
f' {agent_config["requirements_file"]}'
|
||||
)
|
||||
shutil.copyfile(agent_config['requirements_file'], requirements_txt_path)
|
||||
else:
|
||||
# Attempt to read requirements from requirements.txt in the dir (if any).
|
||||
requirements_txt_path = os.path.join(agent_src_path, 'requirements.txt')
|
||||
if not os.path.exists(requirements_txt_path):
|
||||
click.echo(f'Creating {requirements_txt_path}...')
|
||||
with open(requirements_txt_path, 'w', encoding='utf-8') as f:
|
||||
f.write('google-cloud-aiplatform[adk,agent_engines]')
|
||||
click.echo(f'Created {requirements_txt_path}')
|
||||
agent_config['requirements_file'] = agent_config.get(
|
||||
'requirements',
|
||||
requirements_txt_path,
|
||||
)
|
||||
else:
|
||||
if 'requirements_file' in agent_config:
|
||||
click.echo(
|
||||
'Overriding requirements in agent engine config with '
|
||||
f'{requirements_file}'
|
||||
)
|
||||
agent_config['requirements_file'] = requirements_file
|
||||
agent_config['requirements_file'] = f'{temp_folder}/requirements.txt'
|
||||
|
||||
env_vars = {}
|
||||
|
||||
Reference in New Issue
Block a user