Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

🚚 Use label_ref_is_name field in ULabel link tables #395

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.1 on 2024-07-09 12:50

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("lnschema_core", "0055_artifact_type_artifactparamvalue_and_more"),
]

operations = [
migrations.RenameField(
model_name="artifactulabel",
old_name="ulabel_ref_is_name",
new_name="label_ref_is_name",
),
migrations.RenameField(
model_name="collectionulabel",
old_name="ulabel_ref_is_name",
new_name="label_ref_is_name",
),
]
24 changes: 22 additions & 2 deletions lnschema_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,8 @@ class User(Registry, CanValidate):
>>> user
"""

_name_field: str = "handle"

id: int = models.AutoField(primary_key=True)
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, db_index=True, max_length=8, default=None)
Expand Down Expand Up @@ -1008,6 +1010,8 @@ class Storage(Registry, TracksRun, TracksUpdates):
class Meta(Registry.Meta, TracksRun.Meta, TracksUpdates.Meta):
abstract = False

_name_field: str = "root"

id: int = models.AutoField(primary_key=True)
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, max_length=12, default=base62_12, db_index=True)
Expand Down Expand Up @@ -1132,6 +1136,7 @@ class Meta(Registry.Meta, IsVersioned.Meta):

_len_stem_uid: int = 12
_len_full_uid: int = 16
_name_field: str = "name"

id: int = models.AutoField(primary_key=True)
"""Internal id, valid only in one DB instance."""
Expand Down Expand Up @@ -1213,6 +1218,8 @@ class Param(Registry, CanValidate, TracksRun, TracksUpdates):
class Meta(Registry.Meta, TracksRun.Meta, TracksUpdates.Meta):
abstract = False

_name_field: str = "name"

name: str = CharField(max_length=100, db_index=True)
dtype: str = CharField(max_length=64, db_index=True, default=None)
"""Data type ("number", "cat", "int", "float", "bool", "datetime").
Expand All @@ -1228,6 +1235,8 @@ class ParamValue(Registry):
class Meta:
unique_together = ("param", "value")

_name_field: str = "value"

param: Param = models.ForeignKey(Param, CASCADE)
value: Any = models.JSONField() # stores float, integer, boolean or datetime
# it'd be confusing and hard to populate a run here because these
Expand Down Expand Up @@ -1278,6 +1287,7 @@ class Run(Registry, HasParams):
>>> ln.core.context.run
"""

_name_field: str = "started_at"
params: ParamManager = ParamManagerRun # type: ignore

id: int = models.BigAutoField(primary_key=True)
Expand Down Expand Up @@ -1413,6 +1423,8 @@ class ULabel(Registry, HasParents, CanValidate, TracksRun, TracksUpdates):
class Meta(Registry.Meta, TracksRun.Meta, TracksUpdates.Meta):
abstract = False

_name_field: str = "name"

id: int = models.AutoField(primary_key=True)
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, db_index=True, max_length=8, default=base62_8)
Expand Down Expand Up @@ -1522,6 +1534,8 @@ class Feature(Registry, CanValidate, TracksRun, TracksUpdates):
class Meta(Registry.Meta, TracksRun.Meta, TracksUpdates.Meta):
abstract = False

_name_field: str = "name"

id: int = models.AutoField(primary_key=True)
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, db_index=True, max_length=12, default=base62_12)
Expand Down Expand Up @@ -1597,6 +1611,8 @@ class Meta(Registry.Meta, TracksRun.Meta):
abstract = False
unique_together = ("feature", "value")

_name_field: str = "value"

feature: Feature = models.ForeignKey(Feature, CASCADE, null=True, default=None)
value: Any = models.JSONField()

Expand Down Expand Up @@ -1673,6 +1689,8 @@ class FeatureSet(Registry, TracksRun):
class Meta(Registry.Meta, TracksRun.Meta, TracksUpdates.Meta):
abstract = False

_name_field: str = "name"

id: int = models.AutoField(primary_key=True)
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, db_index=True, max_length=20, default=None)
Expand Down Expand Up @@ -1886,6 +1904,7 @@ class Meta(Registry.Meta, IsVersioned.Meta, TracksRun.Meta, TracksUpdates.Meta):

_len_full_uid: int = 20
_len_stem_uid: int = 16
_name_field: str = "description"
features: FeatureManager = FeatureManagerArtifact # type: ignore
params: ParamManager = ParamManagerArtifact # type: ignore

Expand Down Expand Up @@ -2371,6 +2390,7 @@ class Meta(Registry.Meta, IsVersioned.Meta, TracksRun.Meta, TracksUpdates.Meta):

_len_full_uid: int = 20
_len_stem_uid: int = 16
_name_field: str = "name"
features = FeatureManagerCollection # type: ignore

id: int = models.AutoField(primary_key=True)
Expand Down Expand Up @@ -2662,7 +2682,7 @@ class ArtifactULabel(Registry, LinkORM, TracksRun):
feature = models.ForeignKey(
Feature, PROTECT, null=True, default=None, related_name="artifactulabel_links"
)
ulabel_ref_is_name: bool = models.BooleanField(null=True, default=None)
label_ref_is_name: bool = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool = models.BooleanField(null=True, default=None)

class Meta:
Expand All @@ -2678,7 +2698,7 @@ class CollectionULabel(Registry, LinkORM, TracksRun):
feature: Feature = models.ForeignKey(
Feature, PROTECT, null=True, default=None, related_name="collectionulabel_links"
)
ulabel_ref_is_name: bool = models.BooleanField(null=True, default=None)
label_ref_is_name: bool = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool = models.BooleanField(null=True, default=None)

class Meta:
Expand Down
Loading