Skip to content

Commit 789924e

Browse files
committed
Add ignore dirs
1 parent 3e14bc6 commit 789924e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

investing_algorithm_framework/cli/cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,17 @@ def deploy_azure_function(
172172
help='The path to the project directory containing '
173173
'the Lambda function code.'
174174
)
175+
@click.option(
176+
'--ignore_dirs',
177+
default=None,
178+
help='List of directories to ignore when deploying.'
179+
)
175180
def deploy_aws_lambda(
176181
lambda_function_name,
177182
region,
178183
lambda_handler,
179184
project_dir=None,
185+
ignore_dirs=None
180186
):
181187
"""
182188
Command-line tool for deploying a trading bot to AWS lambda
@@ -191,6 +197,7 @@ def deploy_aws_lambda(
191197
project_dir (str): The path to the project directory containing the
192198
Lambda function code. If not provided, it defaults to
193199
the current directory.
200+
ignore_dirs (list): List of directories to ignore when deploying.
194201
195202
Returns:
196203
None
@@ -199,7 +206,8 @@ def deploy_aws_lambda(
199206
lambda_function_name=lambda_function_name,
200207
region=region,
201208
lambda_handler=lambda_handler,
202-
project_dir=project_dir
209+
project_dir=project_dir,
210+
ignore_dirs=ignore_dirs
203211
)
204212

205213

investing_algorithm_framework/cli/deploy_to_aws_lambda.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ def sanitize_bucket_name(name: str) -> str:
3939
return name # Enforce length limit
4040

4141

42-
def zip_code(source_dir, zip_file):
42+
def zip_code(source_dir, zip_file, ignore_dirs=None):
4343
"""
4444
Recursively zips the contents of source_dir into zip_file,
4545
preserving directory structure — suitable for AWS Lambda deployment.
4646
4747
Args:
4848
source_dir: str, the directory containing the Lambda function code.
4949
zip_file: str, the path where the zip file will be created.
50+
ignore_dirs: list, directories to ignore when zipping the code.
5051
5152
Returns:
5253
None
@@ -56,6 +57,16 @@ def zip_code(source_dir, zip_file):
5657
# Function should recursively zip all files and directories
5758
with zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) as zf:
5859
for root, _, files in os.walk(source_dir):
60+
61+
# Skip ignored directories
62+
if ignore_dirs is not None:
63+
relative_root = os.path.relpath(root, source_dir)
64+
if any(
65+
relative_root.startswith(ignore) for ignore in ignore_dirs
66+
):
67+
click.echo(f"Ignoring directory: {relative_root}")
68+
continue
69+
5970
for file in files:
6071
click.echo(f"Adding {file} to zip")
6172
file_path = os.path.join(root, file)
@@ -347,6 +358,7 @@ def command(
347358
region,
348359
lambda_handler,
349360
project_dir=None,
361+
ignore_dirs=None
350362
):
351363
"""
352364
Command-line tool for deploying a trading bot to AWS Lambda.
@@ -358,6 +370,7 @@ def command(
358370
If None, it defaults to the current directory.
359371
lambda_handler: str, the name of the handler function in the code
360372
(default is "aws_function.lambda_handler").
373+
ignore_dirs: list, directories to ignore when zipping the code.
361374
362375
Returns:
363376
None

0 commit comments

Comments
 (0)