22
22
from sagemaker .workflow .pipeline import Pipeline
23
23
from sagemaker .workflow .callback_step import CallbackStep , CallbackOutput , CallbackOutputTypeEnum
24
24
25
- from tests .unit .sagemaker .workflow .helpers import ordered
26
25
27
26
@pytest .fixture
28
27
def sagemaker_session_mock ():
29
28
return Mock ()
30
29
30
+
31
31
def test_callback_step ():
32
32
param = ParameterInteger (name = "MyInt" )
33
33
outputParam1 = CallbackOutput (output_name = "output1" , output_type = CallbackOutputTypeEnum .String )
@@ -52,6 +52,7 @@ def test_callback_step():
52
52
"Arguments" : {"arg1" : "foo" , "arg2" : 5 , "arg3" : param },
53
53
}
54
54
55
+
55
56
def test_callback_step_output_expr ():
56
57
param = ParameterInteger (name = "MyInt" )
57
58
outputParam1 = CallbackOutput (output_name = "output1" , output_type = CallbackOutputTypeEnum .String )
@@ -67,6 +68,7 @@ def test_callback_step_output_expr():
67
68
assert cb_step .properties .Outputs ['output1' ].expr == {"Get" : "Steps.MyCallbackStep.OutputParameters['output1']" }
68
69
assert cb_step .properties .Outputs ['output2' ].expr == {"Get" : "Steps.MyCallbackStep.OutputParameters['output2']" }
69
70
71
+
70
72
def test_pipeline_interpolates_callback_outputs ():
71
73
parameter = ParameterString ("MyStr" )
72
74
outputParam1 = CallbackOutput (output_name = "output1" , output_type = CallbackOutputTypeEnum .String )
@@ -94,48 +96,47 @@ def test_pipeline_interpolates_callback_outputs():
94
96
)
95
97
96
98
assert json .loads (pipeline .definition ()) == {
97
- "Version" : "2020-12-01" ,
98
- "Metadata" : {},
99
- "Parameters" : [{"Name" : "MyStr" , "Type" : "String" }],
100
- "PipelineExperimentConfig" : {
101
- "ExperimentName" : {"Get" : "Execution.PipelineName" },
102
- "TrialName" : {"Get" : "Execution.PipelineExecutionId" },
99
+ "Version" : "2020-12-01" ,
100
+ "Metadata" : {},
101
+ "Parameters" : [{"Name" : "MyStr" , "Type" : "String" }],
102
+ "PipelineExperimentConfig" : {
103
+ "ExperimentName" : {"Get" : "Execution.PipelineName" },
104
+ "TrialName" : {"Get" : "Execution.PipelineExecutionId" },
105
+ },
106
+ "Steps" : [
107
+ {
108
+ "Name" : "MyCallbackStep1" ,
109
+ "Type" : "Callback" ,
110
+ "Arguments" : {
111
+ "arg1" : "foo"
112
+ },
113
+ "DependsOn" : [
114
+ "TestStep"
115
+ ],
116
+ "SqsQueueUrl" : "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue" ,
117
+ "OutputParameters" : [
118
+ {
119
+ "OutputName" : "output1" ,
120
+ "OutputType" : "String"
121
+ }
122
+ ]
103
123
},
104
- "Steps" : [
105
- {
106
- "Name" : "MyCallbackStep1" ,
107
- "Type" : "Callback" ,
108
- "Arguments" : {
109
- "arg1" : "foo"
110
- },
111
- "DependsOn" : [
112
- "TestStep"
113
- ],
114
- "SqsQueueUrl" : "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue" ,
115
- "OutputParameters" : [
116
- {
117
- "OutputName" : "output1" ,
118
- "OutputType" : "String"
119
- }
120
- ]
124
+ {
125
+ "Name" : "MyCallbackStep2" ,
126
+ "Type" : "Callback" ,
127
+ "Arguments" : {
128
+ "arg1" : {"Get" : "Steps.MyCallbackStep1.OutputParameters['output1']" }
121
129
},
122
- {
123
- "Name" : "MyCallbackStep2" ,
124
- "Type" : "Callback" ,
125
- "Arguments" : {
126
- "arg1" : { "Get" : "Steps.MyCallbackStep1.OutputParameters['output1']" }
127
- },
128
- "DependsOn" : [
129
- "TestStep"
130
- ],
131
- "SqsQueueUrl" : "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue" ,
132
- "OutputParameters" : [
133
- {
134
- "OutputName" : "output2" ,
135
- "OutputType" : "String"
136
- }
137
- ]
138
- }
139
- ]
140
- }
141
-
130
+ "DependsOn" : [
131
+ "TestStep"
132
+ ],
133
+ "SqsQueueUrl" : "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue" ,
134
+ "OutputParameters" : [
135
+ {
136
+ "OutputName" : "output2" ,
137
+ "OutputType" : "String"
138
+ }
139
+ ]
140
+ }
141
+ ]
142
+ }
0 commit comments