Skip to content

Commit

Permalink
Make relationship viewonly to silence warning
Browse files Browse the repository at this point in the history
  • Loading branch information
schustmi committed Dec 13, 2024
1 parent d74e50e commit 85af44a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/zenml/zen_stores/schemas/artifact_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions src/zenml/zen_stores/schemas/model_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
),
)

Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions src/zenml/zen_stores/schemas/pipeline_run_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
),
)

Expand Down
1 change: 1 addition & 0 deletions src/zenml/zen_stores/schemas/pipeline_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)

Expand Down
8 changes: 7 additions & 1 deletion src/zenml/zen_stores/schemas/run_metadata_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/zenml/zen_stores/schemas/run_template_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)

Expand Down
1 change: 1 addition & 0 deletions src/zenml/zen_stores/schemas/step_run_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 85af44a

Please sign in to comment.