zenml-nightly 0.71.0.dev20250107__py3-none-any.whl → 0.71.0.dev20250109__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 CHANGED
@@ -1 +1 @@
1
- 0.71.0.dev20250107
1
+ 0.71.0.dev20250109
@@ -490,15 +490,14 @@ class WorkspaceScopedTaggableFilter(WorkspaceScopedFilter):
490
490
  Returns:
491
491
  The query with filter applied.
492
492
  """
493
- from zenml.zen_stores.schemas import TagResourceSchema
493
+ from zenml.zen_stores.schemas import TagResourceSchema, TagSchema
494
494
 
495
495
  query = super().apply_filter(query=query, table=table)
496
496
  if self.tag:
497
- query = (
498
- query.join(getattr(table, "tags"))
499
- .join(TagResourceSchema.tag)
500
- .distinct()
501
- )
497
+ query = query.join(
498
+ TagResourceSchema,
499
+ TagResourceSchema.resource_id == getattr(table, "id"),
500
+ ).join(TagSchema, TagSchema.id == TagResourceSchema.tag_id)
502
501
 
503
502
  return query
504
503
 
@@ -59,10 +59,8 @@ if TYPE_CHECKING:
59
59
  from zenml.zen_stores.schemas.model_schemas import (
60
60
  ModelVersionArtifactSchema,
61
61
  )
62
- from zenml.zen_stores.schemas.run_metadata_schemas import (
63
- RunMetadataResourceSchema,
64
- )
65
- from zenml.zen_stores.schemas.tag_schemas import TagResourceSchema
62
+ from zenml.zen_stores.schemas.run_metadata_schemas import RunMetadataSchema
63
+ from zenml.zen_stores.schemas.tag_schemas import TagSchema
66
64
 
67
65
 
68
66
  class ArtifactSchema(NamedSchema, table=True):
@@ -82,11 +80,12 @@ class ArtifactSchema(NamedSchema, table=True):
82
80
  back_populates="artifact",
83
81
  sa_relationship_kwargs={"cascade": "delete"},
84
82
  )
85
- tags: List["TagResourceSchema"] = Relationship(
86
- back_populates="artifact",
83
+ tags: List["TagSchema"] = Relationship(
87
84
  sa_relationship_kwargs=dict(
88
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.ARTIFACT.value}', foreign(TagResourceSchema.resource_id)==ArtifactSchema.id)",
89
- cascade="delete",
85
+ primaryjoin=f"and_(foreign(TagResourceSchema.resource_type)=='{TaggableResourceTypes.ARTIFACT.value}', foreign(TagResourceSchema.resource_id)==ArtifactSchema.id)",
86
+ secondary="tag_resource",
87
+ secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)",
88
+ order_by="TagSchema.name",
90
89
  overlaps="tags",
91
90
  ),
92
91
  )
@@ -136,7 +135,7 @@ class ArtifactSchema(NamedSchema, table=True):
136
135
  body = ArtifactResponseBody(
137
136
  created=self.created,
138
137
  updated=self.updated,
139
- tags=[t.tag.to_model() for t in self.tags],
138
+ tags=[tag.to_model() for tag in self.tags],
140
139
  latest_version_name=latest_name,
141
140
  latest_version_id=latest_id,
142
141
  )
@@ -192,11 +191,12 @@ class ArtifactVersionSchema(BaseSchema, RunMetadataInterface, table=True):
192
191
  uri: str = Field(sa_column=Column(TEXT, nullable=False))
193
192
  materializer: str = Field(sa_column=Column(TEXT, nullable=False))
194
193
  data_type: str = Field(sa_column=Column(TEXT, nullable=False))
195
- tags: List["TagResourceSchema"] = Relationship(
196
- back_populates="artifact_version",
194
+ tags: List["TagSchema"] = Relationship(
197
195
  sa_relationship_kwargs=dict(
198
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.ARTIFACT_VERSION.value}', foreign(TagResourceSchema.resource_id)==ArtifactVersionSchema.id)",
199
- cascade="delete",
196
+ primaryjoin=f"and_(foreign(TagResourceSchema.resource_type)=='{TaggableResourceTypes.ARTIFACT_VERSION.value}', foreign(TagResourceSchema.resource_id)==ArtifactVersionSchema.id)",
197
+ secondary="tag_resource",
198
+ secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)",
199
+ order_by="TagSchema.name",
200
200
  overlaps="tags",
201
201
  ),
202
202
  )
@@ -244,12 +244,12 @@ class ArtifactVersionSchema(BaseSchema, RunMetadataInterface, table=True):
244
244
  workspace: "WorkspaceSchema" = Relationship(
245
245
  back_populates="artifact_versions"
246
246
  )
247
- run_metadata_resources: List["RunMetadataResourceSchema"] = Relationship(
248
- back_populates="artifact_versions",
247
+ run_metadata: List["RunMetadataSchema"] = Relationship(
249
248
  sa_relationship_kwargs=dict(
250
- primaryjoin=f"and_(RunMetadataResourceSchema.resource_type=='{MetadataResourceTypes.ARTIFACT_VERSION.value}', foreign(RunMetadataResourceSchema.resource_id)==ArtifactVersionSchema.id)",
251
- cascade="delete",
252
- overlaps="run_metadata_resources",
249
+ secondary="run_metadata_resource",
250
+ primaryjoin=f"and_(foreign(RunMetadataResourceSchema.resource_type)=='{MetadataResourceTypes.ARTIFACT_VERSION.value}', foreign(RunMetadataResourceSchema.resource_id)==ArtifactVersionSchema.id)",
251
+ secondaryjoin="RunMetadataSchema.id==foreign(RunMetadataResourceSchema.run_metadata_id)",
252
+ overlaps="run_metadata",
253
253
  ),
254
254
  )
255
255
  output_of_step_runs: List["StepRunOutputArtifactSchema"] = Relationship(
@@ -365,7 +365,7 @@ class ArtifactVersionSchema(BaseSchema, RunMetadataInterface, table=True):
365
365
  data_type=data_type,
366
366
  created=self.created,
367
367
  updated=self.updated,
368
- tags=[t.tag.to_model() for t in self.tags],
368
+ tags=[tag.to_model() for tag in self.tags],
369
369
  producer_pipeline_run_id=producer_pipeline_run_id,
370
370
  save_type=ArtifactSaveType(self.save_type),
371
371
  artifact_store_id=self.artifact_store_id,
@@ -56,11 +56,9 @@ from zenml.zen_stores.schemas.artifact_schemas import ArtifactVersionSchema
56
56
  from zenml.zen_stores.schemas.base_schemas import BaseSchema, NamedSchema
57
57
  from zenml.zen_stores.schemas.constants import MODEL_VERSION_TABLENAME
58
58
  from zenml.zen_stores.schemas.pipeline_run_schemas import PipelineRunSchema
59
- from zenml.zen_stores.schemas.run_metadata_schemas import (
60
- RunMetadataResourceSchema,
61
- )
59
+ from zenml.zen_stores.schemas.run_metadata_schemas import RunMetadataSchema
62
60
  from zenml.zen_stores.schemas.schema_utils import build_foreign_key_field
63
- from zenml.zen_stores.schemas.tag_schemas import TagResourceSchema
61
+ from zenml.zen_stores.schemas.tag_schemas import TagSchema
64
62
  from zenml.zen_stores.schemas.user_schemas import UserSchema
65
63
  from zenml.zen_stores.schemas.utils import (
66
64
  RunMetadataInterface,
@@ -114,11 +112,12 @@ class ModelSchema(NamedSchema, table=True):
114
112
  save_models_to_registry: bool = Field(
115
113
  sa_column=Column(BOOLEAN, nullable=False)
116
114
  )
117
- tags: List["TagResourceSchema"] = Relationship(
118
- back_populates="model",
115
+ tags: List["TagSchema"] = Relationship(
119
116
  sa_relationship_kwargs=dict(
120
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.MODEL.value}', foreign(TagResourceSchema.resource_id)==ModelSchema.id)",
121
- cascade="delete",
117
+ primaryjoin=f"and_(foreign(TagResourceSchema.resource_type)=='{TaggableResourceTypes.MODEL.value}', foreign(TagResourceSchema.resource_id)==ModelSchema.id)",
118
+ secondary="tag_resource",
119
+ secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)",
120
+ order_by="TagSchema.name",
122
121
  overlaps="tags",
123
122
  ),
124
123
  )
@@ -168,7 +167,7 @@ class ModelSchema(NamedSchema, table=True):
168
167
  Returns:
169
168
  The created `ModelResponse`.
170
169
  """
171
- tags = [t.tag.to_model() for t in self.tags]
170
+ tags = [tag.to_model() for tag in self.tags]
172
171
 
173
172
  if self.model_versions:
174
173
  version_numbers = [mv.number for mv in self.model_versions]
@@ -299,11 +298,12 @@ class ModelVersionSchema(NamedSchema, RunMetadataInterface, table=True):
299
298
  back_populates="model_version",
300
299
  sa_relationship_kwargs={"cascade": "delete"},
301
300
  )
302
- tags: List["TagResourceSchema"] = Relationship(
303
- back_populates="model_version",
301
+ tags: List["TagSchema"] = Relationship(
304
302
  sa_relationship_kwargs=dict(
305
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.MODEL_VERSION.value}', foreign(TagResourceSchema.resource_id)==ModelVersionSchema.id)",
306
- cascade="delete",
303
+ primaryjoin=f"and_(foreign(TagResourceSchema.resource_type)=='{TaggableResourceTypes.MODEL_VERSION.value}', foreign(TagResourceSchema.resource_id)==ModelVersionSchema.id)",
304
+ secondary="tag_resource",
305
+ secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)",
306
+ order_by="TagSchema.name",
307
307
  overlaps="tags",
308
308
  ),
309
309
  )
@@ -316,12 +316,12 @@ class ModelVersionSchema(NamedSchema, RunMetadataInterface, table=True):
316
316
  description: str = Field(sa_column=Column(TEXT, nullable=True))
317
317
  stage: str = Field(sa_column=Column(TEXT, nullable=True))
318
318
 
319
- run_metadata_resources: List["RunMetadataResourceSchema"] = Relationship(
320
- back_populates="model_versions",
319
+ run_metadata: List["RunMetadataSchema"] = Relationship(
321
320
  sa_relationship_kwargs=dict(
322
- primaryjoin=f"and_(RunMetadataResourceSchema.resource_type=='{MetadataResourceTypes.MODEL_VERSION.value}', foreign(RunMetadataResourceSchema.resource_id)==ModelVersionSchema.id)",
323
- cascade="delete",
324
- overlaps="run_metadata_resources",
321
+ secondary="run_metadata_resource",
322
+ primaryjoin=f"and_(foreign(RunMetadataResourceSchema.resource_type)=='{MetadataResourceTypes.MODEL_VERSION.value}', foreign(RunMetadataResourceSchema.resource_id)==ModelVersionSchema.id)",
323
+ secondaryjoin="RunMetadataSchema.id==foreign(RunMetadataResourceSchema.run_metadata_id)",
324
+ overlaps="run_metadata",
325
325
  ),
326
326
  )
327
327
  pipeline_runs: List["PipelineRunSchema"] = Relationship(
@@ -471,7 +471,7 @@ class ModelVersionSchema(NamedSchema, RunMetadataInterface, table=True):
471
471
  data_artifact_ids=data_artifact_ids,
472
472
  deployment_artifact_ids=deployment_artifact_ids,
473
473
  pipeline_run_ids=pipeline_run_ids,
474
- tags=[t.tag.to_model() for t in self.tags],
474
+ tags=[tag.to_model() for tag in self.tags],
475
475
  )
476
476
 
477
477
  return ModelVersionResponse(
@@ -58,12 +58,10 @@ if TYPE_CHECKING:
58
58
  ModelVersionPipelineRunSchema,
59
59
  ModelVersionSchema,
60
60
  )
61
- from zenml.zen_stores.schemas.run_metadata_schemas import (
62
- RunMetadataResourceSchema,
63
- )
61
+ from zenml.zen_stores.schemas.run_metadata_schemas import RunMetadataSchema
64
62
  from zenml.zen_stores.schemas.service_schemas import ServiceSchema
65
63
  from zenml.zen_stores.schemas.step_run_schemas import StepRunSchema
66
- from zenml.zen_stores.schemas.tag_schemas import TagResourceSchema
64
+ from zenml.zen_stores.schemas.tag_schemas import TagSchema
67
65
 
68
66
 
69
67
  class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True):
@@ -140,12 +138,12 @@ class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True):
140
138
  )
141
139
  workspace: "WorkspaceSchema" = Relationship(back_populates="runs")
142
140
  user: Optional["UserSchema"] = Relationship(back_populates="runs")
143
- run_metadata_resources: List["RunMetadataResourceSchema"] = Relationship(
144
- back_populates="pipeline_runs",
141
+ run_metadata: List["RunMetadataSchema"] = Relationship(
145
142
  sa_relationship_kwargs=dict(
146
- primaryjoin=f"and_(RunMetadataResourceSchema.resource_type=='{MetadataResourceTypes.PIPELINE_RUN.value}', foreign(RunMetadataResourceSchema.resource_id)==PipelineRunSchema.id)",
147
- cascade="delete",
148
- overlaps="run_metadata_resources",
143
+ secondary="run_metadata_resource",
144
+ primaryjoin=f"and_(foreign(RunMetadataResourceSchema.resource_type)=='{MetadataResourceTypes.PIPELINE_RUN.value}', foreign(RunMetadataResourceSchema.resource_id)==PipelineRunSchema.id)",
145
+ secondaryjoin="RunMetadataSchema.id==foreign(RunMetadataResourceSchema.run_metadata_id)",
146
+ overlaps="run_metadata",
149
147
  ),
150
148
  )
151
149
  logs: Optional["LogsSchema"] = Relationship(
@@ -215,10 +213,12 @@ class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True):
215
213
  services: List["ServiceSchema"] = Relationship(
216
214
  back_populates="pipeline_run",
217
215
  )
218
- tags: List["TagResourceSchema"] = Relationship(
216
+ tags: List["TagSchema"] = Relationship(
219
217
  sa_relationship_kwargs=dict(
220
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.PIPELINE_RUN.value}', foreign(TagResourceSchema.resource_id)==PipelineRunSchema.id)",
221
- cascade="delete",
218
+ primaryjoin=f"and_(foreign(TagResourceSchema.resource_type)=='{TaggableResourceTypes.PIPELINE_RUN.value}', foreign(TagResourceSchema.resource_id)==PipelineRunSchema.id)",
219
+ secondary="tag_resource",
220
+ secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)",
221
+ order_by="TagSchema.name",
222
222
  overlaps="tags",
223
223
  ),
224
224
  )
@@ -291,12 +291,6 @@ class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True):
291
291
  Raises:
292
292
  RuntimeError: if the model creation fails.
293
293
  """
294
- orchestrator_environment = (
295
- json.loads(self.orchestrator_environment)
296
- if self.orchestrator_environment
297
- else {}
298
- )
299
-
300
294
  if self.deployment is not None:
301
295
  deployment = self.deployment.to_model(include_metadata=True)
302
296
 
@@ -377,6 +371,11 @@ class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True):
377
371
  # in the response -> We need to reset the metadata here
378
372
  step.metadata = None
379
373
 
374
+ orchestrator_environment = (
375
+ json.loads(self.orchestrator_environment)
376
+ if self.orchestrator_environment
377
+ else {}
378
+ )
380
379
  metadata = PipelineRunResponseMetadata(
381
380
  workspace=self.workspace.to_model(),
382
381
  run_metadata=self.fetch_metadata(),
@@ -405,7 +404,7 @@ class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True):
405
404
 
406
405
  resources = PipelineRunResponseResources(
407
406
  model_version=model_version,
408
- tags=[t.tag.to_model() for t in self.tags],
407
+ tags=[tag.to_model() for tag in self.tags],
409
408
  )
410
409
 
411
410
  return PipelineRunResponse(
@@ -43,7 +43,7 @@ if TYPE_CHECKING:
43
43
  )
44
44
  from zenml.zen_stores.schemas.pipeline_run_schemas import PipelineRunSchema
45
45
  from zenml.zen_stores.schemas.schedule_schema import ScheduleSchema
46
- from zenml.zen_stores.schemas.tag_schemas import TagResourceSchema
46
+ from zenml.zen_stores.schemas.tag_schemas import TagSchema
47
47
 
48
48
 
49
49
  class PipelineSchema(NamedSchema, table=True):
@@ -95,10 +95,12 @@ class PipelineSchema(NamedSchema, table=True):
95
95
  deployments: List["PipelineDeploymentSchema"] = Relationship(
96
96
  back_populates="pipeline",
97
97
  )
98
- tags: List["TagResourceSchema"] = Relationship(
98
+ tags: List["TagSchema"] = Relationship(
99
99
  sa_relationship_kwargs=dict(
100
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.PIPELINE.value}', foreign(TagResourceSchema.resource_id)==PipelineSchema.id)",
101
- cascade="delete",
100
+ primaryjoin=f"and_(foreign(TagResourceSchema.resource_type)=='{TaggableResourceTypes.PIPELINE.value}', foreign(TagResourceSchema.resource_id)==PipelineSchema.id)",
101
+ secondary="tag_resource",
102
+ secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)",
103
+ order_by="TagSchema.name",
102
104
  overlaps="tags",
103
105
  ),
104
106
  )
@@ -162,7 +164,7 @@ class PipelineSchema(NamedSchema, table=True):
162
164
  latest_run_user=latest_run_user.to_model()
163
165
  if latest_run_user
164
166
  else None,
165
- tags=[t.tag.to_model() for t in self.tags],
167
+ tags=[tag.to_model() for tag in self.tags],
166
168
  )
167
169
 
168
170
  return PipelineResponse(
@@ -13,13 +13,12 @@
13
13
  # permissions and limitations under the License.
14
14
  """SQLModel implementation of pipeline run metadata tables."""
15
15
 
16
- from typing import TYPE_CHECKING, List, Optional
16
+ from typing import Optional
17
17
  from uuid import UUID, uuid4
18
18
 
19
19
  from sqlalchemy import TEXT, VARCHAR, Column
20
20
  from sqlmodel import Field, Relationship, SQLModel
21
21
 
22
- from zenml.enums import MetadataResourceTypes
23
22
  from zenml.zen_stores.schemas.base_schemas import BaseSchema
24
23
  from zenml.zen_stores.schemas.component_schemas import StackComponentSchema
25
24
  from zenml.zen_stores.schemas.schema_utils import build_foreign_key_field
@@ -27,22 +26,12 @@ from zenml.zen_stores.schemas.step_run_schemas import StepRunSchema
27
26
  from zenml.zen_stores.schemas.user_schemas import UserSchema
28
27
  from zenml.zen_stores.schemas.workspace_schemas import WorkspaceSchema
29
28
 
30
- if TYPE_CHECKING:
31
- from zenml.zen_stores.schemas.artifact_schemas import ArtifactVersionSchema
32
- from zenml.zen_stores.schemas.model_schemas import ModelVersionSchema
33
- from zenml.zen_stores.schemas.pipeline_run_schemas import PipelineRunSchema
34
-
35
29
 
36
30
  class RunMetadataSchema(BaseSchema, table=True):
37
31
  """SQL Model for run metadata."""
38
32
 
39
33
  __tablename__ = "run_metadata"
40
34
 
41
- # Relationship to link to resources
42
- resources: List["RunMetadataResourceSchema"] = Relationship(
43
- back_populates="run_metadata",
44
- sa_relationship_kwargs={"cascade": "delete"},
45
- )
46
35
  stack_component_id: Optional[UUID] = build_foreign_key_field(
47
36
  source=__tablename__,
48
37
  target=StackComponentSchema.__tablename__,
@@ -105,36 +94,3 @@ class RunMetadataResourceSchema(SQLModel, table=True):
105
94
  ondelete="CASCADE",
106
95
  nullable=False,
107
96
  )
108
-
109
- # Relationship back to the base metadata table
110
- run_metadata: RunMetadataSchema = Relationship(back_populates="resources")
111
-
112
- # Relationship to link specific resource types
113
- pipeline_runs: List["PipelineRunSchema"] = Relationship(
114
- back_populates="run_metadata_resources",
115
- sa_relationship_kwargs=dict(
116
- primaryjoin=f"and_(RunMetadataResourceSchema.resource_type=='{MetadataResourceTypes.PIPELINE_RUN.value}', foreign(RunMetadataResourceSchema.resource_id)==PipelineRunSchema.id)",
117
- overlaps="run_metadata_resources,step_runs,artifact_versions,model_versions",
118
- ),
119
- )
120
- step_runs: List["StepRunSchema"] = Relationship(
121
- back_populates="run_metadata_resources",
122
- sa_relationship_kwargs=dict(
123
- primaryjoin=f"and_(RunMetadataResourceSchema.resource_type=='{MetadataResourceTypes.STEP_RUN.value}', foreign(RunMetadataResourceSchema.resource_id)==StepRunSchema.id)",
124
- overlaps="run_metadata_resources,pipeline_runs,artifact_versions,model_versions",
125
- ),
126
- )
127
- artifact_versions: List["ArtifactVersionSchema"] = Relationship(
128
- back_populates="run_metadata_resources",
129
- sa_relationship_kwargs=dict(
130
- primaryjoin=f"and_(RunMetadataResourceSchema.resource_type=='{MetadataResourceTypes.ARTIFACT_VERSION.value}', foreign(RunMetadataResourceSchema.resource_id)==ArtifactVersionSchema.id)",
131
- overlaps="run_metadata_resources,pipeline_runs,step_runs,model_versions",
132
- ),
133
- )
134
- model_versions: List["ModelVersionSchema"] = Relationship(
135
- back_populates="run_metadata_resources",
136
- sa_relationship_kwargs=dict(
137
- primaryjoin=f"and_(RunMetadataResourceSchema.resource_type=='{MetadataResourceTypes.MODEL_VERSION.value}', foreign(RunMetadataResourceSchema.resource_id)==ModelVersionSchema.id)",
138
- overlaps="run_metadata_resources,pipeline_runs,step_runs,artifact_versions",
139
- ),
140
- )
@@ -41,7 +41,7 @@ if TYPE_CHECKING:
41
41
  PipelineDeploymentSchema,
42
42
  )
43
43
  from zenml.zen_stores.schemas.pipeline_run_schemas import PipelineRunSchema
44
- from zenml.zen_stores.schemas.tag_schemas import TagResourceSchema
44
+ from zenml.zen_stores.schemas.tag_schemas import TagSchema
45
45
 
46
46
 
47
47
  class RunTemplateSchema(BaseSchema, table=True):
@@ -110,10 +110,12 @@ class RunTemplateSchema(BaseSchema, table=True):
110
110
  }
111
111
  )
112
112
 
113
- tags: List["TagResourceSchema"] = Relationship(
113
+ tags: List["TagSchema"] = Relationship(
114
114
  sa_relationship_kwargs=dict(
115
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.RUN_TEMPLATE.value}', foreign(TagResourceSchema.resource_id)==RunTemplateSchema.id)",
116
- cascade="delete",
115
+ primaryjoin=f"and_(foreign(TagResourceSchema.resource_type)=='{TaggableResourceTypes.RUN_TEMPLATE.value}', foreign(TagResourceSchema.resource_id)==RunTemplateSchema.id)",
116
+ secondary="tag_resource",
117
+ secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)",
118
+ order_by="TagSchema.name",
117
119
  overlaps="tags",
118
120
  ),
119
121
  )
@@ -253,7 +255,7 @@ class RunTemplateSchema(BaseSchema, table=True):
253
255
  pipeline=pipeline,
254
256
  build=build,
255
257
  code_reference=code_reference,
256
- tags=[t.tag.to_model() for t in self.tags],
258
+ tags=[tag.to_model() for tag in self.tags],
257
259
  )
258
260
 
259
261
  return RunTemplateResponse(
@@ -58,9 +58,7 @@ if TYPE_CHECKING:
58
58
  from zenml.zen_stores.schemas.artifact_schemas import ArtifactVersionSchema
59
59
  from zenml.zen_stores.schemas.logs_schemas import LogsSchema
60
60
  from zenml.zen_stores.schemas.model_schemas import ModelVersionSchema
61
- from zenml.zen_stores.schemas.run_metadata_schemas import (
62
- RunMetadataResourceSchema,
63
- )
61
+ from zenml.zen_stores.schemas.run_metadata_schemas import RunMetadataSchema
64
62
 
65
63
 
66
64
  class StepRunSchema(NamedSchema, RunMetadataInterface, table=True):
@@ -150,12 +148,12 @@ class StepRunSchema(NamedSchema, RunMetadataInterface, table=True):
150
148
  deployment: Optional["PipelineDeploymentSchema"] = Relationship(
151
149
  back_populates="step_runs"
152
150
  )
153
- run_metadata_resources: List["RunMetadataResourceSchema"] = Relationship(
154
- back_populates="step_runs",
151
+ run_metadata: List["RunMetadataSchema"] = Relationship(
155
152
  sa_relationship_kwargs=dict(
156
- primaryjoin=f"and_(RunMetadataResourceSchema.resource_type=='{MetadataResourceTypes.STEP_RUN.value}', foreign(RunMetadataResourceSchema.resource_id)==StepRunSchema.id)",
157
- cascade="delete",
158
- overlaps="run_metadata_resources",
153
+ secondary="run_metadata_resource",
154
+ primaryjoin=f"and_(foreign(RunMetadataResourceSchema.resource_type)=='{MetadataResourceTypes.STEP_RUN.value}', foreign(RunMetadataResourceSchema.resource_id)==StepRunSchema.id)",
155
+ secondaryjoin="RunMetadataSchema.id==foreign(RunMetadataResourceSchema.run_metadata_id)",
156
+ overlaps="run_metadata",
159
157
  ),
160
158
  )
161
159
  input_artifacts: List["StepRunInputArtifactSchema"] = Relationship(
@@ -14,7 +14,7 @@
14
14
  """SQLModel implementation of tag tables."""
15
15
 
16
16
  from datetime import datetime
17
- from typing import TYPE_CHECKING, Any, List
17
+ from typing import Any, List
18
18
  from uuid import UUID
19
19
 
20
20
  from sqlalchemy import VARCHAR, Column
@@ -33,16 +33,6 @@ from zenml.models import (
33
33
  from zenml.zen_stores.schemas.base_schemas import BaseSchema, NamedSchema
34
34
  from zenml.zen_stores.schemas.schema_utils import build_foreign_key_field
35
35
 
36
- if TYPE_CHECKING:
37
- from zenml.zen_stores.schemas.artifact_schemas import (
38
- ArtifactSchema,
39
- ArtifactVersionSchema,
40
- )
41
- from zenml.zen_stores.schemas.model_schemas import (
42
- ModelSchema,
43
- ModelVersionSchema,
44
- )
45
-
46
36
 
47
37
  class TagSchema(NamedSchema, table=True):
48
38
  """SQL Model for tag."""
@@ -52,7 +42,7 @@ class TagSchema(NamedSchema, table=True):
52
42
  color: str = Field(sa_column=Column(VARCHAR(255), nullable=False))
53
43
  links: List["TagResourceSchema"] = Relationship(
54
44
  back_populates="tag",
55
- sa_relationship_kwargs={"cascade": "delete"},
45
+ sa_relationship_kwargs={"overlaps": "tags", "cascade": "delete"},
56
46
  )
57
47
 
58
48
  @classmethod
@@ -130,37 +120,11 @@ class TagResourceSchema(BaseSchema, table=True):
130
120
  ondelete="CASCADE",
131
121
  nullable=False,
132
122
  )
133
- tag: "TagSchema" = Relationship(back_populates="links")
123
+ tag: "TagSchema" = Relationship(
124
+ back_populates="links", sa_relationship_kwargs={"overlaps": "tags"}
125
+ )
134
126
  resource_id: UUID
135
127
  resource_type: str = Field(sa_column=Column(VARCHAR(255), nullable=False))
136
- artifact: List["ArtifactSchema"] = Relationship(
137
- back_populates="tags",
138
- sa_relationship_kwargs=dict(
139
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.ARTIFACT.value}', foreign(TagResourceSchema.resource_id)==ArtifactSchema.id)",
140
- overlaps="tags,model,artifact_version,model_version",
141
- ),
142
- )
143
- artifact_version: List["ArtifactVersionSchema"] = Relationship(
144
- back_populates="tags",
145
- sa_relationship_kwargs=dict(
146
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.ARTIFACT_VERSION.value}', foreign(TagResourceSchema.resource_id)==ArtifactVersionSchema.id)",
147
- overlaps="tags,model,artifact,model_version",
148
- ),
149
- )
150
- model: List["ModelSchema"] = Relationship(
151
- back_populates="tags",
152
- sa_relationship_kwargs=dict(
153
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.MODEL.value}', foreign(TagResourceSchema.resource_id)==ModelSchema.id)",
154
- overlaps="tags,artifact,artifact_version,model_version",
155
- ),
156
- )
157
- model_version: List["ModelVersionSchema"] = Relationship(
158
- back_populates="tags",
159
- sa_relationship_kwargs=dict(
160
- primaryjoin=f"and_(TagResourceSchema.resource_type=='{TaggableResourceTypes.MODEL_VERSION.value}', foreign(TagResourceSchema.resource_id)==ModelVersionSchema.id)",
161
- overlaps="tags,model,artifact,artifact_version",
162
- ),
163
- )
164
128
 
165
129
  @classmethod
166
130
  def from_request(cls, request: TagResourceRequest) -> "TagResourceSchema":
@@ -75,35 +75,34 @@ def get_page_from_list(
75
75
  class RunMetadataInterface:
76
76
  """The interface for entities with run metadata."""
77
77
 
78
- run_metadata_resources = Relationship()
78
+ run_metadata = Relationship()
79
79
 
80
80
  def fetch_metadata_collection(self) -> Dict[str, List[RunMetadataEntry]]:
81
- """Fetches all the metadata entries related to the artifact version.
81
+ """Fetches all the metadata entries related to the entity.
82
82
 
83
83
  Returns:
84
- a dictionary, where the key is the key of the metadata entry
84
+ A dictionary, where the key is the key of the metadata entry
85
85
  and the values represent the list of entries with this key.
86
86
  """
87
87
  metadata_collection: Dict[str, List[RunMetadataEntry]] = {}
88
88
 
89
- # Fetch the metadata related to this step
90
- for rm in self.run_metadata_resources:
91
- if rm.run_metadata.key not in metadata_collection:
92
- metadata_collection[rm.run_metadata.key] = []
93
- metadata_collection[rm.run_metadata.key].append(
89
+ for rm in self.run_metadata:
90
+ if rm.key not in metadata_collection:
91
+ metadata_collection[rm.key] = []
92
+ metadata_collection[rm.key].append(
94
93
  RunMetadataEntry(
95
- value=json.loads(rm.run_metadata.value),
96
- created=rm.run_metadata.created,
94
+ value=json.loads(rm.value),
95
+ created=rm.created,
97
96
  )
98
97
  )
99
98
 
100
99
  return metadata_collection
101
100
 
102
101
  def fetch_metadata(self) -> Dict[str, MetadataType]:
103
- """Fetches the latest metadata entry related to the artifact version.
102
+ """Fetches the latest metadata entry related to the entity.
104
103
 
105
104
  Returns:
106
- a dictionary, where the key is the key of the metadata entry
105
+ A dictionary, where the key is the key of the metadata entry
107
106
  and the values represent the latest entry with this key.
108
107
  """
109
108
  metadata_collection = self.fetch_metadata_collection()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: zenml-nightly
3
- Version: 0.71.0.dev20250107
3
+ Version: 0.71.0.dev20250109
4
4
  Summary: ZenML: Write production-ready ML code.
5
5
  Home-page: https://zenml.io
6
6
  License: Apache-2.0
@@ -1,5 +1,5 @@
1
1
  zenml/README.md,sha256=827dekbOWAs1BpW7VF1a4d7EbwPbjwccX-2zdXBENZo,1777
2
- zenml/VERSION,sha256=ZmTNiDD3JR5Qwuxek0Le9CzoLG1ltLJ1W8ncqdBnfgA,19
2
+ zenml/VERSION,sha256=8oW6HhS0djZCgMNPAt1wLpcgotMUxwZWgv2UhlMIvRI,19
3
3
  zenml/__init__.py,sha256=SkMObQA41ajqdZqGErN00S1Vf3KAxpLvbZ-OBy5uYoo,2130
4
4
  zenml/actions/__init__.py,sha256=mrt6wPo73iKRxK754_NqsGyJ3buW7RnVeIGXr1xEw8Y,681
5
5
  zenml/actions/base_action.py,sha256=UcaHev6BTuLDwuswnyaPjdA8AgUqB5xPZ-lRtuvf2FU,25553
@@ -618,7 +618,7 @@ zenml/models/v2/base/base.py,sha256=tXzNTIwGNz7MEgfii3-6ASBNFg4SkR9D9ZM48tlNr84,
618
618
  zenml/models/v2/base/base_plugin_flavor.py,sha256=BfPL4gm5i7ad7_vuRmPtC-rE2kl0W_8SmpWme8Akv1c,2608
619
619
  zenml/models/v2/base/filter.py,sha256=uCZa3MFdEmUL91DYa43vZVuHYBQDC-z3gZWUzzqd63U,36990
620
620
  zenml/models/v2/base/page.py,sha256=yBpWB-8iUmyRwXKSJvX3v9SB7WOnyRa25O8SAss24xk,2601
621
- zenml/models/v2/base/scoped.py,sha256=5HsIcDib4fkwsSPFJFyswPgH9JM325M71n4MRfhkb9A,17149
621
+ zenml/models/v2/base/scoped.py,sha256=KjK8zLMCJsd2C8e5Hra5IG6p3yh-BLd6vI7M_za1A4E,17210
622
622
  zenml/models/v2/core/__init__.py,sha256=LGMIUJi19sOsvo54roZSQwDp_czNQYtenqd_frTLIhU,613
623
623
  zenml/models/v2/core/action.py,sha256=6n6Lep_2-OVUDCWs6eKiUHFKLvcoMjHWP4ZSbua1JRY,7911
624
624
  zenml/models/v2/core/action_flavor.py,sha256=DlGlJTOcgLSDYAsrbAyXOJVdo7X2GYTFQTTEG5BEf-Q,1718
@@ -1242,7 +1242,7 @@ zenml/zen_stores/rest_zen_store.py,sha256=PRbKEqFZNvlj_TIZnVuUJBba08N03yBz3Ycstk
1242
1242
  zenml/zen_stores/schemas/__init__.py,sha256=vMb0Pyf94aMWZDWpPKuRaxNoMsTp9DZNKSQScm9Vd5I,4339
1243
1243
  zenml/zen_stores/schemas/action_schemas.py,sha256=vNnDF4zRy0eWgNwtcU7yY0JXyqe4I3Nns2LHRHWwiDs,6293
1244
1244
  zenml/zen_stores/schemas/api_key_schemas.py,sha256=pCvoTSXSHz-im6aRt-opSBnmIhw3wDRIsi-NJP5WtCQ,7243
1245
- zenml/zen_stores/schemas/artifact_schemas.py,sha256=UN5BW1MjAENNAyX6HCrL5KqcPlOPZ-CLtJNcPvRMNkU,14121
1245
+ zenml/zen_stores/schemas/artifact_schemas.py,sha256=s3Lf_GElGP7jpguGkS3KTDxnvO6nLs6q5RObdcytOMw,14320
1246
1246
  zenml/zen_stores/schemas/artifact_visualization_schemas.py,sha256=_gMNjOF0oJ0ruW5Ua86hDocvO4MT3ACAIx_BwFBJFWk,3693
1247
1247
  zenml/zen_stores/schemas/base_schemas.py,sha256=T3d2IioA2XcCoeaHfEb_mp51ai1djegAi9BIHRE18s0,2015
1248
1248
  zenml/zen_stores/schemas/code_repository_schemas.py,sha256=_v-HozD6UbyQgnQ_u4jo2vFsbWzUnQCMARTz4XEyhq0,7405
@@ -1252,13 +1252,13 @@ zenml/zen_stores/schemas/device_schemas.py,sha256=m_P601TtB6thBpjf8muwI2X6INC-LC
1252
1252
  zenml/zen_stores/schemas/event_source_schemas.py,sha256=3CLt-TfJFQF-xJ6j5UnBFhNXMQTM-pLdIBazghyGmQw,6386
1253
1253
  zenml/zen_stores/schemas/flavor_schemas.py,sha256=LYAcoJeUX-Z87a0HYFwamhjf_wvMsTBcqY5z5232Jos,5049
1254
1254
  zenml/zen_stores/schemas/logs_schemas.py,sha256=qv6fs3JiVgzlmTXJqb_gG5NsU5q_50e0167JiWIxR14,3588
1255
- zenml/zen_stores/schemas/model_schemas.py,sha256=TuRJ9oWFBg4WXfLuNgqjPidULNRrwshpel3dmbpMxzs,24557
1255
+ zenml/zen_stores/schemas/model_schemas.py,sha256=2OgJU4OmykNtfsYS1W-y5DgTcBJed-J9I7FvmfpjYHw,24773
1256
1256
  zenml/zen_stores/schemas/pipeline_build_schemas.py,sha256=QK3sVPYhumUx_x-H3YZ-RfnsxGhKfkMGdP5FC9WrQgU,5718
1257
1257
  zenml/zen_stores/schemas/pipeline_deployment_schemas.py,sha256=fdsROPBE1QrWKvSkaZYz2Sc1MwXogAembs8TfZML3ks,10201
1258
- zenml/zen_stores/schemas/pipeline_run_schemas.py,sha256=24Iw9E5FJHHFilvNat0y5cVP2NNLR2LmmDs9C8wb5tU,17519
1259
- zenml/zen_stores/schemas/pipeline_schemas.py,sha256=GSQBcpM5nSFH4vxfOOSJoIXjoNf9wuNlbLHVVLcsJBA,6242
1260
- zenml/zen_stores/schemas/run_metadata_schemas.py,sha256=vaTZMyX5Rem0sles5-DGExkW_qTiqTSwMcm_F4p9iqk,5848
1261
- zenml/zen_stores/schemas/run_template_schemas.py,sha256=4uE7lHkIQROJRNpNdvATwEJMkeij6pXnHvOsT3q3VrI,8826
1258
+ zenml/zen_stores/schemas/pipeline_run_schemas.py,sha256=WpM45TGhCWX_3Xm2fMIrKoO17D4vQ8ckuAmFM4Z2Lxc,17692
1259
+ zenml/zen_stores/schemas/pipeline_schemas.py,sha256=_ySrNVoKhZa0lAt4lfdwCr3Xy68JByEdLCILD_3MDlA,6361
1260
+ zenml/zen_stores/schemas/run_metadata_schemas.py,sha256=hP3tQ_OyH-ga6Whl6_5Yy8W0BkwBWXT2camu2X6gXL0,3362
1261
+ zenml/zen_stores/schemas/run_template_schemas.py,sha256=eEWD5DO2QsmrQ25SaegEUOO5pPefRl6OoizKyyUkg64,8945
1262
1262
  zenml/zen_stores/schemas/schedule_schema.py,sha256=w3tAHt2mEQ7ILPz4ogRdLV4KivB7E2LtIZWkzXLzAIU,7354
1263
1263
  zenml/zen_stores/schemas/schema_utils.py,sha256=2qPNPfasnTmCW1RPeViXoTAp6oO-uRnUpEZ_rugcoNw,2612
1264
1264
  zenml/zen_stores/schemas/secret_schemas.py,sha256=nRzFkgR940BbS1nlBs4H3YuvFCiGGYZ1vQIsu3Y0Mvk,9884
@@ -1266,11 +1266,11 @@ zenml/zen_stores/schemas/server_settings_schemas.py,sha256=bwrmK4Aj9_G13-L5vxVf5
1266
1266
  zenml/zen_stores/schemas/service_connector_schemas.py,sha256=yDDpgRRkghlrzNS-fIGCmffZoSuvi_w0ItIVu1asHU8,10061
1267
1267
  zenml/zen_stores/schemas/service_schemas.py,sha256=YNDCCfmHTNw3uA_48RJ2xbShJN30zSW_IEMw_4Jt2CQ,9609
1268
1268
  zenml/zen_stores/schemas/stack_schemas.py,sha256=PakmqLso3c-xS4dHtDm5GteaZt1mcap_12i7uSaMWFU,5579
1269
- zenml/zen_stores/schemas/step_run_schemas.py,sha256=PKITQ6ASuPMoYmQS30xuSEVrsiVwirYPCSF4AnaVEog,16408
1270
- zenml/zen_stores/schemas/tag_schemas.py,sha256=EckggyFUTO71aWXTktVJWXyaycdtuq-PGkX1u71tolY,6904
1269
+ zenml/zen_stores/schemas/step_run_schemas.py,sha256=8L_N1n5QJA611RzeXTydhhG4ngu-XBpQZdZ-L4mOEsc,16447
1270
+ zenml/zen_stores/schemas/tag_schemas.py,sha256=Jcgttjw6_6aQ-RDQ-y2u-aXvWaaVbaKXb04RLnrVPOA,5206
1271
1271
  zenml/zen_stores/schemas/trigger_schemas.py,sha256=yjfQilHGYYe8f3JzEsB0HapX3vg4nXr8VljzLyRAckI,10573
1272
1272
  zenml/zen_stores/schemas/user_schemas.py,sha256=v2ryKyohUywOMy3kW24lFmNPjq3-RCoZVriXDrjgb8c,10813
1273
- zenml/zen_stores/schemas/utils.py,sha256=PuLcik9-qiwV97mbCtumMVfTo9P52Eb9mzAtfl0UhzY,3780
1273
+ zenml/zen_stores/schemas/utils.py,sha256=lAhxBn21ljBp4aVol0MiZfRyQrW3RbWAOVfYFcdrxvA,3625
1274
1274
  zenml/zen_stores/schemas/workspace_schemas.py,sha256=NCHQ72OGYpCIF74jFnXAw_5L969ah8Z8kUgEclOCSGE,6677
1275
1275
  zenml/zen_stores/secrets_stores/__init__.py,sha256=VGMVerFv3xUWxnp5X_bHyQJwGCeN7BTovUDwho_w-4w,651
1276
1276
  zenml/zen_stores/secrets_stores/aws_secrets_store.py,sha256=o2kftfG0nr6oTodEDHWYvSK6zKbs1WGfqgMd5bJ4k0k,13799
@@ -1284,8 +1284,8 @@ zenml/zen_stores/secrets_stores/sql_secrets_store.py,sha256=Bq1djrUP9saoD7vECjS7
1284
1284
  zenml/zen_stores/sql_zen_store.py,sha256=8f3ZKcbK00ozjS0bBSsoBs8COfuoKeUGqEfi6Nqaw18,416026
1285
1285
  zenml/zen_stores/template_utils.py,sha256=EKYBgmDLTS_PSMWaIO5yvHPLiQvMqHcsAe6NUCrv-i4,9068
1286
1286
  zenml/zen_stores/zen_store_interface.py,sha256=vf2gKBWfUUPtcGZC35oQB6pPNVzWVyQC8nWxVLjfrxM,92692
1287
- zenml_nightly-0.71.0.dev20250107.dist-info/LICENSE,sha256=wbnfEnXnafPbqwANHkV6LUsPKOtdpsd-SNw37rogLtc,11359
1288
- zenml_nightly-0.71.0.dev20250107.dist-info/METADATA,sha256=LGuSXTUMsyd9NOBEb--cCTEFVm-Px4kqzqg5qFr-nEg,21215
1289
- zenml_nightly-0.71.0.dev20250107.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
1290
- zenml_nightly-0.71.0.dev20250107.dist-info/entry_points.txt,sha256=QK3ETQE0YswAM2mWypNMOv8TLtr7EjnqAFq1br_jEFE,43
1291
- zenml_nightly-0.71.0.dev20250107.dist-info/RECORD,,
1287
+ zenml_nightly-0.71.0.dev20250109.dist-info/LICENSE,sha256=wbnfEnXnafPbqwANHkV6LUsPKOtdpsd-SNw37rogLtc,11359
1288
+ zenml_nightly-0.71.0.dev20250109.dist-info/METADATA,sha256=4cBQZcG07_lCaCaUDfysWPA26XejSp0irfImrF6mV08,21215
1289
+ zenml_nightly-0.71.0.dev20250109.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
1290
+ zenml_nightly-0.71.0.dev20250109.dist-info/entry_points.txt,sha256=QK3ETQE0YswAM2mWypNMOv8TLtr7EjnqAFq1br_jEFE,43
1291
+ zenml_nightly-0.71.0.dev20250109.dist-info/RECORD,,