Skip to content

Commit

Permalink
♻️ This one loads fine
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf committed Jan 5, 2025
1 parent ab5524c commit 1fe973d
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lamindb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def __get_name_with_schema__(cls) -> str:
return f"{schema_prefix}{cls.__name__}"


class LinkORM(models.Model):
class RecordNoPage(models.Model, metaclass=Registry):
"""Class to label link ORMs.
It behaves like Record but doesn't have the _page_md field.
Expand Down Expand Up @@ -1261,7 +1261,7 @@ class Meta(Record.Meta, TracksRun.Meta, TracksUpdates.Meta):
# Also, we don't inherit from TracksRun because a ParamValue
# is typically created before a run is created and we want to
# avoid delete cycles (for Model params though it might be helpful)
class ParamValue(LinkORM):
class ParamValue(RecordNoPage):
"""Parameter values.
Is largely analogous to `FeatureValue`.
Expand Down Expand Up @@ -1701,7 +1701,7 @@ def save(self, *args, **kwargs) -> Feature:

# FeatureValue behaves in many ways like a link in a LinkORM
# in particular, we don't want a _page_md field on it
class FeatureValue(LinkORM, TracksRun):
class FeatureValue(RecordNoPage, TracksRun):
"""Non-categorical features values.
Categorical feature values are stored in their respective registries:
Expand All @@ -1718,7 +1718,7 @@ class FeatureValue(LinkORM, TracksRun):
# there does not seem an issue with querying for a dict-like value
# https://lamin.ai/laminlabs/lamindata/transform/jgTrkoeuxAfs0001

class Meta(LinkORM.Meta, TracksRun.Meta):
class Meta(RecordNoPage.Meta, TracksRun.Meta):
abstract = False

_name_field: str = "value"
Expand Down Expand Up @@ -2856,11 +2856,15 @@ def describe(self) -> None:
# Link models


class LinkORM:
pass


class ValidateFields:
pass


class FeatureSetFeature(LinkORM):
class FeatureSetFeature(RecordNoPage, LinkORM):
id: int = models.BigAutoField(primary_key=True)
# we follow the lower() case convention rather than snake case for link models
featureset: FeatureSet = ForeignKey(FeatureSet, CASCADE, related_name="+")
Expand All @@ -2870,7 +2874,7 @@ class Meta:
unique_together = ("featureset", "feature")


class ArtifactFeatureSet(LinkORM, TracksRun):
class ArtifactFeatureSet(RecordNoPage, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
artifact: Artifact = ForeignKey(Artifact, CASCADE, related_name="links_feature_set")
# we follow the lower() case convention rather than snake case for link models
Expand All @@ -2886,7 +2890,7 @@ class Meta:
unique_together = ("artifact", "featureset")


class CollectionArtifact(LinkORM, TracksRun):
class CollectionArtifact(RecordNoPage, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
collection: Collection = ForeignKey(
Collection, CASCADE, related_name="links_artifact"
Expand All @@ -2897,7 +2901,7 @@ class Meta:
unique_together = ("collection", "artifact")


class ArtifactULabel(LinkORM, TracksRun):
class ArtifactULabel(RecordNoPage, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
artifact: Artifact = ForeignKey(Artifact, CASCADE, related_name="links_ulabel")
ulabel: ULabel = ForeignKey(ULabel, PROTECT, related_name="links_artifact")
Expand All @@ -2913,7 +2917,7 @@ class Meta:
unique_together = ("artifact", "ulabel", "feature")


class CollectionULabel(LinkORM, TracksRun):
class CollectionULabel(RecordNoPage, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
collection: Collection = ForeignKey(
Collection, CASCADE, related_name="links_ulabel"
Expand All @@ -2929,7 +2933,7 @@ class Meta:
unique_together = ("collection", "ulabel")


class ArtifactFeatureValue(LinkORM, TracksRun):
class ArtifactFeatureValue(RecordNoPage, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
artifact: Artifact = ForeignKey(Artifact, CASCADE, related_name="+")
# we follow the lower() case convention rather than snake case for link models
Expand All @@ -2939,7 +2943,7 @@ class Meta:
unique_together = ("artifact", "featurevalue")


class RunParamValue(LinkORM):
class RunParamValue(RecordNoPage, LinkORM):
id: int = models.BigAutoField(primary_key=True)
run: Run = ForeignKey(Run, CASCADE, related_name="+")
# we follow the lower() case convention rather than snake case for link models
Expand All @@ -2949,7 +2953,7 @@ class Meta:
unique_together = ("run", "paramvalue")


class ArtifactParamValue(LinkORM):
class ArtifactParamValue(RecordNoPage, LinkORM):
id: int = models.BigAutoField(primary_key=True)
artifact: Artifact = ForeignKey(Artifact, CASCADE, related_name="+")
# we follow the lower() case convention rather than snake case for link models
Expand Down

0 comments on commit 1fe973d

Please sign in to comment.