lamindb 0.76.8__py3-none-any.whl → 0.76.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lamindb/__init__.py +114 -113
- lamindb/_artifact.py +1206 -1205
- lamindb/_can_validate.py +621 -579
- lamindb/_collection.py +390 -387
- lamindb/_curate.py +1603 -1601
- lamindb/_feature.py +155 -155
- lamindb/_feature_set.py +244 -242
- lamindb/_filter.py +23 -23
- lamindb/_finish.py +250 -256
- lamindb/_from_values.py +403 -382
- lamindb/_is_versioned.py +40 -40
- lamindb/_parents.py +476 -476
- lamindb/_query_manager.py +125 -125
- lamindb/_query_set.py +364 -362
- lamindb/_record.py +668 -649
- lamindb/_run.py +60 -57
- lamindb/_save.py +310 -308
- lamindb/_storage.py +14 -14
- lamindb/_transform.py +130 -127
- lamindb/_ulabel.py +56 -56
- lamindb/_utils.py +9 -9
- lamindb/_view.py +72 -72
- lamindb/core/__init__.py +94 -94
- lamindb/core/_context.py +590 -574
- lamindb/core/_data.py +510 -438
- lamindb/core/_django.py +209 -0
- lamindb/core/_feature_manager.py +994 -867
- lamindb/core/_label_manager.py +289 -253
- lamindb/core/_mapped_collection.py +631 -597
- lamindb/core/_settings.py +188 -187
- lamindb/core/_sync_git.py +138 -138
- lamindb/core/_track_environment.py +27 -27
- lamindb/core/datasets/__init__.py +59 -59
- lamindb/core/datasets/_core.py +581 -571
- lamindb/core/datasets/_fake.py +36 -36
- lamindb/core/exceptions.py +90 -90
- lamindb/core/fields.py +12 -12
- lamindb/core/loaders.py +164 -164
- lamindb/core/schema.py +56 -56
- lamindb/core/storage/__init__.py +25 -25
- lamindb/core/storage/_anndata_accessor.py +741 -740
- lamindb/core/storage/_anndata_sizes.py +41 -41
- lamindb/core/storage/_backed_access.py +98 -98
- lamindb/core/storage/_tiledbsoma.py +204 -204
- lamindb/core/storage/_valid_suffixes.py +21 -21
- lamindb/core/storage/_zarr.py +110 -110
- lamindb/core/storage/objects.py +62 -62
- lamindb/core/storage/paths.py +172 -172
- lamindb/core/subsettings/__init__.py +12 -12
- lamindb/core/subsettings/_creation_settings.py +38 -38
- lamindb/core/subsettings/_transform_settings.py +21 -21
- lamindb/core/types.py +19 -19
- lamindb/core/versioning.py +146 -158
- lamindb/integrations/__init__.py +12 -12
- lamindb/integrations/_vitessce.py +107 -107
- lamindb/setup/__init__.py +14 -14
- lamindb/setup/core/__init__.py +4 -4
- {lamindb-0.76.8.dist-info → lamindb-0.76.10.dist-info}/LICENSE +201 -201
- {lamindb-0.76.8.dist-info → lamindb-0.76.10.dist-info}/METADATA +8 -8
- lamindb-0.76.10.dist-info/RECORD +61 -0
- {lamindb-0.76.8.dist-info → lamindb-0.76.10.dist-info}/WHEEL +1 -1
- lamindb-0.76.8.dist-info/RECORD +0 -60
lamindb/_storage.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
from lamindb_setup.core._docs import doc_args
|
2
|
-
from lamindb_setup.core.upath import UPath, create_path
|
3
|
-
from lnschema_core import Storage
|
4
|
-
|
5
|
-
|
6
|
-
@property # type: ignore
|
7
|
-
@doc_args(Storage.path.__doc__)
|
8
|
-
def path(self) -> UPath:
|
9
|
-
"""{}""" # noqa: D415
|
10
|
-
access_token = self._access_token if hasattr(self, "_access_token") else None
|
11
|
-
return create_path(self.root, access_token=access_token)
|
12
|
-
|
13
|
-
|
14
|
-
Storage.path = path
|
1
|
+
from lamindb_setup.core._docs import doc_args
|
2
|
+
from lamindb_setup.core.upath import UPath, create_path
|
3
|
+
from lnschema_core import Storage
|
4
|
+
|
5
|
+
|
6
|
+
@property # type: ignore
|
7
|
+
@doc_args(Storage.path.__doc__)
|
8
|
+
def path(self) -> UPath:
|
9
|
+
"""{}""" # noqa: D415
|
10
|
+
access_token = self._access_token if hasattr(self, "_access_token") else None
|
11
|
+
return create_path(self.root, access_token=access_token)
|
12
|
+
|
13
|
+
|
14
|
+
Storage.path = path
|
lamindb/_transform.py
CHANGED
@@ -1,127 +1,130 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
|
5
|
-
from lamin_utils import logger
|
6
|
-
from lamindb_setup.core._docs import doc_args
|
7
|
-
from lnschema_core.models import Run, Transform
|
8
|
-
|
9
|
-
from .
|
10
|
-
|
11
|
-
from .
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
has_consciously_provided_uid =
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
_source_code_artifact
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
Transform.
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import TYPE_CHECKING
|
4
|
+
|
5
|
+
from lamin_utils import logger
|
6
|
+
from lamindb_setup.core._docs import doc_args
|
7
|
+
from lnschema_core.models import Run, Transform
|
8
|
+
|
9
|
+
from lamindb.core.exceptions import InconsistentKey
|
10
|
+
|
11
|
+
from ._parents import _view_parents
|
12
|
+
from ._run import delete_run_artifacts
|
13
|
+
from .core.versioning import message_update_key_in_version_family, process_revises
|
14
|
+
|
15
|
+
if TYPE_CHECKING:
|
16
|
+
from lnschema_core.types import TransformType
|
17
|
+
|
18
|
+
|
19
|
+
def __init__(transform: Transform, *args, **kwargs):
|
20
|
+
if len(args) == len(transform._meta.concrete_fields):
|
21
|
+
super(Transform, transform).__init__(*args, **kwargs)
|
22
|
+
return None
|
23
|
+
name: str | None = kwargs.pop("name") if "name" in kwargs else None
|
24
|
+
key: str | None = kwargs.pop("key") if "key" in kwargs else None
|
25
|
+
revises: Transform | None = kwargs.pop("revises") if "revises" in kwargs else None
|
26
|
+
version: str | None = kwargs.pop("version") if "version" in kwargs else None
|
27
|
+
type: TransformType | None = kwargs.pop("type") if "type" in kwargs else "pipeline"
|
28
|
+
reference: str | None = kwargs.pop("reference") if "reference" in kwargs else None
|
29
|
+
reference_type: str | None = (
|
30
|
+
kwargs.pop("reference_type") if "reference_type" in kwargs else None
|
31
|
+
)
|
32
|
+
if "is_new_version_of" in kwargs:
|
33
|
+
logger.warning("`is_new_version_of` will be removed soon, please use `revises`")
|
34
|
+
revises = kwargs.pop("is_new_version_of")
|
35
|
+
# below is internal use that we'll hopefully be able to eliminate
|
36
|
+
uid: str | None = kwargs.pop("uid") if "uid" in kwargs else None
|
37
|
+
if not len(kwargs) == 0:
|
38
|
+
raise ValueError(
|
39
|
+
"Only name, key, version, type, revises, reference, "
|
40
|
+
f"reference_type can be passed, but you passed: {kwargs}"
|
41
|
+
)
|
42
|
+
if revises is None:
|
43
|
+
# need to check uid before checking key
|
44
|
+
if uid is not None:
|
45
|
+
revises = (
|
46
|
+
Transform.filter(uid__startswith=uid[:-4], is_latest=True)
|
47
|
+
.order_by("-created_at")
|
48
|
+
.first()
|
49
|
+
)
|
50
|
+
elif key is not None:
|
51
|
+
revises = (
|
52
|
+
Transform.filter(key=key, is_latest=True)
|
53
|
+
.order_by("-created_at")
|
54
|
+
.first()
|
55
|
+
)
|
56
|
+
if revises is not None and uid is not None and uid == revises.uid:
|
57
|
+
from ._record import init_self_from_db, update_attributes
|
58
|
+
|
59
|
+
init_self_from_db(transform, revises)
|
60
|
+
update_attributes(transform, {"name": name})
|
61
|
+
return None
|
62
|
+
if revises is not None and key is not None and revises.key != key:
|
63
|
+
note = message_update_key_in_version_family(
|
64
|
+
suid=revises.stem_uid,
|
65
|
+
existing_key=revises.key,
|
66
|
+
new_key=key,
|
67
|
+
registry="Artifact",
|
68
|
+
)
|
69
|
+
raise InconsistentKey(
|
70
|
+
f"`key` is {key}, but `revises.key` is '{revises.key}'\n\nEither do *not* pass `key`.\n\n{note}"
|
71
|
+
)
|
72
|
+
new_uid, version, name, revises = process_revises(revises, version, name, Transform)
|
73
|
+
# this is only because the user-facing constructor allows passing a uid
|
74
|
+
# most others don't
|
75
|
+
if uid is None:
|
76
|
+
has_consciously_provided_uid = False
|
77
|
+
uid = new_uid
|
78
|
+
else:
|
79
|
+
has_consciously_provided_uid = True
|
80
|
+
super(Transform, transform).__init__(
|
81
|
+
uid=uid,
|
82
|
+
name=name,
|
83
|
+
key=key,
|
84
|
+
type=type,
|
85
|
+
version=version,
|
86
|
+
reference=reference,
|
87
|
+
reference_type=reference_type,
|
88
|
+
_has_consciously_provided_uid=has_consciously_provided_uid,
|
89
|
+
revises=revises,
|
90
|
+
)
|
91
|
+
|
92
|
+
|
93
|
+
def delete(self) -> None:
|
94
|
+
_source_code_artifact = None
|
95
|
+
if self._source_code_artifact is not None:
|
96
|
+
_source_code_artifact = self._source_code_artifact
|
97
|
+
self._source_code_artifact = None
|
98
|
+
self.save()
|
99
|
+
if _source_code_artifact is not None:
|
100
|
+
_source_code_artifact.delete(permanent=True)
|
101
|
+
# query all runs and delete their artifacts
|
102
|
+
runs = Run.filter(transform=self)
|
103
|
+
for run in runs:
|
104
|
+
delete_run_artifacts(run)
|
105
|
+
# at this point, all artifacts have been taken care of
|
106
|
+
# we can now leverage CASCADE delete
|
107
|
+
super(Transform, self).delete()
|
108
|
+
|
109
|
+
|
110
|
+
@property # type: ignore
|
111
|
+
@doc_args(Transform.latest_run.__doc__)
|
112
|
+
def latest_run(self) -> Run:
|
113
|
+
"""{}""" # noqa: D415
|
114
|
+
return self.runs.order_by("-started_at").first()
|
115
|
+
|
116
|
+
|
117
|
+
def view_lineage(self, with_successors: bool = False, distance: int = 5):
|
118
|
+
return _view_parents(
|
119
|
+
record=self,
|
120
|
+
field="name",
|
121
|
+
with_children=with_successors,
|
122
|
+
distance=distance,
|
123
|
+
attr_name="predecessors",
|
124
|
+
)
|
125
|
+
|
126
|
+
|
127
|
+
Transform.__init__ = __init__
|
128
|
+
Transform.delete = delete
|
129
|
+
Transform.latest_run = latest_run
|
130
|
+
Transform.view_lineage = view_lineage
|
lamindb/_ulabel.py
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
|
5
|
-
import lamindb_setup as ln_setup
|
6
|
-
from lamindb_setup.core._docs import doc_args
|
7
|
-
from lnschema_core import ULabel
|
8
|
-
|
9
|
-
from lamindb._utils import attach_func_to_class_method
|
10
|
-
|
11
|
-
if TYPE_CHECKING:
|
12
|
-
from lnschema_core.types import ListLike
|
13
|
-
|
14
|
-
|
15
|
-
def __init__(self, *args, **kwargs):
|
16
|
-
if len(args) == len(self._meta.concrete_fields):
|
17
|
-
super(ULabel, self).__init__(*args, **kwargs)
|
18
|
-
return None
|
19
|
-
# now we proceed with the user-facing constructor
|
20
|
-
if len(args) > 0:
|
21
|
-
raise ValueError("Only one non-keyword arg allowed")
|
22
|
-
name: str | None = kwargs.pop("name") if "name" in kwargs else None
|
23
|
-
description: str | None = (
|
24
|
-
kwargs.pop("description") if "description" in kwargs else None
|
25
|
-
)
|
26
|
-
reference: str | None = kwargs.pop("reference") if "reference" in kwargs else None
|
27
|
-
reference_type: str | None = (
|
28
|
-
kwargs.pop("reference_type") if "reference_type" in kwargs else None
|
29
|
-
)
|
30
|
-
if len(kwargs) > 0:
|
31
|
-
raise ValueError(
|
32
|
-
"Only name, description, reference, reference_type are valid keyword arguments"
|
33
|
-
)
|
34
|
-
super(ULabel, self).__init__(
|
35
|
-
name=name,
|
36
|
-
description=description,
|
37
|
-
reference=reference,
|
38
|
-
reference_type=reference_type,
|
39
|
-
)
|
40
|
-
|
41
|
-
|
42
|
-
METHOD_NAMES = [
|
43
|
-
"__init__",
|
44
|
-
]
|
45
|
-
|
46
|
-
if ln_setup._TESTING:
|
47
|
-
from inspect import signature
|
48
|
-
|
49
|
-
SIGS = {
|
50
|
-
name: signature(getattr(ULabel, name))
|
51
|
-
for name in METHOD_NAMES
|
52
|
-
if name != "__init__"
|
53
|
-
}
|
54
|
-
|
55
|
-
for name in METHOD_NAMES:
|
56
|
-
attach_func_to_class_method(name, ULabel, globals())
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import TYPE_CHECKING
|
4
|
+
|
5
|
+
import lamindb_setup as ln_setup
|
6
|
+
from lamindb_setup.core._docs import doc_args
|
7
|
+
from lnschema_core import ULabel
|
8
|
+
|
9
|
+
from lamindb._utils import attach_func_to_class_method
|
10
|
+
|
11
|
+
if TYPE_CHECKING:
|
12
|
+
from lnschema_core.types import ListLike
|
13
|
+
|
14
|
+
|
15
|
+
def __init__(self, *args, **kwargs):
|
16
|
+
if len(args) == len(self._meta.concrete_fields):
|
17
|
+
super(ULabel, self).__init__(*args, **kwargs)
|
18
|
+
return None
|
19
|
+
# now we proceed with the user-facing constructor
|
20
|
+
if len(args) > 0:
|
21
|
+
raise ValueError("Only one non-keyword arg allowed")
|
22
|
+
name: str | None = kwargs.pop("name") if "name" in kwargs else None
|
23
|
+
description: str | None = (
|
24
|
+
kwargs.pop("description") if "description" in kwargs else None
|
25
|
+
)
|
26
|
+
reference: str | None = kwargs.pop("reference") if "reference" in kwargs else None
|
27
|
+
reference_type: str | None = (
|
28
|
+
kwargs.pop("reference_type") if "reference_type" in kwargs else None
|
29
|
+
)
|
30
|
+
if len(kwargs) > 0:
|
31
|
+
raise ValueError(
|
32
|
+
"Only name, description, reference, reference_type are valid keyword arguments"
|
33
|
+
)
|
34
|
+
super(ULabel, self).__init__(
|
35
|
+
name=name,
|
36
|
+
description=description,
|
37
|
+
reference=reference,
|
38
|
+
reference_type=reference_type,
|
39
|
+
)
|
40
|
+
|
41
|
+
|
42
|
+
METHOD_NAMES = [
|
43
|
+
"__init__",
|
44
|
+
]
|
45
|
+
|
46
|
+
if ln_setup._TESTING:
|
47
|
+
from inspect import signature
|
48
|
+
|
49
|
+
SIGS = {
|
50
|
+
name: signature(getattr(ULabel, name))
|
51
|
+
for name in METHOD_NAMES
|
52
|
+
if name != "__init__"
|
53
|
+
}
|
54
|
+
|
55
|
+
for name in METHOD_NAMES:
|
56
|
+
attach_func_to_class_method(name, ULabel, globals())
|
lamindb/_utils.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
def attach_func_to_class_method(func_name, cls, globals):
|
2
|
-
implementation = globals[func_name]
|
3
|
-
target = getattr(cls, func_name)
|
4
|
-
# assigning the original class definition docstring
|
5
|
-
# to the implementation only has an effect for regular methods
|
6
|
-
# not for class methods
|
7
|
-
# this is why we need @doc_args for class methods
|
8
|
-
implementation.__doc__ = target.__doc__
|
9
|
-
setattr(cls, func_name, implementation)
|
1
|
+
def attach_func_to_class_method(func_name, cls, globals):
|
2
|
+
implementation = globals[func_name]
|
3
|
+
target = getattr(cls, func_name)
|
4
|
+
# assigning the original class definition docstring
|
5
|
+
# to the implementation only has an effect for regular methods
|
6
|
+
# not for class methods
|
7
|
+
# this is why we need @doc_args for class methods
|
8
|
+
implementation.__doc__ = target.__doc__
|
9
|
+
setattr(cls, func_name, implementation)
|
lamindb/_view.py
CHANGED
@@ -1,72 +1,72 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
import builtins
|
4
|
-
import importlib
|
5
|
-
import inspect
|
6
|
-
|
7
|
-
from lamin_utils import colors, logger
|
8
|
-
from lamindb_setup import settings
|
9
|
-
from lamindb_setup._init_instance import get_schema_module_name
|
10
|
-
from lnschema_core import Record
|
11
|
-
|
12
|
-
is_run_from_ipython = getattr(builtins, "__IPYTHON__", False)
|
13
|
-
|
14
|
-
|
15
|
-
def view(
|
16
|
-
n: int = 7, schema: str | None = None, registries: list[str] | None = None
|
17
|
-
) -> None:
|
18
|
-
"""View latest metadata state.
|
19
|
-
|
20
|
-
Args:
|
21
|
-
n: Display the last `n` rows of a registry.
|
22
|
-
schema: Schema module to view. Default's to
|
23
|
-
`None` and displays all schema modules.
|
24
|
-
registries: List of Record names. Defaults to
|
25
|
-
`None` and lists all registries.
|
26
|
-
|
27
|
-
Examples:
|
28
|
-
>>> ln.view()
|
29
|
-
"""
|
30
|
-
if is_run_from_ipython:
|
31
|
-
from IPython.display import display as show
|
32
|
-
else:
|
33
|
-
show = logger.print
|
34
|
-
|
35
|
-
if schema is not None:
|
36
|
-
schema_names = [schema]
|
37
|
-
else:
|
38
|
-
schema_names = ["core"] + list(settings.instance.schema)
|
39
|
-
|
40
|
-
for schema_name in schema_names:
|
41
|
-
schema_module = importlib.import_module(get_schema_module_name(schema_name))
|
42
|
-
|
43
|
-
all_registries = {
|
44
|
-
registry
|
45
|
-
for registry in schema_module.__dict__.values()
|
46
|
-
if inspect.isclass(registry)
|
47
|
-
and issubclass(registry, Record)
|
48
|
-
and registry is not Record
|
49
|
-
}
|
50
|
-
if registries is not None:
|
51
|
-
filtered_registries = {
|
52
|
-
registry
|
53
|
-
for registry in all_registries
|
54
|
-
if registry.__name__ in registries
|
55
|
-
}
|
56
|
-
else:
|
57
|
-
filtered_registries = all_registries
|
58
|
-
if len(schema_names) > 1:
|
59
|
-
section = f"* module: {colors.green(colors.bold(schema_name))} *"
|
60
|
-
section_no_color = f"* module: {schema_name} *"
|
61
|
-
logger.print("*" * len(section_no_color))
|
62
|
-
logger.print(section)
|
63
|
-
logger.print("*" * len(section_no_color))
|
64
|
-
for registry in sorted(filtered_registries, key=lambda x: x.__name__):
|
65
|
-
if hasattr(registry, "updated_at"):
|
66
|
-
df = registry.filter().order_by("-updated_at")[:n].df()
|
67
|
-
else:
|
68
|
-
# need to adjust in the future
|
69
|
-
df = registry.df().iloc[-n:]
|
70
|
-
if df.shape[0] > 0:
|
71
|
-
logger.print(colors.blue(colors.bold(registry.__name__)))
|
72
|
-
show(df)
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import builtins
|
4
|
+
import importlib
|
5
|
+
import inspect
|
6
|
+
|
7
|
+
from lamin_utils import colors, logger
|
8
|
+
from lamindb_setup import settings
|
9
|
+
from lamindb_setup._init_instance import get_schema_module_name
|
10
|
+
from lnschema_core import Record
|
11
|
+
|
12
|
+
is_run_from_ipython = getattr(builtins, "__IPYTHON__", False)
|
13
|
+
|
14
|
+
|
15
|
+
def view(
|
16
|
+
n: int = 7, schema: str | None = None, registries: list[str] | None = None
|
17
|
+
) -> None:
|
18
|
+
"""View latest metadata state.
|
19
|
+
|
20
|
+
Args:
|
21
|
+
n: Display the last `n` rows of a registry.
|
22
|
+
schema: Schema module to view. Default's to
|
23
|
+
`None` and displays all schema modules.
|
24
|
+
registries: List of Record names. Defaults to
|
25
|
+
`None` and lists all registries.
|
26
|
+
|
27
|
+
Examples:
|
28
|
+
>>> ln.view()
|
29
|
+
"""
|
30
|
+
if is_run_from_ipython:
|
31
|
+
from IPython.display import display as show
|
32
|
+
else:
|
33
|
+
show = logger.print
|
34
|
+
|
35
|
+
if schema is not None:
|
36
|
+
schema_names = [schema]
|
37
|
+
else:
|
38
|
+
schema_names = ["core"] + list(settings.instance.schema)
|
39
|
+
|
40
|
+
for schema_name in schema_names:
|
41
|
+
schema_module = importlib.import_module(get_schema_module_name(schema_name))
|
42
|
+
|
43
|
+
all_registries = {
|
44
|
+
registry
|
45
|
+
for registry in schema_module.__dict__.values()
|
46
|
+
if inspect.isclass(registry)
|
47
|
+
and issubclass(registry, Record)
|
48
|
+
and registry is not Record
|
49
|
+
}
|
50
|
+
if registries is not None:
|
51
|
+
filtered_registries = {
|
52
|
+
registry
|
53
|
+
for registry in all_registries
|
54
|
+
if registry.__name__ in registries
|
55
|
+
}
|
56
|
+
else:
|
57
|
+
filtered_registries = all_registries
|
58
|
+
if len(schema_names) > 1:
|
59
|
+
section = f"* module: {colors.green(colors.bold(schema_name))} *"
|
60
|
+
section_no_color = f"* module: {schema_name} *"
|
61
|
+
logger.print("*" * len(section_no_color))
|
62
|
+
logger.print(section)
|
63
|
+
logger.print("*" * len(section_no_color))
|
64
|
+
for registry in sorted(filtered_registries, key=lambda x: x.__name__):
|
65
|
+
if hasattr(registry, "updated_at"):
|
66
|
+
df = registry.filter().order_by("-updated_at")[:n].df()
|
67
|
+
else:
|
68
|
+
# need to adjust in the future
|
69
|
+
df = registry.df().iloc[-n:]
|
70
|
+
if df.shape[0] > 0:
|
71
|
+
logger.print(colors.blue(colors.bold(registry.__name__)))
|
72
|
+
show(df)
|