Skip to content

Commit ceadb04

Browse files
Merge branch 'master' into master
2 parents 1100651 + 255a339 commit ceadb04

15 files changed

+69
-108
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v2.91.1 (2022-05-19)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* Revert Prevent passing PipelineVariable object into image_uris.retrieve
8+
39
## v2.91.0 (2022-05-19)
410

511
### Features

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.91.1.dev0
1+
2.91.2.dev0

src/sagemaker/image_uris.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from sagemaker.jumpstart.utils import is_jumpstart_model_input
2424
from sagemaker.spark import defaults
2525
from sagemaker.jumpstart import artifacts
26-
from sagemaker.workflow import is_pipeline_variable
2726

2827
logger = logging.getLogger(__name__)
2928

@@ -105,17 +104,11 @@ def retrieve(
105104
106105
Raises:
107106
NotImplementedError: If the scope is not supported.
108-
ValueError: If the combination of arguments specified is not supported or
109-
any PipelineVariable object is passed in.
107+
ValueError: If the combination of arguments specified is not supported.
110108
VulnerableJumpStartModelError: If any of the dependencies required by the script have
111109
known security vulnerabilities.
112110
DeprecatedJumpStartModelError: If the version of the model is deprecated.
113111
"""
114-
args = dict(locals())
115-
for name, val in args.items():
116-
if is_pipeline_variable(val):
117-
raise ValueError("%s should not be a pipeline variable (%s)" % (name, type(val)))
118-
119112
if is_jumpstart_model_input(model_id, model_version):
120113
return artifacts._retrieve_image_uri(
121114
model_id,

src/sagemaker/workflow/entities.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ def __add__(self, other: Union[Expression, PrimitiveType]):
7878

7979
def __str__(self):
8080
"""Override built-in String function for PipelineVariable"""
81-
raise TypeError(
82-
"Pipeline variables do not support __str__ operation. "
83-
"Please use `.to_string()` to convert it to string type in execution time"
84-
"or use `.expr` to translate it to Json for display purpose in Python SDK."
85-
)
81+
raise TypeError("Pipeline variables do not support __str__ operation.")
8682

8783
def __int__(self):
8884
"""Override built-in Integer function for PipelineVariable"""

tests/integ/sagemaker/workflow/test_model_create_and_registration.py

+13-20
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,10 @@ def test_conditional_pytorch_training_model_registration(
9090
inputs = TrainingInput(s3_data=input_path)
9191

9292
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
93-
instance_type = "ml.m5.xlarge"
93+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
9494
good_enough_input = ParameterInteger(name="GoodEnoughInput", default_value=1)
9595
in_condition_input = ParameterString(name="Foo", default_value="Foo")
9696

97-
# If image_uri is not provided, the instance_type should not be a pipeline variable
98-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
9997
pytorch_estimator = PyTorch(
10098
entry_point=entry_point,
10199
role=role,
@@ -155,6 +153,7 @@ def test_conditional_pytorch_training_model_registration(
155153
in_condition_input,
156154
good_enough_input,
157155
instance_count,
156+
instance_type,
158157
],
159158
steps=[step_train, step_cond],
160159
sagemaker_session=sagemaker_session,
@@ -260,10 +259,8 @@ def test_sklearn_xgboost_sip_model_registration(
260259
prefix = "sip"
261260
bucket_name = sagemaker_session.default_bucket()
262261
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
263-
instance_type = "ml.m5.xlarge"
262+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
264263

265-
# The instance_type should not be a pipeline variable
266-
# since it is used to retrieve image_uri in compile time (PySDK)
267264
sklearn_processor = SKLearnProcessor(
268265
role=role,
269266
instance_type=instance_type,
@@ -334,8 +331,6 @@ def test_sklearn_xgboost_sip_model_registration(
334331
source_dir = base_dir
335332
code_location = "s3://{0}/{1}/code".format(bucket_name, prefix)
336333

337-
# If image_uri is not provided, the instance_type should not be a pipeline variable
338-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
339334
estimator = XGBoost(
340335
entry_point=entry_point,
341336
source_dir=source_dir,
@@ -421,6 +416,7 @@ def test_sklearn_xgboost_sip_model_registration(
421416
train_data_path_param,
422417
val_data_path_param,
423418
model_path_param,
419+
instance_type,
424420
instance_count,
425421
output_path_param,
426422
],
@@ -466,7 +462,7 @@ def test_model_registration_with_drift_check_baselines(
466462
pipeline_name,
467463
):
468464
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
469-
instance_type = "ml.m5.xlarge"
465+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
470466

471467
# upload model data to s3
472468
model_local_path = os.path.join(DATA_DIR, "mxnet_mnist/model.tar.gz")
@@ -554,9 +550,6 @@ def test_model_registration_with_drift_check_baselines(
554550
),
555551
)
556552
customer_metadata_properties = {"key1": "value1"}
557-
558-
# If image_uri is not provided, the instance_type should not be a pipeline variable
559-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
560553
estimator = XGBoost(
561554
entry_point="training.py",
562555
source_dir=os.path.join(DATA_DIR, "sip"),
@@ -586,6 +579,7 @@ def test_model_registration_with_drift_check_baselines(
586579
parameters=[
587580
model_uri_param,
588581
metrics_uri_param,
582+
instance_type,
589583
instance_count,
590584
],
591585
steps=[step_register],
@@ -673,11 +667,9 @@ def test_model_registration_with_model_repack(
673667
inputs = TrainingInput(s3_data=input_path)
674668

675669
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
676-
instance_type = "ml.m5.xlarge"
670+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
677671
good_enough_input = ParameterInteger(name="GoodEnoughInput", default_value=1)
678672

679-
# If image_uri is not provided, the instance_type should not be a pipeline variable
680-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
681673
pytorch_estimator = PyTorch(
682674
entry_point=entry_point,
683675
role=role,
@@ -732,7 +724,7 @@ def test_model_registration_with_model_repack(
732724

733725
pipeline = Pipeline(
734726
name=pipeline_name,
735-
parameters=[good_enough_input, instance_count],
727+
parameters=[good_enough_input, instance_count, instance_type],
736728
steps=[step_cond],
737729
sagemaker_session=sagemaker_session,
738730
)
@@ -775,10 +767,8 @@ def test_model_registration_with_tensorflow_model_with_pipeline_model(
775767
inputs = TrainingInput(s3_data=input_path)
776768

777769
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
778-
instance_type = "ml.m5.xlarge"
770+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
779771

780-
# If image_uri is not provided, the instance_type should not be a pipeline variable
781-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
782772
tensorflow_estimator = TensorFlow(
783773
entry_point=entry_point,
784774
role=role,
@@ -819,7 +809,10 @@ def test_model_registration_with_tensorflow_model_with_pipeline_model(
819809

820810
pipeline = Pipeline(
821811
name=pipeline_name,
822-
parameters=[instance_count],
812+
parameters=[
813+
instance_count,
814+
instance_type,
815+
],
823816
steps=[step_train, step_register_model],
824817
sagemaker_session=sagemaker_session,
825818
)

tests/integ/sagemaker/workflow/test_model_steps.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,15 @@ def test_pytorch_training_model_registration_and_creation_without_custom_inferen
8383
inputs = TrainingInput(s3_data=input_path)
8484

8585
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
86+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
8687

87-
# If image_uri is not provided, the instance_type should not be a pipeline variable
88-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
8988
pytorch_estimator = PyTorch(
9089
entry_point=entry_point,
9190
role=role,
9291
framework_version="1.5.0",
9392
py_version="py3",
9493
instance_count=instance_count,
95-
instance_type="ml.m5.xlarge",
94+
instance_type=instance_type,
9695
sagemaker_session=pipeline_session,
9796
)
9897
train_step_args = pytorch_estimator.fit(inputs=inputs)
@@ -141,7 +140,7 @@ def test_pytorch_training_model_registration_and_creation_without_custom_inferen
141140
)
142141
pipeline = Pipeline(
143142
name=pipeline_name,
144-
parameters=[instance_count],
143+
parameters=[instance_count, instance_type],
145144
steps=[step_train, step_model_regis, step_model_create, step_fail],
146145
sagemaker_session=pipeline_session,
147146
)
@@ -204,16 +203,15 @@ def test_pytorch_training_model_registration_and_creation_with_custom_inference(
204203
inputs = TrainingInput(s3_data=input_path)
205204

206205
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
206+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
207207

208-
# If image_uri is not provided, the instance_type should not be a pipeline variable
209-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
210208
pytorch_estimator = PyTorch(
211209
entry_point=entry_point,
212210
role=role,
213211
framework_version="1.5.0",
214212
py_version="py3",
215213
instance_count=instance_count,
216-
instance_type="ml.m5.xlarge",
214+
instance_type=instance_type,
217215
sagemaker_session=pipeline_session,
218216
output_kms_key=kms_key,
219217
)
@@ -269,7 +267,7 @@ def test_pytorch_training_model_registration_and_creation_with_custom_inference(
269267
)
270268
pipeline = Pipeline(
271269
name=pipeline_name,
272-
parameters=[instance_count],
270+
parameters=[instance_count, instance_type],
273271
steps=[step_train, step_model_regis, step_model_create, step_fail],
274272
sagemaker_session=pipeline_session,
275273
)
@@ -402,6 +400,7 @@ def test_model_registration_with_drift_check_baselines_and_model_metrics(
402400
pipeline_name,
403401
):
404402
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
403+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
405404

406405
# upload model data to s3
407406
model_local_path = os.path.join(DATA_DIR, "mxnet_mnist/model.tar.gz")
@@ -489,12 +488,10 @@ def test_model_registration_with_drift_check_baselines_and_model_metrics(
489488
),
490489
)
491490
customer_metadata_properties = {"key1": "value1"}
492-
# If image_uri is not provided, the instance_type should not be a pipeline variable
493-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
494491
estimator = XGBoost(
495492
entry_point="training.py",
496493
source_dir=os.path.join(DATA_DIR, "sip"),
497-
instance_type="ml.m5.xlarge",
494+
instance_type=instance_type,
498495
instance_count=instance_count,
499496
framework_version="0.90-2",
500497
sagemaker_session=pipeline_session,
@@ -527,6 +524,7 @@ def test_model_registration_with_drift_check_baselines_and_model_metrics(
527524
parameters=[
528525
model_uri_param,
529526
metrics_uri_param,
527+
instance_type,
530528
instance_count,
531529
],
532530
steps=[step_model_register],
@@ -608,14 +606,13 @@ def test_model_registration_with_tensorflow_model_with_pipeline_model(
608606
)
609607
inputs = TrainingInput(s3_data=input_path)
610608
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
609+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
611610

612-
# If image_uri is not provided, the instance_type should not be a pipeline variable
613-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
614611
tensorflow_estimator = TensorFlow(
615612
entry_point=entry_point,
616613
role=role,
617614
instance_count=instance_count,
618-
instance_type="ml.m5.xlarge",
615+
instance_type=instance_type,
619616
framework_version=tf_full_version,
620617
py_version=tf_full_py_version,
621618
sagemaker_session=pipeline_session,
@@ -648,7 +645,10 @@ def test_model_registration_with_tensorflow_model_with_pipeline_model(
648645
)
649646
pipeline = Pipeline(
650647
name=pipeline_name,
651-
parameters=[instance_count],
648+
parameters=[
649+
instance_count,
650+
instance_type,
651+
],
652652
steps=[step_train, step_register_model],
653653
sagemaker_session=pipeline_session,
654654
)

tests/integ/sagemaker/workflow/test_retry.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
_REGISTER_MODEL_NAME_BASE,
3232
_CREATE_MODEL_NAME_BASE,
3333
)
34-
from sagemaker.workflow.parameters import ParameterInteger
34+
from sagemaker.workflow.parameters import (
35+
ParameterInteger,
36+
ParameterString,
37+
)
3538
from sagemaker.pytorch.estimator import PyTorch
3639
from sagemaker.workflow.pipeline import Pipeline
3740
from sagemaker.workflow.retry import (
@@ -182,11 +185,9 @@ def test_model_registration_with_model_repack(
182185
inputs = TrainingInput(s3_data=input_path)
183186

184187
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
185-
instance_type = "ml.m5.xlarge"
188+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
186189
good_enough_input = ParameterInteger(name="GoodEnoughInput", default_value=1)
187190

188-
# If image_uri is not provided, the instance_type should not be a pipeline variable
189-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
190191
pytorch_estimator = PyTorch(
191192
entry_point=entry_point,
192193
role=role,
@@ -251,7 +252,7 @@ def test_model_registration_with_model_repack(
251252
)
252253
pipeline = Pipeline(
253254
name=pipeline_name,
254-
parameters=[good_enough_input, instance_count],
255+
parameters=[good_enough_input, instance_count, instance_type],
255256
steps=[step_train, step_cond],
256257
sagemaker_session=pipeline_session,
257258
)

tests/integ/sagemaker/workflow/test_training_steps.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_training_job_with_debugger_and_profiler(
5959
pytorch_training_latest_py_version,
6060
):
6161
instance_count = ParameterInteger(name="InstanceCount", default_value=1)
62-
instance_type = "ml.m5.xlarge"
62+
instance_type = ParameterString(name="InstanceType", default_value="ml.m5.xlarge")
6363

6464
rules = [
6565
Rule.sagemaker(rule_configs.vanishing_gradient()),
@@ -78,8 +78,6 @@ def test_training_job_with_debugger_and_profiler(
7878
)
7979
inputs = TrainingInput(s3_data=input_path)
8080

81-
# If image_uri is not provided, the instance_type should not be a pipeline variable
82-
# since instance_type is used to retrieve image_uri in compile time (PySDK)
8381
pytorch_estimator = PyTorch(
8482
entry_point=script_path,
8583
role="SageMakerRole",
@@ -100,7 +98,7 @@ def test_training_job_with_debugger_and_profiler(
10098

10199
pipeline = Pipeline(
102100
name=pipeline_name,
103-
parameters=[instance_count],
101+
parameters=[instance_count, instance_type],
104102
steps=[step_train],
105103
sagemaker_session=sagemaker_session,
106104
)

0 commit comments

Comments
 (0)