|
17 | 17 | from mock import Mock, PropertyMock
|
18 | 18 |
|
19 | 19 | from sagemaker import Model
|
20 |
| -from sagemaker.workflow.parameters import ParameterString |
21 | 20 | from sagemaker.workflow.pipeline_context import PipelineSession
|
| 21 | +from sagemaker.workflow import is_pipeline_variable, is_pipeline_parameter_string |
| 22 | +from sagemaker.workflow.parameters import ( |
| 23 | + ParameterString, |
| 24 | + ParameterInteger, |
| 25 | + ParameterBoolean, |
| 26 | + ParameterFloat, |
| 27 | +) |
| 28 | +from sagemaker.workflow.functions import Join, JsonGet |
| 29 | +from tests.unit.sagemaker.workflow.helpers import CustomStep |
22 | 30 |
|
23 | 31 | from botocore.config import Config
|
24 | 32 |
|
@@ -130,6 +138,46 @@ def test_pipeline_session_context_for_model_step(pipeline_session_mock):
|
130 | 138 | assert len(register_step_args.need_runtime_repack) == 0
|
131 | 139 |
|
132 | 140 |
|
| 141 | +@pytest.mark.parametrize( |
| 142 | + "item", |
| 143 | + [ |
| 144 | + (ParameterString(name="my-str"), True), |
| 145 | + (ParameterBoolean(name="my-bool"), True), |
| 146 | + (ParameterFloat(name="my-float"), True), |
| 147 | + (ParameterInteger(name="my-int"), True), |
| 148 | + (Join(on="/", values=["my", "value"]), True), |
| 149 | + (JsonGet(step_name="my-step", property_file="pf", json_path="path"), True), |
| 150 | + (CustomStep(name="my-step").properties.OutputDataConfig.S3OutputPath, True), |
| 151 | + ("my-str", False), |
| 152 | + (1, False), |
| 153 | + (CustomStep(name="my-ste"), False), |
| 154 | + ], |
| 155 | +) |
| 156 | +def test_is_pipeline_variable(item): |
| 157 | + var, assertion = item |
| 158 | + assert is_pipeline_variable(var) == assertion |
| 159 | + |
| 160 | + |
| 161 | +@pytest.mark.parametrize( |
| 162 | + "item", |
| 163 | + [ |
| 164 | + (ParameterString(name="my-str"), True), |
| 165 | + (ParameterBoolean(name="my-bool"), False), |
| 166 | + (ParameterFloat(name="my-float"), False), |
| 167 | + (ParameterInteger(name="my-int"), False), |
| 168 | + (Join(on="/", values=["my", "value"]), False), |
| 169 | + (JsonGet(step_name="my-step", property_file="pf", json_path="path"), False), |
| 170 | + (CustomStep(name="my-step").properties.OutputDataConfig.S3OutputPath, False), |
| 171 | + ("my-str", False), |
| 172 | + (1, False), |
| 173 | + (CustomStep(name="my-ste"), False), |
| 174 | + ], |
| 175 | +) |
| 176 | +def test_is_pipeline_parameter_string(item): |
| 177 | + var, assertion = item |
| 178 | + assert is_pipeline_parameter_string(var) == assertion |
| 179 | + |
| 180 | + |
133 | 181 | def test_pipeline_session_context_for_model_step_without_instance_types(
|
134 | 182 | pipeline_session_mock,
|
135 | 183 | ):
|
|
0 commit comments