54
54
from sagemaker .workflow .lambda_step import LambdaStep , LambdaOutput , LambdaOutputTypeEnum
55
55
from tests .unit import DATA_DIR
56
56
from tests .unit .sagemaker .workflow .helpers import CustomStep , ordered
57
- from tests .unit .sagemaker .workflow .conftest import BUCKET , ROLE
58
-
59
- _IMAGE_URI = "fakeimage"
60
- _INSTANCE_TYPE = "ml.m4.xlarge"
57
+ from tests .unit .sagemaker .workflow .conftest import BUCKET , ROLE , IMAGE_URI , INSTANCE_TYPE
61
58
62
59
_SAGEMAKER_PROGRAM = SCRIPT_PARAM_NAME .upper ()
63
60
_SAGEMAKER_SUBMIT_DIRECTORY = DIR_PARAM_NAME .upper ()
@@ -79,7 +76,7 @@ def model_data_param():
79
76
def model (pipeline_session , model_data_param ):
80
77
return Model (
81
78
name = "MyModel" ,
82
- image_uri = _IMAGE_URI ,
79
+ image_uri = IMAGE_URI ,
83
80
model_data = model_data_param ,
84
81
sagemaker_session = pipeline_session ,
85
82
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
@@ -159,7 +156,7 @@ def test_register_model_with_runtime_repack(pipeline_session, model_data_param,
159
156
assert arguments ["ModelApprovalStatus" ] == "PendingManualApproval"
160
157
assert len (arguments ["InferenceSpecification" ]["Containers" ]) == 1
161
158
container = arguments ["InferenceSpecification" ]["Containers" ][0 ]
162
- assert container ["Image" ] == _IMAGE_URI
159
+ assert container ["Image" ] == IMAGE_URI
163
160
assert container ["ModelDataUrl" ] == {
164
161
"Get" : f"Steps.{ expected_repack_step_name } .ModelArtifacts.S3ModelArtifacts"
165
162
}
@@ -238,7 +235,7 @@ def test_create_model_with_runtime_repack(pipeline_session, model_data_param, mo
238
235
assert step ["Name" ] == f"MyModelStep-{ _CREATE_MODEL_NAME_BASE } "
239
236
arguments = step ["Arguments" ]
240
237
container = arguments ["PrimaryContainer" ]
241
- assert container ["Image" ] == _IMAGE_URI
238
+ assert container ["Image" ] == IMAGE_URI
242
239
assert container ["ModelDataUrl" ] == {
243
240
"Get" : f"Steps.{ expected_repack_step_name } .ModelArtifacts.S3ModelArtifacts"
244
241
}
@@ -335,7 +332,7 @@ def test_create_pipeline_model_with_runtime_repack(pipeline_session, model_data_
335
332
assert containers [0 ]["ModelDataUrl" ] == {"Get" : "Parameters.ModelData" }
336
333
assert containers [1 ]["Environment" ][_SAGEMAKER_PROGRAM ] == _SCRIPT_NAME
337
334
assert containers [1 ]["Environment" ][_SAGEMAKER_SUBMIT_DIRECTORY ] == _DIR_NAME
338
- assert containers [1 ]["Image" ] == _IMAGE_URI
335
+ assert containers [1 ]["Image" ] == IMAGE_URI
339
336
assert containers [1 ]["ModelDataUrl" ] == {
340
337
"Get" : f"Steps.{ expected_repack_step_name } .ModelArtifacts.S3ModelArtifacts"
341
338
}
@@ -371,7 +368,7 @@ def test_register_pipeline_model_with_runtime_repack(pipeline_session, model_dat
371
368
)
372
369
# The model need to runtime repack
373
370
model = Model (
374
- image_uri = _IMAGE_URI ,
371
+ image_uri = IMAGE_URI ,
375
372
model_data = model_data_param ,
376
373
sagemaker_session = pipeline_session ,
377
374
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
@@ -431,7 +428,7 @@ def test_register_pipeline_model_with_runtime_repack(pipeline_session, model_dat
431
428
assert containers [0 ]["ModelDataUrl" ] == {"Get" : "Parameters.ModelData" }
432
429
assert containers [0 ]["Environment" ][_SAGEMAKER_PROGRAM ] == _SCRIPT_NAME
433
430
assert "s3://" in containers [0 ]["Environment" ][_SAGEMAKER_SUBMIT_DIRECTORY ]
434
- assert containers [1 ]["Image" ] == _IMAGE_URI
431
+ assert containers [1 ]["Image" ] == IMAGE_URI
435
432
assert containers [1 ]["ModelDataUrl" ] == {
436
433
"Get" : f"Steps.{ expected_repack_step_name } .ModelArtifacts.S3ModelArtifacts"
437
434
}
@@ -459,7 +456,7 @@ def test_register_model_without_repack(pipeline_session):
459
456
model_name = "MyModel"
460
457
model = Model (
461
458
name = model_name ,
462
- image_uri = _IMAGE_URI ,
459
+ image_uri = IMAGE_URI ,
463
460
model_data = model_data ,
464
461
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
465
462
sagemaker_session = pipeline_session ,
@@ -489,7 +486,7 @@ def test_register_model_without_repack(pipeline_session):
489
486
assert arguments ["ModelApprovalStatus" ] == "PendingManualApproval"
490
487
containers = arguments ["InferenceSpecification" ]["Containers" ]
491
488
assert len (containers ) == 1
492
- assert containers [0 ]["Image" ] == _IMAGE_URI
489
+ assert containers [0 ]["Image" ] == IMAGE_URI
493
490
assert containers [0 ]["ModelDataUrl" ] == {"Get" : "Parameters.ModelData" }
494
491
assert containers [0 ]["Environment" ][_SAGEMAKER_PROGRAM ] == _SCRIPT_NAME
495
492
assert (
@@ -506,7 +503,7 @@ def test_create_model_with_compile_time_repack(mock_repack, pipeline_session):
506
503
model_name = "MyModel"
507
504
model = Model (
508
505
name = model_name ,
509
- image_uri = _IMAGE_URI ,
506
+ image_uri = IMAGE_URI ,
510
507
model_data = f"s3://{ BUCKET } /model.tar.gz" ,
511
508
sagemaker_session = pipeline_session ,
512
509
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
@@ -527,7 +524,7 @@ def test_create_model_with_compile_time_repack(mock_repack, pipeline_session):
527
524
assert len (step_dsl_list ) == 2
528
525
assert step_dsl_list [0 ]["Name" ] == "MyModelStep-CreateModel"
529
526
arguments = step_dsl_list [0 ]["Arguments" ]
530
- assert arguments ["PrimaryContainer" ]["Image" ] == _IMAGE_URI
527
+ assert arguments ["PrimaryContainer" ]["Image" ] == IMAGE_URI
531
528
assert (
532
529
arguments ["PrimaryContainer" ]["ModelDataUrl" ] == f"s3://{ BUCKET } /{ model_name } /model.tar.gz"
533
530
)
@@ -609,7 +606,7 @@ def test_conditional_model_create_and_regis(
609
606
assert arguments ["ModelApprovalStatus" ] == "PendingManualApproval"
610
607
assert len (arguments ["InferenceSpecification" ]["Containers" ]) == 1
611
608
container = arguments ["InferenceSpecification" ]["Containers" ][0 ]
612
- assert container ["Image" ] == _IMAGE_URI
609
+ assert container ["Image" ] == IMAGE_URI
613
610
assert container ["ModelDataUrl" ] == {
614
611
"Get" : f"Steps.{ expected_repack_step_name } .ModelArtifacts.S3ModelArtifacts"
615
612
}
@@ -619,7 +616,7 @@ def test_conditional_model_create_and_regis(
619
616
assert step ["Name" ] == f"MyModelStepCreate-{ _CREATE_MODEL_NAME_BASE } "
620
617
arguments = step ["Arguments" ]
621
618
container = arguments ["PrimaryContainer" ]
622
- assert container ["Image" ] == _IMAGE_URI
619
+ assert container ["Image" ] == IMAGE_URI
623
620
assert container ["ModelDataUrl" ] == {"Get" : "Parameters.ModelData" }
624
621
assert not container .get ("Environment" , {})
625
622
else :
@@ -645,7 +642,7 @@ def test_conditional_model_create_and_regis(
645
642
SKLearnModel (
646
643
name = "MySKModel" ,
647
644
model_data = "dummy_model_data" ,
648
- image_uri = _IMAGE_URI ,
645
+ image_uri = IMAGE_URI ,
649
646
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
650
647
role = ROLE ,
651
648
enable_network_isolation = True ,
@@ -658,7 +655,7 @@ def test_conditional_model_create_and_regis(
658
655
name = "MYXGBoostModel" ,
659
656
model_data = "dummy_model_data" ,
660
657
framework_version = "1.11.0" ,
661
- image_uri = _IMAGE_URI ,
658
+ image_uri = IMAGE_URI ,
662
659
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
663
660
role = ROLE ,
664
661
enable_network_isolation = False ,
@@ -669,7 +666,7 @@ def test_conditional_model_create_and_regis(
669
666
PyTorchModel (
670
667
name = "MyPyTorchModel" ,
671
668
model_data = "dummy_model_data" ,
672
- image_uri = _IMAGE_URI ,
669
+ image_uri = IMAGE_URI ,
673
670
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
674
671
role = ROLE ,
675
672
framework_version = "1.5.0" ,
@@ -681,7 +678,7 @@ def test_conditional_model_create_and_regis(
681
678
MXNetModel (
682
679
name = "MyMXNetModel" ,
683
680
model_data = "dummy_model_data" ,
684
- image_uri = _IMAGE_URI ,
681
+ image_uri = IMAGE_URI ,
685
682
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
686
683
role = ROLE ,
687
684
framework_version = "1.2.0" ,
@@ -692,7 +689,7 @@ def test_conditional_model_create_and_regis(
692
689
HuggingFaceModel (
693
690
name = "MyHuggingFaceModel" ,
694
691
model_data = "dummy_model_data" ,
695
- image_uri = _IMAGE_URI ,
692
+ image_uri = IMAGE_URI ,
696
693
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
697
694
role = ROLE ,
698
695
),
@@ -702,7 +699,7 @@ def test_conditional_model_create_and_regis(
702
699
TensorFlowModel (
703
700
name = "MyTensorFlowModel" ,
704
701
model_data = "dummy_model_data" ,
705
- image_uri = _IMAGE_URI ,
702
+ image_uri = IMAGE_URI ,
706
703
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
707
704
role = ROLE ,
708
705
code_location = _MODEL_CODE_LOCATION_TRAILING_SLASH ,
@@ -713,7 +710,7 @@ def test_conditional_model_create_and_regis(
713
710
ChainerModel (
714
711
name = "MyChainerModel" ,
715
712
model_data = "dummy_model_data" ,
716
- image_uri = _IMAGE_URI ,
713
+ image_uri = IMAGE_URI ,
717
714
entry_point = f"{ DATA_DIR } /{ _SCRIPT_NAME } " ,
718
715
role = ROLE ,
719
716
),
@@ -824,7 +821,7 @@ def assert_test_result(steps: list):
824
821
TensorFlowModel (
825
822
model_data = "dummy_model_step" ,
826
823
role = ROLE ,
827
- image_uri = _IMAGE_URI ,
824
+ image_uri = IMAGE_URI ,
828
825
entry_point = os .path .join (_TENSORFLOW_PATH , "inference.py" ),
829
826
),
830
827
{
@@ -840,7 +837,7 @@ def assert_test_result(steps: list):
840
837
TensorFlowModel (
841
838
model_data = "dummy_model_step" ,
842
839
role = ROLE ,
843
- image_uri = _IMAGE_URI ,
840
+ image_uri = IMAGE_URI ,
844
841
),
845
842
{
846
843
"expected_step_num" : 1 ,
@@ -975,10 +972,10 @@ def test_model_step_with_lambda_property_reference(pipeline_session):
975
972
[
976
973
(
977
974
Processor (
978
- image_uri = _IMAGE_URI ,
975
+ image_uri = IMAGE_URI ,
979
976
role = ROLE ,
980
977
instance_count = 1 ,
981
- instance_type = _INSTANCE_TYPE ,
978
+ instance_type = INSTANCE_TYPE ,
982
979
),
983
980
dict (target_fun = "run" , func_args = {}),
984
981
),
@@ -999,8 +996,8 @@ def test_model_step_with_lambda_property_reference(pipeline_session):
999
996
estimator = Estimator (
1000
997
role = ROLE ,
1001
998
instance_count = 1 ,
1002
- instance_type = _INSTANCE_TYPE ,
1003
- image_uri = _IMAGE_URI ,
999
+ instance_type = INSTANCE_TYPE ,
1000
+ image_uri = IMAGE_URI ,
1004
1001
),
1005
1002
objective_metric_name = "test:acc" ,
1006
1003
hyperparameter_ranges = {"batch-size" : IntegerParameter (64 , 128 )},
@@ -1011,8 +1008,8 @@ def test_model_step_with_lambda_property_reference(pipeline_session):
1011
1008
Estimator (
1012
1009
role = ROLE ,
1013
1010
instance_count = 1 ,
1014
- instance_type = _INSTANCE_TYPE ,
1015
- image_uri = _IMAGE_URI ,
1011
+ instance_type = INSTANCE_TYPE ,
1012
+ image_uri = IMAGE_URI ,
1016
1013
),
1017
1014
dict (target_fun = "fit" , func_args = {}),
1018
1015
),
0 commit comments