Skip to content

Commit 9e8a66a

Browse files
yeesiancopybara-github
authored andcommitted
feat: Respect the .ae_ignore file when deploying to agent engine
PiperOrigin-RevId: 786823416
1 parent f1889ae commit 9e8a66a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/google/adk/cli/cli_deploy.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,15 @@ def to_agent_engine(
315315
shutil.rmtree(agent_src_path)
316316

317317
try:
318+
ignore_patterns = None
319+
ae_ignore_path = os.path.join(agent_folder, '.ae_ignore')
320+
if os.path.exists(ae_ignore_path):
321+
click.echo(f'Ignoring files matching the patterns in {ae_ignore_path}')
322+
with open(ae_ignore_path, 'r') as f:
323+
patterns = [pattern.strip() for pattern in f.readlines()]
324+
ignore_patterns = shutil.ignore_patterns(*patterns)
318325
click.echo('Copying agent source code...')
319-
shutil.copytree(agent_folder, agent_src_path)
326+
shutil.copytree(agent_folder, agent_src_path, ignore=ignore_patterns)
320327
click.echo('Copying agent source code complete.')
321328

322329
click.echo('Initializing Vertex AI...')
@@ -341,7 +348,7 @@ def to_agent_engine(
341348
env_vars = None
342349
if not env_file:
343350
# Attempt to read the env variables from .env in the dir (if any).
344-
env_file = os.path.join(agent_src_path, '.env')
351+
env_file = os.path.join(agent_folder, '.env')
345352
if os.path.exists(env_file):
346353
from dotenv import dotenv_values
347354

0 commit comments

Comments
 (0)