zenml-nightly 0.68.1.dev20241107__py3-none-any.whl → 0.68.1.dev20241108__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/artifacts/external_artifact.py +2 -1
- zenml/artifacts/utils.py +13 -20
- zenml/cli/base.py +4 -4
- zenml/cli/model.py +1 -6
- zenml/cli/stack.py +1 -0
- zenml/client.py +21 -73
- zenml/enums.py +12 -4
- zenml/integrations/aws/orchestrators/sagemaker_orchestrator.py +1 -1
- zenml/integrations/azure/orchestrators/azureml_orchestrator.py +1 -1
- zenml/integrations/gcp/orchestrators/vertex_orchestrator.py +1 -1
- zenml/integrations/tensorboard/visualizers/tensorboard_visualizer.py +60 -54
- zenml/metadata/lazy_load.py +20 -7
- zenml/model/model.py +1 -2
- zenml/models/__init__.py +0 -12
- zenml/models/v2/core/artifact_version.py +19 -7
- zenml/models/v2/core/model_version.py +3 -5
- zenml/models/v2/core/pipeline_run.py +3 -5
- zenml/models/v2/core/run_metadata.py +2 -217
- zenml/models/v2/core/step_run.py +40 -24
- zenml/orchestrators/input_utils.py +44 -19
- zenml/orchestrators/step_launcher.py +2 -2
- zenml/orchestrators/step_run_utils.py +19 -15
- zenml/orchestrators/step_runner.py +8 -3
- zenml/steps/base_step.py +1 -1
- zenml/steps/entrypoint_function_utils.py +3 -5
- zenml/steps/step_context.py +3 -2
- zenml/steps/utils.py +8 -2
- zenml/zen_server/rbac/utils.py +0 -2
- zenml/zen_server/routers/workspaces_endpoints.py +3 -4
- zenml/zen_server/zen_server_api.py +0 -2
- zenml/zen_stores/migrations/versions/1cb6477f72d6_move_artifact_save_type.py +99 -0
- zenml/zen_stores/migrations/versions/b557b2871693_update_step_run_input_types.py +33 -0
- zenml/zen_stores/rest_zen_store.py +3 -54
- zenml/zen_stores/schemas/artifact_schemas.py +8 -1
- zenml/zen_stores/schemas/model_schemas.py +2 -2
- zenml/zen_stores/schemas/pipeline_run_schemas.py +1 -1
- zenml/zen_stores/schemas/run_metadata_schemas.py +1 -48
- zenml/zen_stores/schemas/step_run_schemas.py +18 -10
- zenml/zen_stores/sql_zen_store.py +52 -98
- zenml/zen_stores/zen_store_interface.py +2 -42
- {zenml_nightly-0.68.1.dev20241107.dist-info → zenml_nightly-0.68.1.dev20241108.dist-info}/METADATA +1 -1
- {zenml_nightly-0.68.1.dev20241107.dist-info → zenml_nightly-0.68.1.dev20241108.dist-info}/RECORD +46 -45
- zenml/zen_server/routers/run_metadata_endpoints.py +0 -96
- {zenml_nightly-0.68.1.dev20241107.dist-info → zenml_nightly-0.68.1.dev20241108.dist-info}/LICENSE +0 -0
- {zenml_nightly-0.68.1.dev20241107.dist-info → zenml_nightly-0.68.1.dev20241108.dist-info}/WHEEL +0 -0
- {zenml_nightly-0.68.1.dev20241107.dist-info → zenml_nightly-0.68.1.dev20241108.dist-info}/entry_points.txt +0 -0
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
import json
|
17
17
|
from datetime import datetime
|
18
|
-
from typing import TYPE_CHECKING, Any, List, Optional
|
18
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
19
19
|
from uuid import UUID
|
20
20
|
|
21
21
|
from pydantic import ConfigDict
|
@@ -28,6 +28,7 @@ from zenml.constants import MEDIUMTEXT_MAX_LENGTH
|
|
28
28
|
from zenml.enums import (
|
29
29
|
ExecutionStatus,
|
30
30
|
MetadataResourceTypes,
|
31
|
+
StepRunInputArtifactType,
|
31
32
|
)
|
32
33
|
from zenml.models import (
|
33
34
|
StepRunRequest,
|
@@ -36,7 +37,11 @@ from zenml.models import (
|
|
36
37
|
StepRunResponseMetadata,
|
37
38
|
StepRunUpdate,
|
38
39
|
)
|
39
|
-
from zenml.models.v2.core.
|
40
|
+
from zenml.models.v2.core.artifact_version import ArtifactVersionResponse
|
41
|
+
from zenml.models.v2.core.step_run import (
|
42
|
+
StepRunInputResponse,
|
43
|
+
StepRunResponseResources,
|
44
|
+
)
|
40
45
|
from zenml.zen_stores.schemas.base_schemas import NamedSchema
|
41
46
|
from zenml.zen_stores.schemas.constants import MODEL_VERSION_TABLENAME
|
42
47
|
from zenml.zen_stores.schemas.pipeline_deployment_schemas import (
|
@@ -214,21 +219,25 @@ class StepRunSchema(NamedSchema, table=True):
|
|
214
219
|
or a step_configuration.
|
215
220
|
"""
|
216
221
|
run_metadata = {
|
217
|
-
metadata_schema.key: metadata_schema.
|
222
|
+
metadata_schema.key: json.loads(metadata_schema.value)
|
218
223
|
for metadata_schema in self.run_metadata
|
219
224
|
}
|
220
225
|
|
221
226
|
input_artifacts = {
|
222
|
-
artifact.name:
|
227
|
+
artifact.name: StepRunInputResponse(
|
228
|
+
input_type=StepRunInputArtifactType(artifact.type),
|
229
|
+
**artifact.artifact_version.to_model().model_dump(),
|
230
|
+
)
|
223
231
|
for artifact in self.input_artifacts
|
224
232
|
}
|
225
233
|
|
226
|
-
output_artifacts = {
|
227
|
-
|
228
|
-
|
234
|
+
output_artifacts: Dict[str, List["ArtifactVersionResponse"]] = {}
|
235
|
+
for artifact in self.output_artifacts:
|
236
|
+
if artifact.name not in output_artifacts:
|
237
|
+
output_artifacts[artifact.name] = []
|
238
|
+
output_artifacts[artifact.name].append(
|
239
|
+
artifact.artifact_version.to_model()
|
229
240
|
)
|
230
|
-
for artifact in self.output_artifacts
|
231
|
-
}
|
232
241
|
|
233
242
|
full_step_config = None
|
234
243
|
if self.deployment is not None:
|
@@ -398,7 +407,6 @@ class StepRunOutputArtifactSchema(SQLModel, table=True):
|
|
398
407
|
|
399
408
|
# Fields
|
400
409
|
name: str
|
401
|
-
type: str
|
402
410
|
|
403
411
|
# Foreign keys
|
404
412
|
step_id: UUID = build_foreign_key_field(
|
@@ -86,6 +86,7 @@ from zenml.config.global_config import GlobalConfiguration
|
|
86
86
|
from zenml.config.pipeline_run_configuration import PipelineRunConfiguration
|
87
87
|
from zenml.config.secrets_store_config import SecretsStoreConfiguration
|
88
88
|
from zenml.config.server_config import ServerConfiguration
|
89
|
+
from zenml.config.step_configurations import StepConfiguration, StepSpec
|
89
90
|
from zenml.config.store_config import StoreConfiguration
|
90
91
|
from zenml.constants import (
|
91
92
|
DEFAULT_PASSWORD,
|
@@ -118,7 +119,6 @@ from zenml.enums import (
|
|
118
119
|
StackComponentType,
|
119
120
|
StackDeploymentProvider,
|
120
121
|
StepRunInputArtifactType,
|
121
|
-
StepRunOutputArtifactType,
|
122
122
|
StoreType,
|
123
123
|
TaggableResourceTypes,
|
124
124
|
)
|
@@ -216,9 +216,7 @@ from zenml.models import (
|
|
216
216
|
PipelineRunResponse,
|
217
217
|
PipelineRunUpdate,
|
218
218
|
PipelineUpdate,
|
219
|
-
RunMetadataFilter,
|
220
219
|
RunMetadataRequest,
|
221
|
-
RunMetadataResponse,
|
222
220
|
RunTemplateFilter,
|
223
221
|
RunTemplateRequest,
|
224
222
|
RunTemplateResponse,
|
@@ -5481,9 +5479,7 @@ class SqlZenStore(BaseZenStore):
|
|
5481
5479
|
|
5482
5480
|
# ----------------------------- Run Metadata -----------------------------
|
5483
5481
|
|
5484
|
-
def create_run_metadata(
|
5485
|
-
self, run_metadata: RunMetadataRequest
|
5486
|
-
) -> List[RunMetadataResponse]:
|
5482
|
+
def create_run_metadata(self, run_metadata: RunMetadataRequest) -> None:
|
5487
5483
|
"""Creates run metadata.
|
5488
5484
|
|
5489
5485
|
Args:
|
@@ -5492,7 +5488,6 @@ class SqlZenStore(BaseZenStore):
|
|
5492
5488
|
Returns:
|
5493
5489
|
The created run metadata.
|
5494
5490
|
"""
|
5495
|
-
return_value: List[RunMetadataResponse] = []
|
5496
5491
|
with Session(self.engine) as session:
|
5497
5492
|
for key, value in run_metadata.values.items():
|
5498
5493
|
type_ = run_metadata.types[key]
|
@@ -5508,70 +5503,7 @@ class SqlZenStore(BaseZenStore):
|
|
5508
5503
|
)
|
5509
5504
|
session.add(run_metadata_schema)
|
5510
5505
|
session.commit()
|
5511
|
-
|
5512
|
-
run_metadata_schema.to_model(
|
5513
|
-
include_metadata=True, include_resources=True
|
5514
|
-
)
|
5515
|
-
)
|
5516
|
-
return return_value
|
5517
|
-
|
5518
|
-
def get_run_metadata(
|
5519
|
-
self, run_metadata_id: UUID, hydrate: bool = True
|
5520
|
-
) -> RunMetadataResponse:
|
5521
|
-
"""Gets run metadata with the given ID.
|
5522
|
-
|
5523
|
-
Args:
|
5524
|
-
run_metadata_id: The ID of the run metadata to get.
|
5525
|
-
hydrate: Flag deciding whether to hydrate the output model(s)
|
5526
|
-
by including metadata fields in the response.
|
5527
|
-
|
5528
|
-
Returns:
|
5529
|
-
The run metadata.
|
5530
|
-
|
5531
|
-
Raises:
|
5532
|
-
KeyError: if the run metadata doesn't exist.
|
5533
|
-
"""
|
5534
|
-
with Session(self.engine) as session:
|
5535
|
-
run_metadata = session.exec(
|
5536
|
-
select(RunMetadataSchema).where(
|
5537
|
-
RunMetadataSchema.id == run_metadata_id
|
5538
|
-
)
|
5539
|
-
).first()
|
5540
|
-
if run_metadata is None:
|
5541
|
-
raise KeyError(
|
5542
|
-
f"Unable to get run metadata with ID "
|
5543
|
-
f"{run_metadata_id}: "
|
5544
|
-
f"No run metadata with this ID found."
|
5545
|
-
)
|
5546
|
-
return run_metadata.to_model(
|
5547
|
-
include_metadata=hydrate, include_resources=True
|
5548
|
-
)
|
5549
|
-
|
5550
|
-
def list_run_metadata(
|
5551
|
-
self,
|
5552
|
-
run_metadata_filter_model: RunMetadataFilter,
|
5553
|
-
hydrate: bool = False,
|
5554
|
-
) -> Page[RunMetadataResponse]:
|
5555
|
-
"""List run metadata.
|
5556
|
-
|
5557
|
-
Args:
|
5558
|
-
run_metadata_filter_model: All filter parameters including
|
5559
|
-
pagination params.
|
5560
|
-
hydrate: Flag deciding whether to hydrate the output model(s)
|
5561
|
-
by including metadata fields in the response.
|
5562
|
-
|
5563
|
-
Returns:
|
5564
|
-
The run metadata.
|
5565
|
-
"""
|
5566
|
-
with Session(self.engine) as session:
|
5567
|
-
query = select(RunMetadataSchema)
|
5568
|
-
return self.filter_and_paginate(
|
5569
|
-
session=session,
|
5570
|
-
query=query,
|
5571
|
-
table=RunMetadataSchema,
|
5572
|
-
filter_model=run_metadata_filter_model,
|
5573
|
-
hydrate=hydrate,
|
5574
|
-
)
|
5506
|
+
return None
|
5575
5507
|
|
5576
5508
|
# ----------------------------- Schedules -----------------------------
|
5577
5509
|
|
@@ -8189,25 +8121,35 @@ class SqlZenStore(BaseZenStore):
|
|
8189
8121
|
session=session,
|
8190
8122
|
)
|
8191
8123
|
|
8124
|
+
session.commit()
|
8125
|
+
session.refresh(step_schema)
|
8126
|
+
|
8127
|
+
step_model = step_schema.to_model(include_metadata=True)
|
8128
|
+
|
8192
8129
|
# Save input artifact IDs into the database.
|
8193
8130
|
for input_name, artifact_version_id in step_run.inputs.items():
|
8131
|
+
input_type = self._get_step_run_input_type(
|
8132
|
+
input_name=input_name,
|
8133
|
+
step_config=step_model.config,
|
8134
|
+
step_spec=step_model.spec,
|
8135
|
+
)
|
8194
8136
|
self._set_run_step_input_artifact(
|
8195
8137
|
run_step_id=step_schema.id,
|
8196
8138
|
artifact_version_id=artifact_version_id,
|
8197
8139
|
name=input_name,
|
8198
|
-
input_type=
|
8140
|
+
input_type=input_type,
|
8199
8141
|
session=session,
|
8200
8142
|
)
|
8201
8143
|
|
8202
8144
|
# Save output artifact IDs into the database.
|
8203
|
-
for output_name,
|
8204
|
-
|
8205
|
-
|
8206
|
-
|
8207
|
-
|
8208
|
-
|
8209
|
-
|
8210
|
-
|
8145
|
+
for output_name, artifact_version_ids in step_run.outputs.items():
|
8146
|
+
for artifact_version_id in artifact_version_ids:
|
8147
|
+
self._set_run_step_output_artifact(
|
8148
|
+
step_run_id=step_schema.id,
|
8149
|
+
artifact_version_id=artifact_version_id,
|
8150
|
+
name=output_name,
|
8151
|
+
session=session,
|
8152
|
+
)
|
8211
8153
|
|
8212
8154
|
if step_run.status != ExecutionStatus.RUNNING:
|
8213
8155
|
self._update_pipeline_run_status(
|
@@ -8215,6 +8157,7 @@ class SqlZenStore(BaseZenStore):
|
|
8215
8157
|
)
|
8216
8158
|
|
8217
8159
|
session.commit()
|
8160
|
+
session.refresh(step_schema)
|
8218
8161
|
|
8219
8162
|
return step_schema.to_model(
|
8220
8163
|
include_metadata=True, include_resources=True
|
@@ -8307,26 +8250,12 @@ class SqlZenStore(BaseZenStore):
|
|
8307
8250
|
existing_step_run.update(step_run_update)
|
8308
8251
|
session.add(existing_step_run)
|
8309
8252
|
|
8310
|
-
# Update the
|
8253
|
+
# Update the artifacts.
|
8311
8254
|
for name, artifact_version_id in step_run_update.outputs.items():
|
8312
8255
|
self._set_run_step_output_artifact(
|
8313
8256
|
step_run_id=step_run_id,
|
8314
8257
|
artifact_version_id=artifact_version_id,
|
8315
8258
|
name=name,
|
8316
|
-
output_type=StepRunOutputArtifactType.DEFAULT,
|
8317
|
-
session=session,
|
8318
|
-
)
|
8319
|
-
|
8320
|
-
# Update saved artifacts
|
8321
|
-
for (
|
8322
|
-
artifact_name,
|
8323
|
-
artifact_version_id,
|
8324
|
-
) in step_run_update.saved_artifact_versions.items():
|
8325
|
-
self._set_run_step_output_artifact(
|
8326
|
-
step_run_id=step_run_id,
|
8327
|
-
artifact_version_id=artifact_version_id,
|
8328
|
-
name=artifact_name,
|
8329
|
-
output_type=StepRunOutputArtifactType.MANUAL,
|
8330
8259
|
session=session,
|
8331
8260
|
)
|
8332
8261
|
|
@@ -8355,6 +8284,34 @@ class SqlZenStore(BaseZenStore):
|
|
8355
8284
|
include_metadata=True, include_resources=True
|
8356
8285
|
)
|
8357
8286
|
|
8287
|
+
def _get_step_run_input_type(
|
8288
|
+
self,
|
8289
|
+
input_name: str,
|
8290
|
+
step_config: StepConfiguration,
|
8291
|
+
step_spec: StepSpec,
|
8292
|
+
) -> StepRunInputArtifactType:
|
8293
|
+
"""Get the input type of an artifact.
|
8294
|
+
|
8295
|
+
Args:
|
8296
|
+
input_name: The name of the input artifact.
|
8297
|
+
step_config: The step config.
|
8298
|
+
step_spec: The step spec.
|
8299
|
+
|
8300
|
+
Returns:
|
8301
|
+
The input type of the artifact.
|
8302
|
+
"""
|
8303
|
+
if input_name in step_spec.inputs:
|
8304
|
+
return StepRunInputArtifactType.STEP_OUTPUT
|
8305
|
+
if input_name in step_config.external_input_artifacts:
|
8306
|
+
return StepRunInputArtifactType.EXTERNAL
|
8307
|
+
elif (
|
8308
|
+
input_name in step_config.model_artifacts_or_metadata
|
8309
|
+
or input_name in step_config.client_lazy_loaders
|
8310
|
+
):
|
8311
|
+
return StepRunInputArtifactType.LAZY_LOADED
|
8312
|
+
else:
|
8313
|
+
return StepRunInputArtifactType.MANUAL
|
8314
|
+
|
8358
8315
|
@staticmethod
|
8359
8316
|
def _set_run_step_parent_step(
|
8360
8317
|
child_id: UUID, parent_id: UUID, session: Session
|
@@ -8473,7 +8430,6 @@ class SqlZenStore(BaseZenStore):
|
|
8473
8430
|
step_run_id: UUID,
|
8474
8431
|
artifact_version_id: UUID,
|
8475
8432
|
name: str,
|
8476
|
-
output_type: StepRunOutputArtifactType,
|
8477
8433
|
session: Session,
|
8478
8434
|
) -> None:
|
8479
8435
|
"""Sets an artifact as an output of a step run.
|
@@ -8482,7 +8438,6 @@ class SqlZenStore(BaseZenStore):
|
|
8482
8438
|
step_run_id: The ID of the step run.
|
8483
8439
|
artifact_version_id: The ID of the artifact version.
|
8484
8440
|
name: The name of the output in the step run.
|
8485
|
-
output_type: In which way the artifact was saved by the step.
|
8486
8441
|
session: The database session to use.
|
8487
8442
|
|
8488
8443
|
Raises:
|
@@ -8526,7 +8481,6 @@ class SqlZenStore(BaseZenStore):
|
|
8526
8481
|
step_id=step_run_id,
|
8527
8482
|
artifact_id=artifact_version_id,
|
8528
8483
|
name=name,
|
8529
|
-
type=output_type.value,
|
8530
8484
|
)
|
8531
8485
|
session.add(assignment)
|
8532
8486
|
|
@@ -90,9 +90,7 @@ from zenml.models import (
|
|
90
90
|
PipelineRunResponse,
|
91
91
|
PipelineRunUpdate,
|
92
92
|
PipelineUpdate,
|
93
|
-
RunMetadataFilter,
|
94
93
|
RunMetadataRequest,
|
95
|
-
RunMetadataResponse,
|
96
94
|
RunTemplateFilter,
|
97
95
|
RunTemplateRequest,
|
98
96
|
RunTemplateResponse,
|
@@ -1633,52 +1631,14 @@ class ZenStoreInterface(ABC):
|
|
1633
1631
|
# -------------------- Run metadata --------------------
|
1634
1632
|
|
1635
1633
|
@abstractmethod
|
1636
|
-
def create_run_metadata(
|
1637
|
-
self, run_metadata: RunMetadataRequest
|
1638
|
-
) -> List[RunMetadataResponse]:
|
1634
|
+
def create_run_metadata(self, run_metadata: RunMetadataRequest) -> None:
|
1639
1635
|
"""Creates run metadata.
|
1640
1636
|
|
1641
1637
|
Args:
|
1642
1638
|
run_metadata: The run metadata to create.
|
1643
1639
|
|
1644
1640
|
Returns:
|
1645
|
-
|
1646
|
-
"""
|
1647
|
-
|
1648
|
-
@abstractmethod
|
1649
|
-
def get_run_metadata(
|
1650
|
-
self, run_metadata_id: UUID, hydrate: bool = True
|
1651
|
-
) -> RunMetadataResponse:
|
1652
|
-
"""Get run metadata by its unique ID.
|
1653
|
-
|
1654
|
-
Args:
|
1655
|
-
run_metadata_id: The ID of the run metadata to get.
|
1656
|
-
hydrate: Flag deciding whether to hydrate the output model(s)
|
1657
|
-
by including metadata fields in the response.
|
1658
|
-
|
1659
|
-
Returns:
|
1660
|
-
The run metadata with the given ID.
|
1661
|
-
|
1662
|
-
Raises:
|
1663
|
-
KeyError: if the run metadata doesn't exist.
|
1664
|
-
"""
|
1665
|
-
|
1666
|
-
@abstractmethod
|
1667
|
-
def list_run_metadata(
|
1668
|
-
self,
|
1669
|
-
run_metadata_filter_model: RunMetadataFilter,
|
1670
|
-
hydrate: bool = False,
|
1671
|
-
) -> Page[RunMetadataResponse]:
|
1672
|
-
"""List run metadata.
|
1673
|
-
|
1674
|
-
Args:
|
1675
|
-
run_metadata_filter_model: All filter parameters including
|
1676
|
-
pagination params.
|
1677
|
-
hydrate: Flag deciding whether to hydrate the output model(s)
|
1678
|
-
by including metadata fields in the response.
|
1679
|
-
|
1680
|
-
Returns:
|
1681
|
-
The run metadata.
|
1641
|
+
None
|
1682
1642
|
"""
|
1683
1643
|
|
1684
1644
|
# -------------------- Schedules --------------------
|