From 0c92b8b032e7169872ef9f8dfa2e0caf263289ba Mon Sep 17 00:00:00 2001 From: Michael Schuster Date: Mon, 9 Dec 2024 11:17:59 +0100 Subject: [PATCH] Remove FK cycle --- src/zenml/zen_stores/schemas/model_schemas.py | 13 ++----------- .../zen_stores/schemas/pipeline_run_schemas.py | 3 --- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/zenml/zen_stores/schemas/model_schemas.py b/src/zenml/zen_stores/schemas/model_schemas.py index 93ecf08fc8..8f8cbedfda 100644 --- a/src/zenml/zen_stores/schemas/model_schemas.py +++ b/src/zenml/zen_stores/schemas/model_schemas.py @@ -333,9 +333,6 @@ class ModelVersionSchema(NamedSchema, RunMetadataInterface, table=True): ) pipeline_runs: List["PipelineRunSchema"] = Relationship( back_populates="model_version", - sa_relationship_kwargs={ - "primaryjoin": "ModelVersionSchema.id==PipelineRunSchema.model_version_id", - }, ) step_runs: List["StepRunSchema"] = Relationship( back_populates="model_version" @@ -345,14 +342,8 @@ class ModelVersionSchema(NamedSchema, RunMetadataInterface, table=True): sa_column=Column(Boolean, Computed("name == number")) ) - producer_run_id: Optional[UUID] = build_foreign_key_field( - source=__tablename__, - target=PipelineRunSchema.__tablename__, - source_column="producer_run_id", - target_column="id", - ondelete="SET NULL", - nullable=True, - ) + # Don't use a FK here to avoid a cycle + producer_run_id: Optional[UUID] = None # TODO: In Pydantic v2, the `model_` is a protected namespaces for all # fields defined under base models. If not handled, this raises a warning. diff --git a/src/zenml/zen_stores/schemas/pipeline_run_schemas.py b/src/zenml/zen_stores/schemas/pipeline_run_schemas.py index bad1156039..67236f0ab7 100644 --- a/src/zenml/zen_stores/schemas/pipeline_run_schemas.py +++ b/src/zenml/zen_stores/schemas/pipeline_run_schemas.py @@ -163,9 +163,6 @@ class PipelineRunSchema(NamedSchema, RunMetadataInterface, table=True): ) model_version: "ModelVersionSchema" = Relationship( back_populates="pipeline_runs", - sa_relationship_kwargs={ - "foreign_keys": "[PipelineRunSchema.model_version_id]" - }, ) # Temporary fields and foreign keys to be deprecated