diff --git a/docs/bio-registries.ipynb b/docs/bio-registries.ipynb index 62c181ce9..c4a5b902e 100644 --- a/docs/bio-registries.ipynb +++ b/docs/bio-registries.ipynb @@ -304,7 +304,7 @@ "source": [ "We'd like to load the corresponding records in our in-house registry to annotate a dataset.\n", "\n", - "To this end, you'll typically use {class}`~lamindb.core.CanValidate.from_values`, which will both validate & retrieve records that match the values." + "To this end, you'll typically use {class}`~lamindb.core.CanCurate.from_values`, which will both validate & retrieve records that match the values." ] }, { diff --git a/docs/curate-any.ipynb b/docs/curate-any.ipynb index ee4ef411c..f2a1966cb 100644 --- a/docs/curate-any.ipynb +++ b/docs/curate-any.ipynb @@ -20,11 +20,11 @@ "source": [ ":::{dropdown} How do I validate based on a public ontology?\n", "\n", - "LaminDB makes it easy to validate categorical variables based on registries that inherit from {class}`~lamindb.core.CanValidate`.\n", + "LaminDB makes it easy to validate categorical variables based on registries that inherit from {class}`~lamindb.core.CanCurate`.\n", "\n", - "{class}`~lamindb.core.CanValidate` methods validate against the registries in your LaminDB instance.\n", + "{class}`~lamindb.core.CanCurate` methods validate against the registries in your LaminDB instance.\n", "In {doc}`./bio-registries`, you'll see how to extend standard validation to validation against _public references_ using a `ReferenceTable` ontology object: `public = Record.public()`.\n", - "By default, {meth}`~lamindb.core.CanValidate.from_values` considers a match in a public reference a validated value for any {mod}`bionty` entity.\n", + "By default, {meth}`~lamindb.core.CanCurate.from_values` considers a match in a public reference a validated value for any {mod}`bionty` entity.\n", "\n", ":::" ] @@ -92,7 +92,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "{meth}`~lamindb.core.CanValidate.validate` validates passed values against reference values in a registry.\n", + "{meth}`~lamindb.core.CanCurate.validate` validates passed values against reference values in a registry.\n", "It returns a boolean vector indicating whether a value has an exact match in the reference values." ] }, @@ -109,11 +109,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "When validation fails, you can call {meth}`~lamindb.core.CanValidate.inspect` to figure out what to do.\n", + "When validation fails, you can call {meth}`~lamindb.core.CanCurate.inspect` to figure out what to do.\n", "\n", - "{meth}`~lamindb.core.CanValidate.inspect` applies the same definition of validation as {meth}`~lamindb.core.CanValidate.validate`, but returns a rich return value {class}`~lamindb.core.InspectResult`. Most importantly, it logs recommended curation steps that would render the data validated.\n", + "{meth}`~lamindb.core.CanCurate.inspect` applies the same definition of validation as {meth}`~lamindb.core.CanCurate.validate`, but returns a rich return value {class}`~lamindb.core.InspectResult`. Most importantly, it logs recommended curation steps that would render the data validated.\n", "\n", - "Note: you can use {meth}`~lamindb.core.CanValidate.standardize` to standardize synonyms." + "Note: you can use {meth}`~lamindb.core.CanCurate.standardize` to standardize synonyms." ] }, { @@ -131,7 +131,7 @@ "source": [ "Following the suggestions to register new labels:\n", "\n", - "Bulk creating records using {meth}`~lamindb.core.CanValidate.from_values` only returns validated records:\n", + "Bulk creating records using {meth}`~lamindb.core.CanCurate.from_values` only returns validated records:\n", "\n", "Note: Terms validated with public reference are also created with `.from_values`, see {doc}`/bio-registries` for details." ] diff --git a/lamindb/__init__.py b/lamindb/__init__.py index 90ea3e5c6..7909e2ff6 100644 --- a/lamindb/__init__.py +++ b/lamindb/__init__.py @@ -79,7 +79,7 @@ def __getattr__(name): from . import core # isort: split from . import ( _artifact, - _can_validate, + _can_curate, _collection, _curate, _feature, diff --git a/lamindb/_can_validate.py b/lamindb/_can_curate.py similarity index 98% rename from lamindb/_can_validate.py rename to lamindb/_can_curate.py index 21c6639ae..1be509953 100644 --- a/lamindb/_can_validate.py +++ b/lamindb/_can_curate.py @@ -8,7 +8,7 @@ from django.core.exceptions import FieldDoesNotExist from lamin_utils import colors, logger from lamindb_setup.core._docs import doc_args -from lnschema_core import CanValidate, Record +from lnschema_core import CanCurate, Record from ._from_values import _has_organism_field, _print_values, get_or_create_records from ._record import _queryset, get_name_field @@ -23,7 +23,7 @@ # from_values doesn't apply for QuerySet or Manager @classmethod # type:ignore -@doc_args(CanValidate.from_values.__doc__) +@doc_args(CanCurate.from_values.__doc__) def from_values( cls, values: ListLike, @@ -49,7 +49,7 @@ def from_values( @classmethod # type: ignore -@doc_args(CanValidate.inspect.__doc__) +@doc_args(CanCurate.inspect.__doc__) def inspect( cls, values: ListLike, @@ -71,7 +71,7 @@ def inspect( @classmethod # type: ignore -@doc_args(CanValidate.validate.__doc__) +@doc_args(CanCurate.validate.__doc__) def validate( cls, values: ListLike, @@ -268,7 +268,7 @@ def _validate( @classmethod # type: ignore -@doc_args(CanValidate.standardize.__doc__) +@doc_args(CanCurate.standardize.__doc__) def standardize( cls, values: ListLike, @@ -621,10 +621,10 @@ def _field_is_id(field: str, registry: type[Record]) -> bool: from inspect import signature SIGS = { - name: signature(getattr(CanValidate, name)) + name: signature(getattr(CanCurate, name)) for name in METHOD_NAMES if not name.startswith("__") } for name in METHOD_NAMES: - attach_func_to_class_method(name, CanValidate, globals()) + attach_func_to_class_method(name, CanCurate, globals()) diff --git a/lamindb/_curate.py b/lamindb/_curate.py index 221feebb1..1cbeeb547 100644 --- a/lamindb/_curate.py +++ b/lamindb/_curate.py @@ -1731,7 +1731,7 @@ def _save_organism(name: str): # pragma: no cover def _ref_is_name(field: FieldAttr) -> bool | None: """Check if the reference field is a name field.""" - from ._can_validate import get_name_field + from ._can_curate import get_name_field name_field = get_name_field(field.field.model) return field.field.name == name_field diff --git a/lamindb/_query_set.py b/lamindb/_query_set.py index 89c76b462..269a0750b 100644 --- a/lamindb/_query_set.py +++ b/lamindb/_query_set.py @@ -12,7 +12,7 @@ from lamindb_setup.core._docs import doc_args from lnschema_core.models import ( Artifact, - CanValidate, + CanCurate, Collection, IsVersioned, Record, @@ -354,7 +354,7 @@ def latest_version(self) -> QuerySet: # ------------------------------------------------------------------------------------- -# CanValidate +# CanCurate # ------------------------------------------------------------------------------------- @@ -374,26 +374,26 @@ def lookup(self, field: StrField | None = None, **kwargs) -> NamedTuple: return _lookup(cls=self, field=field, **kwargs) -@doc_args(CanValidate.validate.__doc__) +@doc_args(CanCurate.validate.__doc__) def validate(self, values: ListLike, field: str | StrField | None = None, **kwargs): """{}""" # noqa: D415 - from ._can_validate import _validate + from ._can_curate import _validate return _validate(cls=self, values=values, field=field, **kwargs) -@doc_args(CanValidate.inspect.__doc__) +@doc_args(CanCurate.inspect.__doc__) def inspect(self, values: ListLike, field: str | StrField | None = None, **kwargs): """{}""" # noqa: D415 - from ._can_validate import _inspect + from ._can_curate import _inspect return _inspect(cls=self, values=values, field=field, **kwargs) -@doc_args(CanValidate.standardize.__doc__) +@doc_args(CanCurate.standardize.__doc__) def standardize(self, values: Iterable, field: str | StrField | None = None, **kwargs): """{}""" # noqa: D415 - from ._can_validate import _standardize + from ._can_curate import _standardize return _standardize(cls=self, values=values, field=field, **kwargs) diff --git a/lamindb/core/__init__.py b/lamindb/core/__init__.py index 280a29a13..2609ea649 100644 --- a/lamindb/core/__init__.py +++ b/lamindb/core/__init__.py @@ -14,7 +14,7 @@ ParamManager LabelManager IsVersioned - CanValidate + CanCurate HasParents TracksRun TracksUpdates @@ -68,7 +68,7 @@ from lamin_utils import logger from lamin_utils._inspect import InspectResult from lnschema_core.models import ( - CanValidate, + CanCurate, FeatureValue, HasParents, IsVersioned, diff --git a/lamindb/core/_django.py b/lamindb/core/_django.py index baf01d9cf..fd9ce9e38 100644 --- a/lamindb/core/_django.py +++ b/lamindb/core/_django.py @@ -33,7 +33,7 @@ def get_artifact_with_related( include_featureset: bool = False, ) -> dict: """Fetch an artifact with its related data.""" - from lamindb._can_validate import get_name_field + from lamindb._can_curate import get_name_field from ._label_manager import LABELS_EXCLUDE_SET @@ -163,7 +163,7 @@ def get_featureset_m2m_relations( artifact: Artifact, slot_featureset: dict, limit: int = 20 ): """Fetch all many-to-many relationships for given feature sets.""" - from lamindb._can_validate import get_name_field + from lamindb._can_curate import get_name_field m2m_relations = [ v diff --git a/lamindb/core/_label_manager.py b/lamindb/core/_label_manager.py index e5f5309cb..00e651054 100644 --- a/lamindb/core/_label_manager.py +++ b/lamindb/core/_label_manager.py @@ -6,7 +6,7 @@ import numpy as np from django.db import connections from lamin_utils import colors, logger -from lnschema_core.models import CanValidate, Feature +from lnschema_core.models import CanCurate, Feature from lamindb._from_values import _print_values from lamindb._record import ( @@ -116,7 +116,7 @@ def validate_labels_registry( label_uids = np.array( [getattr(label, field) for label in labels if label is not None] ) - if issubclass(registry, CanValidate): + if issubclass(registry, CanCurate): validated = registry.validate(label_uids, field=field, mute=True) validated_uids = label_uids[validated] validated_labels = registry.filter( diff --git a/sub/bionty b/sub/bionty index a21655f44..87c5b7f54 160000 --- a/sub/bionty +++ b/sub/bionty @@ -1 +1 @@ -Subproject commit a21655f447cebe8047036a3b63420430acf8be07 +Subproject commit 87c5b7f54993a7893904c6b4a8c8629d36905b72 diff --git a/sub/cellregistry b/sub/cellregistry index eb8e37742..6a528df81 160000 --- a/sub/cellregistry +++ b/sub/cellregistry @@ -1 +1 @@ -Subproject commit eb8e377427598843ad6d58bc7a451dead9fe7ca7 +Subproject commit 6a528df8184f04941dbb9633028799b5061b7639 diff --git a/sub/clinicore b/sub/clinicore index 626d35c4b..457050c21 160000 --- a/sub/clinicore +++ b/sub/clinicore @@ -1 +1 @@ -Subproject commit 626d35c4b70e28fb35f0bfb10d46322e8c75259a +Subproject commit 457050c219cfd54feaf3d1bc268c3a328784110d diff --git a/sub/findrefs b/sub/findrefs index 1bf2dcdd4..ecfe7d681 160000 --- a/sub/findrefs +++ b/sub/findrefs @@ -1 +1 @@ -Subproject commit 1bf2dcdd4149e1690e03e2e2c75e3fb50b65347b +Subproject commit ecfe7d6819e2291eae92fd0e194dba6116ac5d2c diff --git a/sub/lnschema-core b/sub/lnschema-core index cde81450b..971a4c8f3 160000 --- a/sub/lnschema-core +++ b/sub/lnschema-core @@ -1 +1 @@ -Subproject commit cde81450b29f2bd1f082de35d34587a1ccd5d6f3 +Subproject commit 971a4c8f305074e7f27fdaa1d7b274b02f3a100d diff --git a/sub/omop b/sub/omop index 056091b6e..c32f88eff 160000 --- a/sub/omop +++ b/sub/omop @@ -1 +1 @@ -Subproject commit 056091b6eb253c0db3632ff7e938f3e30db540e2 +Subproject commit c32f88effeff9cf023fc03aa1bf4638f3976f074 diff --git a/sub/ourprojects b/sub/ourprojects index 7d8f49329..a64d4358e 160000 --- a/sub/ourprojects +++ b/sub/ourprojects @@ -1 +1 @@ -Subproject commit 7d8f49329cd6f3229c31650b88c2e96c28bbf71a +Subproject commit a64d4358ef023c44af6387aef5f0d1500b8f5ec0 diff --git a/sub/wetlab b/sub/wetlab index c731d52d5..bbb5b2c20 160000 --- a/sub/wetlab +++ b/sub/wetlab @@ -1 +1 @@ -Subproject commit c731d52d5b1903940373eeaa408a86934d398241 +Subproject commit bbb5b2c205cd46b0b1c4a2c827187bbe1b2ad3f0 diff --git a/tests/core/test_parents.py b/tests/core/test_parents.py index 941918a37..610cb8085 100644 --- a/tests/core/test_parents.py +++ b/tests/core/test_parents.py @@ -1,7 +1,7 @@ import lamindb as ln import pytest -from django.core.exceptions import ValidationError from lamindb._parents import _add_emoji +from lnschema_core.validation import FieldValidationError def test_view_parents(): @@ -38,7 +38,8 @@ def test_query_parents_children(): def test_add_emoji(): record = ln.Transform(type="upload") assert _add_emoji(record, label="transform") == "🖥️ transform" - with pytest.raises(ValidationError): + # validate literal + with pytest.raises(FieldValidationError): transform = ln.Transform(name="test", type="app") transform = ln.Transform(name="test", type="upload") transform.save()