Skip to content

Commit c2300ce

Browse files
committed
adding a lambda_launcher script
1 parent 71af7a3 commit c2300ce

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ workbench_config = "workbench.scripts.show_config:main"
9292
glue_launcher = "workbench.scripts.glue_launcher:main"
9393
ml_pipeline_batch = "workbench.scripts.ml_pipeline_batch:main"
9494
ml_pipeline_sqs = "workbench.scripts.ml_pipeline_sqs:main"
95+
lambda_launcher = "workbench.scripts.lambda_launcher:main"
9596

9697
[tool.pytest.ini_options]
9798
addopts = "-v --cov-report term-missing"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import sys
2+
import os
3+
import importlib.util
4+
5+
6+
def main():
7+
if len(sys.argv) != 2:
8+
print("Usage: lambda_launcher <handler_module_name>")
9+
sys.exit(1)
10+
11+
handler_file = sys.argv[1]
12+
13+
# Add .py if not present
14+
if not handler_file.endswith(".py"):
15+
handler_file += ".py"
16+
17+
# Check if file exists
18+
if not os.path.exists(handler_file):
19+
print(f"Error: File '{handler_file}' not found")
20+
sys.exit(1)
21+
22+
# Load the module dynamically
23+
spec = importlib.util.spec_from_file_location("lambda_module", handler_file)
24+
lambda_module = importlib.util.module_from_spec(spec)
25+
spec.loader.exec_module(lambda_module)
26+
27+
# Call the lambda_handler
28+
print(f"Invoking lambda_handler from {handler_file}...")
29+
print("-" * 50)
30+
31+
result = lambda_module.lambda_handler({}, {})
32+
33+
print("-" * 50)
34+
print("Result:")
35+
print(result)
36+
37+
38+
if __name__ == "__main__":
39+
main()

0 commit comments

Comments
 (0)