Skip to content

Commit 28b57fd

Browse files
dipanjankMichael Trinhspoorn
authored
fix: Fix LambdaStep Creation (#3828)
Co-authored-by: Michael Trinh <[email protected]> Co-authored-by: Michael <[email protected]>
1 parent 1caab81 commit 28b57fd

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

src/sagemaker/lambda_helper.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def __init__(
3737
memory_size: int = 128,
3838
runtime: str = "python3.8",
3939
vpc_config: dict = None,
40-
architectures: list = None,
4140
environment: dict = None,
4241
layers: list = None,
4342
):
@@ -71,8 +70,6 @@ def __init__(
7170
memory_size (int): Memory of the Lambda function in megabytes. Default is 128 MB.
7271
runtime (str): Runtime of the Lambda function. Default is set to python3.8.
7372
vpc_config (dict): VPC to deploy the Lambda function to. Default is None.
74-
architectures (list): Which architecture to deploy to. Valid Values are
75-
'x86_64' and 'arm64', default is None.
7673
environment (dict): Environment Variables for the Lambda function. Default is None.
7774
layers (list): List of Lambda layers for the Lambda function. Default is None.
7875
"""
@@ -87,10 +84,9 @@ def __init__(
8784
self.timeout = timeout
8885
self.memory_size = memory_size
8986
self.runtime = runtime
90-
self.vpc_config = vpc_config
91-
self.environment = environment
92-
self.architectures = architectures
93-
self.layers = layers
87+
self.vpc_config = vpc_config or {}
88+
self.environment = environment or {}
89+
self.layers = layers or []
9490

9591
if function_arn is None and function_name is None:
9692
raise ValueError("Either function_arn or function_name must be provided.")
@@ -142,7 +138,6 @@ def create(self):
142138
MemorySize=self.memory_size,
143139
VpcConfig=self.vpc_config,
144140
Environment=self.environment,
145-
Architectures=self.architectures,
146141
Layers=self.layers,
147142
)
148143
return response
@@ -163,7 +158,6 @@ def update(self):
163158
response = lambda_client.update_function_code(
164159
FunctionName=self.function_name or self.function_arn,
165160
ZipFile=_zip_lambda_code(self.script),
166-
Architectures=self.architectures,
167161
)
168162
else:
169163
bucket = self.s3_bucket or self.session.default_bucket()
@@ -186,7 +180,6 @@ def update(self):
186180
zipped_code_dir=self.zipped_code_dir,
187181
s3_bucket=bucket,
188182
),
189-
Architectures=self.architectures,
190183
)
191184
return response
192185
except ClientError as e:

tests/unit/test_lambda_helper.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,9 @@ def test_create_lambda_happycase1(sagemaker_session):
187187
Code=code,
188188
Timeout=120,
189189
MemorySize=128,
190-
Architectures=None,
191-
VpcConfig=None,
192-
Environment=None,
193-
Layers=None,
190+
VpcConfig={},
191+
Environment={},
192+
Layers=[],
194193
)
195194

196195

@@ -216,10 +215,9 @@ def test_create_lambda_happycase2(sagemaker_session):
216215
Code=code,
217216
Timeout=120,
218217
MemorySize=128,
219-
Architectures=None,
220-
VpcConfig=None,
221-
Environment=None,
222-
Layers=None,
218+
VpcConfig={},
219+
Environment={},
220+
Layers=[],
223221
)
224222

225223

@@ -231,7 +229,6 @@ def test_create_lambda_happycase3(sagemaker_session):
231229
script=SCRIPT,
232230
handler=HANDLER,
233231
session=sagemaker_session,
234-
architectures=["x86_64"],
235232
environment={"Name": "my-test-lambda"},
236233
vpc_config={
237234
"SubnetIds": ["test-subnet-1"],
@@ -251,7 +248,6 @@ def test_create_lambda_happycase3(sagemaker_session):
251248
Code=code,
252249
Timeout=120,
253250
MemorySize=128,
254-
Architectures=["x86_64"],
255251
VpcConfig={"SubnetIds": ["test-subnet-1"], "SecurityGroupIds": ["sec-group-1"]},
256252
Environment={"Name": "my-test-lambda"},
257253
Layers=["my-test-layer-1", "my-test-layer-2"],
@@ -314,7 +310,6 @@ def test_update_lambda_happycase1(sagemaker_session):
314310
sagemaker_session.lambda_client.update_function_code.assert_called_with(
315311
FunctionName=FUNCTION_NAME,
316312
ZipFile=ZIPPED_CODE,
317-
Architectures=None,
318313
)
319314

320315

@@ -335,7 +330,6 @@ def test_update_lambda_happycase2(sagemaker_session):
335330
FunctionName=LAMBDA_ARN,
336331
S3Bucket=S3_BUCKET,
337332
S3Key=S3_KEY,
338-
Architectures=None,
339333
)
340334

341335

@@ -347,7 +341,6 @@ def test_update_lambda_happycase3(sagemaker_session):
347341
script=SCRIPT,
348342
handler=HANDLER,
349343
session=sagemaker_session,
350-
architectures=["x86_64"],
351344
environment={"Name": "my-test-lambda"},
352345
vpc_config={
353346
"SubnetIds": ["test-subnet-1"],
@@ -360,7 +353,6 @@ def test_update_lambda_happycase3(sagemaker_session):
360353
sagemaker_session.lambda_client.update_function_code.assert_called_with(
361354
FunctionName=FUNCTION_NAME,
362355
ZipFile=ZIPPED_CODE,
363-
Architectures=["x86_64"],
364356
)
365357

366358

@@ -380,7 +372,6 @@ def test_update_lambda_s3bucket_not_provided(s3_upload, sagemaker_session):
380372
FunctionName=LAMBDA_ARN,
381373
S3Bucket=sagemaker_session.default_bucket(),
382374
S3Key=s3_upload.return_value,
383-
Architectures=None,
384375
)
385376

386377

@@ -425,10 +416,9 @@ def test_upsert_lambda_happycase1(sagemaker_session):
425416
Code=code,
426417
Timeout=120,
427418
MemorySize=128,
428-
Architectures=None,
429-
VpcConfig=None,
430-
Environment=None,
431-
Layers=None,
419+
VpcConfig={},
420+
Environment={},
421+
Layers=[],
432422
)
433423

434424

@@ -455,7 +445,7 @@ def test_upsert_lambda_happycase2(sagemaker_session):
455445
lambda_obj.upsert()
456446

457447
sagemaker_session.lambda_client.update_function_code.assert_called_once_with(
458-
FunctionName=FUNCTION_NAME, ZipFile=ZIPPED_CODE, Architectures=None
448+
FunctionName=FUNCTION_NAME, ZipFile=ZIPPED_CODE
459449
)
460450

461451

0 commit comments

Comments
 (0)