Skip to content

Commit

Permalink
🚚 Rename CanValidate to CanCurate
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyosun committed Nov 15, 2024
1 parent f3cc457 commit 469189e
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docs/bio-registries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions docs/curate-any.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
":::"
]
Expand Down Expand Up @@ -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."
]
},
Expand All @@ -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."
]
},
{
Expand All @@ -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."
]
Expand Down
2 changes: 1 addition & 1 deletion lamindb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __getattr__(name):
from . import core # isort: split
from . import (
_artifact,
_can_validate,
_can_curate,
_collection,
_curate,
_feature,
Expand Down
14 changes: 7 additions & 7 deletions lamindb/_can_validate.py β†’ lamindb/_can_curate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -71,7 +71,7 @@ def inspect(


@classmethod # type: ignore
@doc_args(CanValidate.validate.__doc__)
@doc_args(CanCurate.validate.__doc__)
def validate(
cls,
values: ListLike,
Expand Down Expand Up @@ -268,7 +268,7 @@ def _validate(


@classmethod # type: ignore
@doc_args(CanValidate.standardize.__doc__)
@doc_args(CanCurate.standardize.__doc__)
def standardize(
cls,
values: ListLike,
Expand Down Expand Up @@ -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())
2 changes: 1 addition & 1 deletion lamindb/_curate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions lamindb/_query_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from lamindb_setup.core._docs import doc_args
from lnschema_core.models import (
Artifact,
CanValidate,
CanCurate,
Collection,
IsVersioned,
Record,
Expand Down Expand Up @@ -354,7 +354,7 @@ def latest_version(self) -> QuerySet:


# -------------------------------------------------------------------------------------
# CanValidate
# CanCurate
# -------------------------------------------------------------------------------------


Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions lamindb/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ParamManager
LabelManager
IsVersioned
CanValidate
CanCurate
HasParents
TracksRun
TracksUpdates
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lamindb/core/_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lamindb/core/_label_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion sub/bionty
2 changes: 1 addition & 1 deletion sub/cellregistry
2 changes: 1 addition & 1 deletion sub/findrefs
2 changes: 1 addition & 1 deletion sub/omop
Submodule omop updated 1 files
+40 βˆ’40 omop/models.py
2 changes: 1 addition & 1 deletion sub/ourprojects
5 changes: 3 additions & 2 deletions tests/core/test_parents.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 469189e

Please sign in to comment.