1
1
"""Utility functions to run a pipeline from the server."""
2
2
3
- import copy
4
3
import hashlib
5
4
import sys
6
5
from typing import Any , Dict , List , Optional
16
15
from zenml .config .pipeline_run_configuration import (
17
16
PipelineRunConfiguration ,
18
17
)
19
- from zenml .config .step_configurations import Step , StepConfiguration
18
+ from zenml .config .step_configurations import Step , StepConfigurationUpdate
20
19
from zenml .constants import (
21
20
ENV_ZENML_ACTIVE_PROJECT_ID ,
22
21
ENV_ZENML_ACTIVE_STACK_ID ,
43
42
validate_stack_is_runnable_from_server ,
44
43
)
45
44
from zenml .stack .flavor import Flavor
46
- from zenml .utils import dict_utils , requirements_utils , settings_utils
45
+ from zenml .utils import pydantic_utils , requirements_utils , settings_utils
47
46
from zenml .zen_server .auth import AuthContext , generate_access_token
48
47
from zenml .zen_server .template_execution .runner_entrypoint_configuration import (
49
48
RunnerEntrypointConfiguration ,
@@ -106,7 +105,6 @@ def run_template(
106
105
deployment_request = deployment_request_from_template (
107
106
template = template ,
108
107
config = run_config or PipelineRunConfiguration (),
109
- user_id = auth_context .user .id ,
110
108
)
111
109
112
110
ensure_async_orchestrator (deployment = deployment_request , stack = stack )
@@ -345,14 +343,12 @@ def generate_dockerfile(
345
343
def deployment_request_from_template (
346
344
template : RunTemplateResponse ,
347
345
config : PipelineRunConfiguration ,
348
- user_id : UUID ,
349
346
) -> "PipelineDeploymentRequest" :
350
347
"""Generate a deployment request from a template.
351
348
352
349
Args:
353
350
template: The template from which to create the deployment request.
354
351
config: The run configuration.
355
- user_id: ID of the user that is trying to run the template.
356
352
357
353
Raises:
358
354
ValueError: If there are missing/extra step parameters in the run
@@ -363,49 +359,34 @@ def deployment_request_from_template(
363
359
"""
364
360
deployment = template .source_deployment
365
361
assert deployment
366
- pipeline_configuration = PipelineConfiguration (
367
- ** config .model_dump (
368
- include = set (PipelineConfiguration .model_fields ),
369
- exclude = {"name" , "parameters" },
370
- ),
371
- name = deployment .pipeline_configuration .name ,
372
- parameters = deployment .pipeline_configuration .parameters ,
373
- )
374
362
375
- step_config_dict_base = pipeline_configuration .model_dump (
376
- exclude = {"name" , "parameters" , "tags" , "enable_pipeline_logs" }
363
+ pipeline_update = config .model_dump (
364
+ include = set (PipelineConfiguration .model_fields ),
365
+ exclude = {"name" , "parameters" },
366
+ # TODO: Make sure all unset values are actually passed as unset
367
+ exclude_unset = True ,
368
+ )
369
+ pipeline_configuration = pydantic_utils .update_model (
370
+ deployment .pipeline_configuration , pipeline_update
377
371
)
378
- steps = {}
379
- for invocation_id , step in deployment .step_configurations .items ():
380
- step_config_dict = {
381
- ** copy .deepcopy (step_config_dict_base ),
382
- ** step .config .model_dump (
383
- # TODO: Maybe we need to make some of these configurable via
384
- # yaml as well, e.g. the lazy loaders?
385
- include = {
386
- "name" ,
387
- "caching_parameters" ,
388
- "external_input_artifacts" ,
389
- "model_artifacts_or_metadata" ,
390
- "client_lazy_loaders" ,
391
- "substitutions" ,
392
- "outputs" ,
393
- }
394
- ),
395
- }
396
-
397
- required_parameters = set (step .config .parameters )
398
- configured_parameters = set ()
399
372
400
- if update := config .steps .get (invocation_id ):
401
- update_dict = update .model_dump ()
373
+ steps = {}
374
+ for invocation_id , step in deployment .raw_step_configurations .items ():
375
+ step_update = config .steps .get (
376
+ invocation_id , StepConfigurationUpdate ()
377
+ ).model_dump (
402
378
# Get rid of deprecated name to prevent overriding the step name
403
379
# with `None`.
404
- update_dict .pop ("name" , None )
405
- configured_parameters = set (update .parameters )
406
- step_config_dict = dict_utils .recursive_update (
407
- step_config_dict , update = update_dict
408
- )
380
+ exclude = {"name" },
381
+ exclude_unset = True ,
382
+ )
383
+ step_config = pydantic_utils .update_model (step .config , step_update )
384
+ # step_config = step_config.apply_pipeline_configuration(
385
+ # pipeline_configuration
386
+ # )
387
+
388
+ required_parameters = set (step .config .parameters )
389
+ configured_parameters = set (step_config .parameters )
409
390
410
391
unknown_parameters = configured_parameters - required_parameters
411
392
if unknown_parameters :
@@ -421,7 +402,6 @@ def deployment_request_from_template(
421
402
f"parameters for step { invocation_id } : { missing_parameters } ."
422
403
)
423
404
424
- step_config = StepConfiguration .model_validate (step_config_dict )
425
405
steps [invocation_id ] = Step (spec = step .spec , config = step_config )
426
406
427
407
code_reference_request = None
@@ -440,7 +420,8 @@ def deployment_request_from_template(
440
420
run_name_template = config .run_name
441
421
or get_default_run_name (pipeline_name = pipeline_configuration .name ),
442
422
pipeline_configuration = pipeline_configuration ,
443
- step_configurations = steps ,
423
+ # step_configurations=steps,
424
+ raw_step_configurations = steps ,
444
425
client_environment = {},
445
426
client_version = zenml_version ,
446
427
server_version = zenml_version ,
0 commit comments