Fix: hardcode handler_name = "lambda_function.lambda_handler" to match the zip entry name.#5692
Fix: hardcode handler_name = "lambda_function.lambda_handler" to match the zip entry name.#5692mollyheamazon wants to merge 3 commits intoaws:masterfrom
Conversation
mufaddal-rohawala
left a comment
There was a problem hiding this comment.
🤖 AI Code Review
This PR fixes a bug where the Lambda handler name was dynamically derived from the source file name, but the zip entry always uses 'lambda_function.py' as the module name. The fix is straightforward and the test update correctly validates the new behavior. However, there are two notable concerns: a direct boto3 call (pre-existing) and a missing explanation of why the handler name must be hardcoded.
| lambda_client = boto3.client("lambda") | ||
| function_name = f"SageMaker-evaluator-{name}-{datetime.now().strftime('%Y%m%d_%H%M%S')}" | ||
| handler_name = f"{os.path.splitext(os.path.basename(source_file))[0]}.lambda_handler" | ||
| handler_name = "lambda_function.lambda_handler" |
There was a problem hiding this comment.
The fix itself makes sense if the zip archive always packages the source file as lambda_function.py regardless of the original filename. However, this introduces a subtle coupling — the hardcoded string "lambda_function.lambda_handler" must match whatever entry name is used when building the zip. Consider extracting this as a module-level constant (e.g., LAMBDA_HANDLER_NAME = "lambda_function.lambda_handler") and adding a comment explaining why it's hardcoded (i.e., the zip archive always renames the source to lambda_function.py). This will prevent future contributors from "fixing" it back to the dynamic version.
Also, as a pre-existing issue: this method calls boto3.client("lambda") directly (line 383). Per V3 architecture tenets, all AWS API interactions should go through sagemaker-core rather than calling boto3 directly. This is out of scope for this PR, but worth tracking.
|
mlops integ test failures is flaky test |
Issue #, if available:
Ticket: https://tiny.amazon.com/12ooeo0ys/tcorpamazP405over
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.