zenml-nightly 0.62.0.dev20240728__py3-none-any.whl → 0.62.0.dev20240730__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zenml/VERSION +1 -1
- zenml/actions/pipeline_run/pipeline_run_action.py +19 -17
- zenml/analytics/enums.py +4 -0
- zenml/cli/__init__.py +28 -15
- zenml/cli/base.py +1 -1
- zenml/cli/pipeline.py +54 -61
- zenml/cli/stack.py +6 -8
- zenml/client.py +232 -99
- zenml/config/compiler.py +14 -22
- zenml/config/pipeline_run_configuration.py +3 -0
- zenml/config/server_config.py +3 -0
- zenml/config/source.py +2 -1
- zenml/constants.py +2 -0
- zenml/enums.py +3 -0
- zenml/integrations/aws/orchestrators/sagemaker_orchestrator.py +13 -4
- zenml/integrations/databricks/flavors/databricks_orchestrator_flavor.py +11 -2
- zenml/integrations/databricks/orchestrators/databricks_orchestrator.py +19 -13
- zenml/models/__init__.py +26 -10
- zenml/models/v2/base/filter.py +32 -0
- zenml/models/v2/core/pipeline.py +73 -89
- zenml/models/v2/core/pipeline_build.py +15 -11
- zenml/models/v2/core/pipeline_deployment.py +56 -0
- zenml/models/v2/core/pipeline_run.py +52 -1
- zenml/models/v2/core/run_template.py +393 -0
- zenml/models/v2/misc/stack_deployment.py +5 -0
- zenml/new/pipelines/build_utils.py +34 -58
- zenml/new/pipelines/pipeline.py +17 -76
- zenml/new/pipelines/run_utils.py +12 -0
- zenml/post_execution/pipeline.py +1 -4
- zenml/service_connectors/service_connector_utils.py +4 -2
- zenml/stack_deployments/aws_stack_deployment.py +6 -5
- zenml/stack_deployments/azure_stack_deployment.py +118 -11
- zenml/stack_deployments/gcp_stack_deployment.py +12 -5
- zenml/stack_deployments/stack_deployment.py +6 -5
- zenml/steps/utils.py +0 -4
- zenml/utils/package_utils.py +39 -0
- zenml/zen_server/rbac/models.py +1 -0
- zenml/zen_server/rbac/utils.py +4 -0
- zenml/zen_server/routers/pipeline_builds_endpoints.py +2 -66
- zenml/zen_server/routers/pipeline_deployments_endpoints.py +2 -53
- zenml/zen_server/routers/pipelines_endpoints.py +1 -74
- zenml/zen_server/routers/run_templates_endpoints.py +212 -0
- zenml/zen_server/routers/workspaces_endpoints.py +79 -0
- zenml/zen_server/{pipeline_deployment → template_execution}/runner_entrypoint_configuration.py +1 -8
- zenml/zen_server/{pipeline_deployment → template_execution}/utils.py +214 -92
- zenml/zen_server/utils.py +2 -2
- zenml/zen_server/zen_server_api.py +2 -1
- zenml/zen_stores/migrations/versions/7d1919bb1ef0_add_run_templates.py +100 -0
- zenml/zen_stores/migrations/versions/b59aa68fdb1f_simplify_pipelines.py +139 -0
- zenml/zen_stores/rest_zen_store.py +107 -36
- zenml/zen_stores/schemas/__init__.py +2 -0
- zenml/zen_stores/schemas/pipeline_build_schemas.py +3 -3
- zenml/zen_stores/schemas/pipeline_deployment_schemas.py +29 -2
- zenml/zen_stores/schemas/pipeline_run_schemas.py +26 -3
- zenml/zen_stores/schemas/pipeline_schemas.py +29 -30
- zenml/zen_stores/schemas/run_template_schemas.py +264 -0
- zenml/zen_stores/schemas/step_run_schemas.py +11 -4
- zenml/zen_stores/sql_zen_store.py +364 -150
- zenml/zen_stores/template_utils.py +261 -0
- zenml/zen_stores/zen_store_interface.py +93 -20
- {zenml_nightly-0.62.0.dev20240728.dist-info → zenml_nightly-0.62.0.dev20240730.dist-info}/METADATA +1 -1
- {zenml_nightly-0.62.0.dev20240728.dist-info → zenml_nightly-0.62.0.dev20240730.dist-info}/RECORD +67 -63
- zenml/models/v2/core/pipeline_namespace.py +0 -113
- zenml/new/pipelines/deserialization_utils.py +0 -292
- /zenml/zen_server/{pipeline_deployment → template_execution}/__init__.py +0 -0
- /zenml/zen_server/{pipeline_deployment → template_execution}/workload_manager_interface.py +0 -0
- {zenml_nightly-0.62.0.dev20240728.dist-info → zenml_nightly-0.62.0.dev20240730.dist-info}/LICENSE +0 -0
- {zenml_nightly-0.62.0.dev20240728.dist-info → zenml_nightly-0.62.0.dev20240730.dist-info}/WHEEL +0 -0
- {zenml_nightly-0.62.0.dev20240728.dist-info → zenml_nightly-0.62.0.dev20240730.dist-info}/entry_points.txt +0 -0
@@ -1,292 +0,0 @@
|
|
1
|
-
# Copyright (c) ZenML GmbH 2023. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at:
|
6
|
-
#
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
12
|
-
# or implied. See the License for the specific language governing
|
13
|
-
# permissions and limitations under the License.
|
14
|
-
"""Pipeline deserialization utilities."""
|
15
|
-
|
16
|
-
import inspect
|
17
|
-
from typing import TYPE_CHECKING, Callable, Dict, Set, Type
|
18
|
-
|
19
|
-
from packaging import version
|
20
|
-
|
21
|
-
from zenml.logger import get_logger
|
22
|
-
from zenml.new.pipelines.pipeline import Pipeline
|
23
|
-
from zenml.steps.base_step import BaseStep
|
24
|
-
from zenml.steps.entrypoint_function_utils import StepArtifact
|
25
|
-
from zenml.utils import source_utils
|
26
|
-
|
27
|
-
if TYPE_CHECKING:
|
28
|
-
from zenml.config.pipeline_spec import PipelineSpec
|
29
|
-
from zenml.models import PipelineResponse
|
30
|
-
|
31
|
-
logger = get_logger(__name__)
|
32
|
-
|
33
|
-
|
34
|
-
def load_pipeline(model: "PipelineResponse") -> "Pipeline":
|
35
|
-
"""Load a pipeline from a model.
|
36
|
-
|
37
|
-
Args:
|
38
|
-
model: The pipeline model to load.
|
39
|
-
|
40
|
-
Raises:
|
41
|
-
ValueError: If the pipeline can't be loaded due to an old model spec
|
42
|
-
(version <0.2).
|
43
|
-
|
44
|
-
Returns:
|
45
|
-
The loaded pipeline.
|
46
|
-
"""
|
47
|
-
model_version = version.parse(model.spec.version)
|
48
|
-
if model_version < version.parse("0.2"):
|
49
|
-
raise ValueError(
|
50
|
-
"Loading a pipeline is only possible for pipeline specs with "
|
51
|
-
"version 0.2 or higher."
|
52
|
-
)
|
53
|
-
elif model_version == version.parse("0.2"):
|
54
|
-
pipeline_instance = load_pipeline_v_0_2(model=model)
|
55
|
-
elif model_version == version.parse("0.3"):
|
56
|
-
pipeline_instance = load_pipeline_v_0_3(model=model)
|
57
|
-
else:
|
58
|
-
pipeline_instance = load_pipeline_v_0_4(model=model)
|
59
|
-
|
60
|
-
version_hash = pipeline_instance._compute_unique_identifier(
|
61
|
-
pipeline_spec=model.spec
|
62
|
-
)
|
63
|
-
if version_hash != model.version_hash:
|
64
|
-
logger.warning(
|
65
|
-
"Trying to load pipeline version `%s`, but the local step code "
|
66
|
-
"changed since this pipeline version was registered. Using "
|
67
|
-
"this pipeline instance will result in a different pipeline "
|
68
|
-
"version being registered or reused.",
|
69
|
-
model.version,
|
70
|
-
)
|
71
|
-
return pipeline_instance
|
72
|
-
|
73
|
-
|
74
|
-
def load_pipeline_v_0_4(model: "PipelineResponse") -> "Pipeline":
|
75
|
-
"""Load a pipeline from a model with spec version 0.4.
|
76
|
-
|
77
|
-
Args:
|
78
|
-
model: The pipeline model to load.
|
79
|
-
|
80
|
-
Raises:
|
81
|
-
TypeError: If the pipeline source does not refer to a pipeline instance.
|
82
|
-
|
83
|
-
Returns:
|
84
|
-
The loaded pipeline.
|
85
|
-
"""
|
86
|
-
pipeline_source = model.spec.source
|
87
|
-
assert pipeline_source
|
88
|
-
|
89
|
-
pipeline = source_utils.load(pipeline_source)
|
90
|
-
|
91
|
-
if not isinstance(pipeline, Pipeline):
|
92
|
-
raise TypeError("Not a pipeline")
|
93
|
-
|
94
|
-
pipeline.prepare(**model.spec.parameters)
|
95
|
-
return pipeline
|
96
|
-
|
97
|
-
|
98
|
-
def load_pipeline_v_0_3(model: "PipelineResponse") -> "Pipeline":
|
99
|
-
"""Load a pipeline from a model with spec version 0.3.
|
100
|
-
|
101
|
-
Args:
|
102
|
-
model: The pipeline model to load.
|
103
|
-
|
104
|
-
Returns:
|
105
|
-
The loaded pipeline.
|
106
|
-
"""
|
107
|
-
return _load_legacy_pipeline(model=model, use_pipeline_parameter_name=True)
|
108
|
-
|
109
|
-
|
110
|
-
def load_pipeline_v_0_2(model: "PipelineResponse") -> "Pipeline":
|
111
|
-
"""Load a pipeline from a model with spec version 0.2.
|
112
|
-
|
113
|
-
Args:
|
114
|
-
model: The pipeline model to load.
|
115
|
-
|
116
|
-
Returns:
|
117
|
-
The loaded pipeline.
|
118
|
-
"""
|
119
|
-
return _load_legacy_pipeline(
|
120
|
-
model=model, use_pipeline_parameter_name=False
|
121
|
-
)
|
122
|
-
|
123
|
-
|
124
|
-
def _load_legacy_pipeline(
|
125
|
-
model: "PipelineResponse", use_pipeline_parameter_name: bool
|
126
|
-
) -> "Pipeline":
|
127
|
-
"""Load a legacy pipeline.
|
128
|
-
|
129
|
-
Args:
|
130
|
-
model: The pipeline model to load.
|
131
|
-
use_pipeline_parameter_name: Whether to use the pipeline parameter name
|
132
|
-
when referring to upstream steps. If `False` the step name will be
|
133
|
-
used instead.
|
134
|
-
|
135
|
-
Returns:
|
136
|
-
The loaded pipeline.
|
137
|
-
"""
|
138
|
-
from zenml.pipelines.base_pipeline import BasePipeline
|
139
|
-
|
140
|
-
steps = _load_and_verify_steps(
|
141
|
-
pipeline_spec=model.spec,
|
142
|
-
use_pipeline_parameter_name=use_pipeline_parameter_name,
|
143
|
-
)
|
144
|
-
connect_method = _generate_connect_method(
|
145
|
-
model=model, use_pipeline_parameter_name=use_pipeline_parameter_name
|
146
|
-
)
|
147
|
-
|
148
|
-
pipeline_class: Type[BasePipeline] = type(
|
149
|
-
model.name,
|
150
|
-
(BasePipeline,),
|
151
|
-
{
|
152
|
-
"connect": staticmethod(connect_method),
|
153
|
-
"__doc__": model.docstring,
|
154
|
-
},
|
155
|
-
)
|
156
|
-
|
157
|
-
pipeline_instance = pipeline_class(**steps)
|
158
|
-
pipeline_instance.prepare()
|
159
|
-
return pipeline_instance
|
160
|
-
|
161
|
-
|
162
|
-
def _load_and_verify_steps(
|
163
|
-
pipeline_spec: "PipelineSpec", use_pipeline_parameter_name: bool = False
|
164
|
-
) -> Dict[str, BaseStep]:
|
165
|
-
"""Loads steps and verifies their names and inputs/outputs names.
|
166
|
-
|
167
|
-
Args:
|
168
|
-
pipeline_spec: The pipeline spec from which to load the steps.
|
169
|
-
use_pipeline_parameter_name: Whether to use the pipeline parameter name
|
170
|
-
when referring to upstream steps. If `False` the step name will be
|
171
|
-
used instead.
|
172
|
-
|
173
|
-
Raises:
|
174
|
-
RuntimeError: If the step names or input/output names of the
|
175
|
-
loaded steps don't match with the names defined in the spec.
|
176
|
-
|
177
|
-
Returns:
|
178
|
-
The loaded steps.
|
179
|
-
"""
|
180
|
-
steps = {}
|
181
|
-
available_outputs: Dict[str, Set[str]] = {}
|
182
|
-
|
183
|
-
for step_spec in pipeline_spec.steps:
|
184
|
-
for upstream_step in step_spec.upstream_steps:
|
185
|
-
if upstream_step not in available_outputs:
|
186
|
-
raise RuntimeError(
|
187
|
-
f"Unable to find upstream step `{upstream_step}`. "
|
188
|
-
"This is probably because the step was renamed in code."
|
189
|
-
)
|
190
|
-
|
191
|
-
for input_spec in step_spec.inputs.values():
|
192
|
-
if (
|
193
|
-
input_spec.output_name
|
194
|
-
not in available_outputs[input_spec.step_name]
|
195
|
-
):
|
196
|
-
raise RuntimeError(
|
197
|
-
f"Missing output `{input_spec.output_name}` for step "
|
198
|
-
f"`{input_spec.step_name}`. This is probably because "
|
199
|
-
"the output of the step was renamed."
|
200
|
-
)
|
201
|
-
|
202
|
-
step = BaseStep.load_from_source(step_spec.source)
|
203
|
-
input_names = set(step.entrypoint_definition.inputs)
|
204
|
-
spec_input_names = set(step_spec.inputs)
|
205
|
-
|
206
|
-
if input_names != spec_input_names:
|
207
|
-
raise RuntimeError(
|
208
|
-
f"Input names of step {step_spec.source} and the spec "
|
209
|
-
f"from the database don't match. Step inputs: "
|
210
|
-
f"`{input_names}`, spec inputs: `{spec_input_names}`."
|
211
|
-
)
|
212
|
-
|
213
|
-
steps[step_spec.pipeline_parameter_name] = step
|
214
|
-
output_name = (
|
215
|
-
step_spec.pipeline_parameter_name
|
216
|
-
if use_pipeline_parameter_name
|
217
|
-
else step.name
|
218
|
-
)
|
219
|
-
available_outputs[output_name] = set(
|
220
|
-
step.entrypoint_definition.outputs.keys()
|
221
|
-
)
|
222
|
-
|
223
|
-
return steps
|
224
|
-
|
225
|
-
|
226
|
-
def _generate_connect_method(
|
227
|
-
model: "PipelineResponse", use_pipeline_parameter_name: bool = False
|
228
|
-
) -> Callable[..., None]:
|
229
|
-
"""Dynamically generates a connect method for a pipeline model.
|
230
|
-
|
231
|
-
Args:
|
232
|
-
model: The model for which to generate the method.
|
233
|
-
use_pipeline_parameter_name: Whether to use the pipeline parameter name
|
234
|
-
when referring to upstream steps. If `False` the step name will be
|
235
|
-
used instead.
|
236
|
-
|
237
|
-
Returns:
|
238
|
-
The generated connect method.
|
239
|
-
"""
|
240
|
-
|
241
|
-
def connect(**steps: BaseStep) -> None:
|
242
|
-
# Bind **steps to the connect signature assigned to this method
|
243
|
-
# below. This ensures that the method inputs get verified and only
|
244
|
-
# the arguments defined in the signature are allowed
|
245
|
-
inspect.signature(connect).bind(**steps)
|
246
|
-
|
247
|
-
step_outputs: Dict[str, Dict[str, StepArtifact]] = {}
|
248
|
-
for step_spec in model.spec.steps:
|
249
|
-
step = steps[step_spec.pipeline_parameter_name]
|
250
|
-
|
251
|
-
step_inputs = {}
|
252
|
-
for input_name, input_ in step_spec.inputs.items():
|
253
|
-
try:
|
254
|
-
upstream_step = step_outputs[input_.step_name]
|
255
|
-
step_input = upstream_step[input_.output_name]
|
256
|
-
step_inputs[input_name] = step_input
|
257
|
-
except KeyError:
|
258
|
-
raise RuntimeError(
|
259
|
-
f"Unable to find upstream step "
|
260
|
-
f"`{input_.step_name}` in pipeline `{model.name}`. "
|
261
|
-
"This is probably due to configuring a new step "
|
262
|
-
"name after loading a pipeline using "
|
263
|
-
"`Pipeline.from_model`."
|
264
|
-
)
|
265
|
-
|
266
|
-
step_output = step(**step_inputs) # type: ignore[arg-type]
|
267
|
-
output_keys = list(step.entrypoint_definition.outputs.keys())
|
268
|
-
|
269
|
-
if isinstance(step_output, StepArtifact):
|
270
|
-
step_output = (step_output,)
|
271
|
-
|
272
|
-
output_name = (
|
273
|
-
step_spec.pipeline_parameter_name
|
274
|
-
if use_pipeline_parameter_name
|
275
|
-
else step.name
|
276
|
-
)
|
277
|
-
step_outputs[output_name] = {
|
278
|
-
key: step_output[i] for i, key in enumerate(output_keys)
|
279
|
-
}
|
280
|
-
|
281
|
-
# Create the connect method signature based on the expected steps
|
282
|
-
parameters = [
|
283
|
-
inspect.Parameter(
|
284
|
-
name=step_spec.pipeline_parameter_name,
|
285
|
-
kind=inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
286
|
-
)
|
287
|
-
for step_spec in model.spec.steps
|
288
|
-
]
|
289
|
-
signature = inspect.Signature(parameters=parameters)
|
290
|
-
connect.__signature__ = signature # type: ignore[attr-defined]
|
291
|
-
|
292
|
-
return connect
|
File without changes
|
File without changes
|
{zenml_nightly-0.62.0.dev20240728.dist-info → zenml_nightly-0.62.0.dev20240730.dist-info}/LICENSE
RENAMED
File without changes
|
{zenml_nightly-0.62.0.dev20240728.dist-info → zenml_nightly-0.62.0.dev20240730.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|