3535from zenml .config .step_configurations import (
3636 InputSpec ,
3737 Step ,
38+ StepConfiguration ,
3839 StepConfigurationUpdate ,
3940 StepSpec ,
4041)
4748if TYPE_CHECKING :
4849 from zenml .pipelines .pipeline_definition import Pipeline
4950 from zenml .stack import Stack , StackComponent
51+ from zenml .steps .base_step import BaseStep
5052 from zenml .steps .step_invocation import StepInvocation
5153
5254from zenml .logger import get_logger
@@ -126,17 +128,29 @@ def compile(
126128 merge = False ,
127129 )
128130
129- steps = {
130- invocation_id : self ._compile_step_invocation (
131- invocation = invocation ,
132- stack = stack ,
133- step_config = (run_configuration .steps or {}).get (invocation_id ),
134- pipeline_configuration = pipeline .configuration ,
135- )
136- for invocation_id , invocation in self ._get_sorted_invocations (
137- pipeline = pipeline
138- )
139- }
131+ if pipeline .is_dynamic :
132+ step_templates = {
133+ step .name : self ._compile_config_template (
134+ step = step , stack = stack
135+ )
136+ for step in pipeline .depends_on
137+ }
138+ steps = {}
139+ else :
140+ step_templates = None
141+ steps = {
142+ invocation_id : self ._compile_step_invocation (
143+ invocation = invocation ,
144+ stack = stack ,
145+ step_config = (run_configuration .steps or {}).get (
146+ invocation_id
147+ ),
148+ pipeline_configuration = pipeline .configuration ,
149+ )
150+ for invocation_id , invocation in self ._get_sorted_invocations (
151+ pipeline = pipeline
152+ )
153+ }
140154
141155 self ._ensure_required_stack_components_exist (stack = stack , steps = steps )
142156
@@ -156,6 +170,7 @@ def compile(
156170 is_dynamic = pipeline .is_dynamic ,
157171 pipeline_configuration = pipeline .configuration ,
158172 step_configurations = steps ,
173+ step_configuration_templates = step_templates ,
159174 client_environment = get_run_environment_dict (),
160175 client_version = client_version ,
161176 server_version = server_version ,
@@ -521,6 +536,48 @@ def _compile_step_invocation(
521536 step_config_overrides = step_configuration_overrides ,
522537 )
523538
539+ def _compile_config_template (
540+ self ,
541+ step : "BaseStep" ,
542+ stack : "Stack" ,
543+ step_config : Optional ["StepConfigurationUpdate" ],
544+ ) -> StepConfiguration :
545+ """Compiles a ZenML step.
546+
547+ Args:
548+ invocation: The step invocation to compile.
549+ stack: The stack on which the pipeline will be run.
550+ step_config: Run configuration for the step.
551+ pipeline_configuration: Configuration for the pipeline.
552+
553+ Returns:
554+ The compiled step.
555+ """
556+ if step_config :
557+ step ._apply_configuration (step_config )
558+
559+ convert_component_shortcut_settings_keys (
560+ step .configuration .settings , stack = stack
561+ )
562+ step_secrets = secret_utils .resolve_and_verify_secrets (
563+ step .configuration .secrets
564+ )
565+ step_settings = self ._filter_and_validate_settings (
566+ settings = step .configuration .settings ,
567+ configuration_level = ConfigurationLevel .STEP ,
568+ stack = stack ,
569+ )
570+ step .configure (
571+ secrets = step_secrets ,
572+ settings = step_settings ,
573+ merge = False ,
574+ )
575+
576+ # TODO: apply pipeline config
577+ return StepConfiguration .model_validate (
578+ step .configuration .model_dump ()
579+ )
580+
524581 def _get_sorted_invocations (
525582 self ,
526583 pipeline : "Pipeline" ,
0 commit comments