File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ workbench_config = "workbench.scripts.show_config:main"
9292glue_launcher = " workbench.scripts.glue_launcher:main"
9393ml_pipeline_batch = " workbench.scripts.ml_pipeline_batch:main"
9494ml_pipeline_sqs = " workbench.scripts.ml_pipeline_sqs:main"
95+ lambda_launcher = " workbench.scripts.lambda_launcher:main"
9596
9697[tool .pytest .ini_options ]
9798addopts = " -v --cov-report term-missing"
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments