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

Commit

Permalink
✨ Enable listing of version family (#325)
Browse files Browse the repository at this point in the history
* ✨ Enable listing of version family

* 🎨 Change naming of versioning base class
  • Loading branch information
bpenteado authored Dec 20, 2023
1 parent 44ca40a commit adf38b7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lnschema_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,22 @@ def view_parents(
pass


class IsVersioned:
"""Base class for versioning methods."""

def versions(self):
"""Lists all records of the same version family.
Examples:
>>> new_artifact = ln.Artifact(df2, is_new_version_of=artifact)
>>> new_artifact.save()
>>> new_artifact.versions()
"""
from lamindb._filter import filter_version_family

return filter_version_family(self).all()


class Registry(models.Model):
"""Registry base class.
Expand Down Expand Up @@ -733,7 +749,7 @@ def path(self) -> Union[Path, UPath]:
pass


class Transform(Registry, HasParents):
class Transform(Registry, HasParents, IsVersioned):
"""Transforms of artifacts & datasets.
Pipelines, notebooks, app uploads.
Expand Down Expand Up @@ -1315,7 +1331,7 @@ def members(self) -> "QuerySet":
pass


class Artifact(Registry, Data, IsTree):
class Artifact(Registry, Data, IsTree, IsVersioned):
"""Artifacts: data batches stored as files, arrays, directories.
Args:
Expand Down Expand Up @@ -1793,7 +1809,7 @@ def restore(self) -> None:
pass


class Dataset(Registry, Data):
class Dataset(Registry, Data, IsVersioned):
"""Datasets: collections of artifacts.
Args:
Expand Down

0 comments on commit adf38b7

Please sign in to comment.