@@ -116,9 +116,13 @@ def generate_config_template(
116116 for config in steps_configs .values ():
117117 config .get ("settings" , {}).pop ("docker" , None )
118118
119+ pipeline_config_exclude = {"schedule" , "build" }
120+ if not snapshot .is_dynamic :
121+ pipeline_config_exclude .add ("parameters" )
122+
119123 pipeline_config = pipeline_configuration .model_dump (
120124 include = set (PipelineRunConfiguration .model_fields ),
121- exclude = { "schedule" , "build" , "parameters" } ,
125+ exclude = pipeline_config_exclude ,
122126 exclude_none = True ,
123127 exclude_defaults = True ,
124128 )
@@ -135,12 +139,14 @@ def generate_config_template(
135139
136140def generate_config_schema (
137141 snapshot : PipelineSnapshotSchema ,
142+ pipeline_configuration : "PipelineConfiguration" ,
138143 step_configurations : Dict [str , "Step" ],
139144) -> Dict [str , Any ]:
140145 """Generate a run configuration schema for the snapshot.
141146
142147 Args:
143148 snapshot: The snapshot schema.
149+ pipeline_configuration: The pipeline configuration.
144150 step_configurations: The step configurations.
145151
146152 Returns:
@@ -190,13 +196,17 @@ def generate_config_schema(
190196 generic_step_fields : Dict [str , Any ] = {}
191197
192198 for key , field_info in StepConfigurationUpdate .model_fields .items ():
193- if key in [
199+ step_config_exclude = [
194200 "name" ,
195201 "outputs" ,
196202 "step_operator" ,
197203 "experiment_tracker" ,
198204 "parameters" ,
199- ]:
205+ ]
206+ if not snapshot .is_dynamic :
207+ step_config_exclude .append ("runtime" )
208+
209+ if key in step_config_exclude :
200210 continue
201211
202212 if field_info .annotation == Optional [SourceWithValidator ]: # type: ignore[comparison-overlap]
@@ -294,4 +304,26 @@ def generate_config_schema(
294304 FieldInfo (default = None ),
295305 )
296306
307+ if snapshot .is_dynamic :
308+ pipeline_parameter_fields : Dict [str , Any ] = {}
309+
310+ for parameter_name in pipeline_configuration .parameters or {}:
311+ # Pydantic doesn't allow field names to start with an underscore
312+ sanitized_parameter_name = parameter_name .lstrip ("_" )
313+ while sanitized_parameter_name in parameter_fields :
314+ sanitized_parameter_name = sanitized_parameter_name + "_"
315+
316+ pipeline_parameter_fields [sanitized_parameter_name ] = (
317+ Any ,
318+ FieldInfo (default = ..., validation_alias = parameter_name ),
319+ )
320+
321+ parameters_class = create_model (
322+ "Parameters" , ** pipeline_parameter_fields
323+ )
324+ top_level_fields ["parameters" ] = (
325+ parameters_class ,
326+ FieldInfo (default = None ),
327+ )
328+
297329 return create_model ("Result" , ** top_level_fields ).model_json_schema () # type: ignore[no-any-return]
0 commit comments