@@ -97,6 +97,33 @@ def test_pipeline_parameter_validation_one_component_all_good() -> None:
97
97
assert is_valid is True
98
98
99
99
100
+ def test_pipeline_invalidate () -> None :
101
+ pipe = Pipeline ()
102
+ pipe .is_validated = True
103
+ pipe .param_mapping = {"a" : {"key" : {"component" : "component" , "param" : "param" }}}
104
+ pipe .missing_inputs = {"a" : ["other_key" ]}
105
+ pipe .invalidate ()
106
+ assert pipe .is_validated is False
107
+ assert len (pipe .param_mapping ) == 0
108
+ assert len (pipe .missing_inputs ) == 0
109
+
110
+
111
+ def test_pipeline_parameter_validation_called_twice () -> None :
112
+ pipe = Pipeline ()
113
+ component_a = ComponentPassThrough ()
114
+ component_b = ComponentPassThrough ()
115
+ pipe .add_component (component_a , "a" )
116
+ pipe .add_component (component_b , "b" )
117
+ pipe .connect ("a" , "b" , {"value" : "a.result" })
118
+ is_valid = pipe .validate_parameter_mapping_for_task (pipe .get_node_by_name ("b" ))
119
+ assert is_valid is True
120
+ with pytest .raises (PipelineDefinitionError ):
121
+ pipe .validate_parameter_mapping_for_task (pipe .get_node_by_name ("b" ))
122
+ pipe .invalidate ()
123
+ is_valid = pipe .validate_parameter_mapping_for_task (pipe .get_node_by_name ("b" ))
124
+ assert is_valid is True
125
+
126
+
100
127
def test_pipeline_parameter_validation_one_component_input_param_missing () -> None :
101
128
pipe = Pipeline ()
102
129
component_a = ComponentPassThrough ()
@@ -105,6 +132,39 @@ def test_pipeline_parameter_validation_one_component_input_param_missing() -> No
105
132
assert pipe .missing_inputs ["a" ] == ["value" ]
106
133
107
134
135
+ def test_pipeline_parameter_validation_param_mapped_twice () -> None :
136
+ pipe = Pipeline ()
137
+ component_a = ComponentPassThrough ()
138
+ component_b = ComponentPassThrough ()
139
+ component_c = ComponentPassThrough ()
140
+ pipe .add_component (component_a , "a" )
141
+ pipe .add_component (component_b , "b" )
142
+ pipe .add_component (component_c , "c" )
143
+ pipe .connect ("a" , "c" , {"value" : "a.result" })
144
+ pipe .connect ("b" , "c" , {"value" : "b.result" })
145
+ with pytest .raises (PipelineDefinitionError ) as excinfo :
146
+ pipe .validate_parameter_mapping_for_task (pipe .get_node_by_name ("c" ))
147
+ assert (
148
+ "Parameter 'value' already mapped to {'component': 'a', 'param': 'result'}"
149
+ in str (excinfo )
150
+ )
151
+
152
+
153
+ def test_pipeline_parameter_validation_unexpected_input () -> None :
154
+ pipe = Pipeline ()
155
+ component_a = ComponentPassThrough ()
156
+ component_b = ComponentPassThrough ()
157
+ pipe .add_component (component_a , "a" )
158
+ pipe .add_component (component_b , "b" )
159
+ pipe .connect ("a" , "b" , {"unexpected_input_name" : "a.result" })
160
+ with pytest .raises (PipelineDefinitionError ) as excinfo :
161
+ pipe .validate_parameter_mapping_for_task (pipe .get_node_by_name ("b" ))
162
+ assert (
163
+ "Parameter 'unexpected_input_name' is not a valid input for component 'b' of type 'ComponentPassThrough'"
164
+ in str (excinfo )
165
+ )
166
+
167
+
108
168
def test_pipeline_parameter_validation_connected_components_input () -> None :
109
169
"""Parameter for component 'b' comes from the pipeline inputs"""
110
170
pipe = Pipeline ()
0 commit comments