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

Commit

Permalink
🔥 Remove linking collections to feature sets (#428)
Browse files Browse the repository at this point in the history
* 🔥 Remove linking collections to feature sets

* ♻️ Simplify FeatureManager
  • Loading branch information
falexwolf authored Sep 8, 2024
1 parent 26592c1 commit ad766b3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.2 on 2024-09-08 11:37

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
(
"lnschema_core",
"0064_alter_artifact_version_alter_collection_version_and_more",
),
]

operations = [
migrations.RemoveField(
model_name="collection",
name="feature_sets",
),
migrations.DeleteModel(
name="CollectionFeatureSet",
),
]
37 changes: 1 addition & 36 deletions lnschema_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,18 +772,6 @@ class ParamManager:
pass


class FeatureManagerArtifact(FeatureManager):
"""Feature manager."""

pass


class FeatureManagerCollection(FeatureManager):
"""Feature manager."""

pass


class ParamManagerArtifact(ParamManager):
"""Param manager."""

Expand Down Expand Up @@ -1848,7 +1836,7 @@ class Meta(Record.Meta, IsVersioned.Meta, TracksRun.Meta, TracksUpdates.Meta):
})
"""

features: FeatureManager = FeatureManagerArtifact # type: ignore
features: FeatureManager = FeatureManager # type: ignore
"""Feature manager.
Features denote dataset dimensions, i.e., the variables that measure labels & numbers.
Expand Down Expand Up @@ -2402,7 +2390,6 @@ class Meta(Record.Meta, IsVersioned.Meta, TracksRun.Meta, TracksUpdates.Meta):

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

id: int = models.AutoField(primary_key=True)
Expand All @@ -2426,10 +2413,6 @@ class Meta(Record.Meta, IsVersioned.Meta, TracksRun.Meta, TracksUpdates.Meta):
max_length=25, db_index=True, null=True, default=None
)
"""Type of reference, e.g., cellxgene Census collection_id."""
feature_sets: FeatureSet = models.ManyToManyField(
"FeatureSet", related_name="collections", through="CollectionFeatureSet"
)
"""The feature sets measured in this collection (see :class:`~lamindb.FeatureSet`)."""
ulabels: ULabel = models.ManyToManyField(
"ULabel", through="CollectionULabel", related_name="collections"
)
Expand Down Expand Up @@ -2687,24 +2670,6 @@ class Meta:
unique_together = ("artifact", "featureset")


class CollectionFeatureSet(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
collection = models.ForeignKey(
Collection, CASCADE, related_name="links_feature_set"
)
# we follow the lower() case convention rather than snake case for link models
featureset: FeatureSet = models.ForeignKey(
FeatureSet, PROTECT, related_name="links_collection"
)
slot: str = CharField(max_length=50, null=True, default=None)
feature_ref_is_semantic: bool = models.BooleanField(
null=True, default=None
) # like Feature name or Gene symbol or CellMarker name

class Meta:
unique_together = ("collection", "featureset")


class CollectionArtifact(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
collection: Collection = models.ForeignKey(
Expand Down

0 comments on commit ad766b3

Please sign in to comment.