From 85af44afa3d7fadd95a5345db26055ab285db597 Mon Sep 17 00:00:00 2001 From: Michael Schuster Date: Fri, 13 Dec 2024 16:10:02 +0100 Subject: [PATCH] Make relationship viewonly to silence warning --- src/zenml/zen_stores/schemas/artifact_schemas.py | 3 +++ src/zenml/zen_stores/schemas/model_schemas.py | 3 +++ src/zenml/zen_stores/schemas/pipeline_run_schemas.py | 2 ++ src/zenml/zen_stores/schemas/pipeline_schemas.py | 1 + src/zenml/zen_stores/schemas/run_metadata_schemas.py | 8 +++++++- src/zenml/zen_stores/schemas/run_template_schemas.py | 1 + src/zenml/zen_stores/schemas/step_run_schemas.py | 1 + 7 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/zenml/zen_stores/schemas/artifact_schemas.py b/src/zenml/zen_stores/schemas/artifact_schemas.py index 16a24bf1cc..07a1309ff4 100644 --- a/src/zenml/zen_stores/schemas/artifact_schemas.py +++ b/src/zenml/zen_stores/schemas/artifact_schemas.py @@ -86,6 +86,7 @@ class ArtifactSchema(NamedSchema, table=True): secondary="tag_resource", secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)", order_by="TagSchema.name", + viewonly=True, ), ) @@ -196,6 +197,7 @@ class ArtifactVersionSchema(BaseSchema, RunMetadataInterface, table=True): secondary="tag_resource", secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)", order_by="TagSchema.name", + viewonly=True, ), ) save_type: str = Field(sa_column=Column(TEXT, nullable=False)) @@ -247,6 +249,7 @@ class ArtifactVersionSchema(BaseSchema, RunMetadataInterface, table=True): secondary="run_metadata_resource", primaryjoin=f"and_(foreign(RunMetadataResourceSchema.resource_type)=='{MetadataResourceTypes.ARTIFACT_VERSION.value}', foreign(RunMetadataResourceSchema.resource_id)==ArtifactVersionSchema.id)", secondaryjoin="RunMetadataSchema.id==foreign(RunMetadataResourceSchema.run_metadata_id)", + viewonly=True, ), ) output_of_step_runs: List["StepRunOutputArtifactSchema"] = Relationship( diff --git a/src/zenml/zen_stores/schemas/model_schemas.py b/src/zenml/zen_stores/schemas/model_schemas.py index 837b27a6c7..88adbf2bc4 100644 --- a/src/zenml/zen_stores/schemas/model_schemas.py +++ b/src/zenml/zen_stores/schemas/model_schemas.py @@ -118,6 +118,7 @@ class ModelSchema(NamedSchema, table=True): secondary="tag_resource", secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)", order_by="TagSchema.name", + viewonly=True, ), ) model_versions: List["ModelVersionSchema"] = Relationship( @@ -303,6 +304,7 @@ class ModelVersionSchema(NamedSchema, RunMetadataInterface, table=True): secondary="tag_resource", secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)", order_by="TagSchema.name", + viewonly=True, ), ) @@ -319,6 +321,7 @@ class ModelVersionSchema(NamedSchema, RunMetadataInterface, table=True): secondary="run_metadata_resource", primaryjoin=f"and_(foreign(RunMetadataResourceSchema.resource_type)=='{MetadataResourceTypes.MODEL_VERSION.value}', foreign(RunMetadataResourceSchema.resource_id)==ModelVersionSchema.id)", secondaryjoin="RunMetadataSchema.id==foreign(RunMetadataResourceSchema.run_metadata_id)", + viewonly=True, ), ) pipeline_runs: List["PipelineRunSchema"] = Relationship( diff --git a/src/zenml/zen_stores/schemas/pipeline_run_schemas.py b/src/zenml/zen_stores/schemas/pipeline_run_schemas.py index 7edfcb062e..459638e738 100644 --- a/src/zenml/zen_stores/schemas/pipeline_run_schemas.py +++ b/src/zenml/zen_stores/schemas/pipeline_run_schemas.py @@ -143,6 +143,7 @@ class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True): secondary="run_metadata_resource", primaryjoin=f"and_(foreign(RunMetadataResourceSchema.resource_type)=='{MetadataResourceTypes.PIPELINE_RUN.value}', foreign(RunMetadataResourceSchema.resource_id)==PipelineRunSchema.id)", secondaryjoin="RunMetadataSchema.id==foreign(RunMetadataResourceSchema.run_metadata_id)", + viewonly=True, ), ) logs: Optional["LogsSchema"] = Relationship( @@ -218,6 +219,7 @@ class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True): secondary="tag_resource", secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)", order_by="TagSchema.name", + viewonly=True, ), ) diff --git a/src/zenml/zen_stores/schemas/pipeline_schemas.py b/src/zenml/zen_stores/schemas/pipeline_schemas.py index 93b4265d76..7e991306f4 100644 --- a/src/zenml/zen_stores/schemas/pipeline_schemas.py +++ b/src/zenml/zen_stores/schemas/pipeline_schemas.py @@ -101,6 +101,7 @@ class PipelineSchema(NamedSchema, table=True): secondary="tag_resource", secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)", order_by="TagSchema.name", + viewonly=True, ), ) diff --git a/src/zenml/zen_stores/schemas/run_metadata_schemas.py b/src/zenml/zen_stores/schemas/run_metadata_schemas.py index f38d0bca93..a2f9fe24fc 100644 --- a/src/zenml/zen_stores/schemas/run_metadata_schemas.py +++ b/src/zenml/zen_stores/schemas/run_metadata_schemas.py @@ -16,7 +16,7 @@ from typing import List, Optional from uuid import UUID, uuid4 -from sqlalchemy import TEXT, VARCHAR, Column +from sqlalchemy import TEXT, VARCHAR, Column, Index from sqlmodel import Field, Relationship, SQLModel from zenml.zen_stores.schemas.base_schemas import BaseSchema @@ -87,6 +87,12 @@ class RunMetadataResourceSchema(SQLModel, table=True): """Table for linking resources to run metadata entries.""" __tablename__ = "run_metadata_resource" + __table_args__ = ( + Index( + "my_index" "resource_id", + "resource_type", + ), + ) id: UUID = Field(default_factory=uuid4, primary_key=True) resource_id: UUID diff --git a/src/zenml/zen_stores/schemas/run_template_schemas.py b/src/zenml/zen_stores/schemas/run_template_schemas.py index 26ad4d250b..3b3bbb0022 100644 --- a/src/zenml/zen_stores/schemas/run_template_schemas.py +++ b/src/zenml/zen_stores/schemas/run_template_schemas.py @@ -116,6 +116,7 @@ class RunTemplateSchema(BaseSchema, table=True): secondary="tag_resource", secondaryjoin="TagSchema.id == foreign(TagResourceSchema.tag_id)", order_by="TagSchema.name", + viewonly=True, ), ) diff --git a/src/zenml/zen_stores/schemas/step_run_schemas.py b/src/zenml/zen_stores/schemas/step_run_schemas.py index 396e951dcd..b6334101d5 100644 --- a/src/zenml/zen_stores/schemas/step_run_schemas.py +++ b/src/zenml/zen_stores/schemas/step_run_schemas.py @@ -153,6 +153,7 @@ class StepRunSchema(NamedSchema, RunMetadataInterface, table=True): secondary="run_metadata_resource", primaryjoin=f"and_(foreign(RunMetadataResourceSchema.resource_type)=='{MetadataResourceTypes.STEP_RUN.value}', foreign(RunMetadataResourceSchema.resource_id)==StepRunSchema.id)", secondaryjoin="RunMetadataSchema.id==foreign(RunMetadataResourceSchema.run_metadata_id)", + viewonly=True, ), ) input_artifacts: List["StepRunInputArtifactSchema"] = Relationship(