lamindb 1.2a2__py3-none-any.whl → 1.3.1__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 +3 -1
- lamindb/_view.py +2 -2
- lamindb/base/types.py +50 -11
- lamindb/core/_compat.py +60 -0
- lamindb/core/_context.py +15 -12
- lamindb/core/datasets/__init__.py +1 -0
- lamindb/core/datasets/_core.py +23 -0
- lamindb/core/datasets/_small.py +16 -2
- lamindb/core/loaders.py +22 -12
- lamindb/core/storage/_tiledbsoma.py +2 -2
- lamindb/core/storage/_zarr.py +84 -26
- lamindb/core/storage/objects.py +45 -44
- lamindb/core/types.py +11 -1
- lamindb/curators/__init__.py +1430 -1665
- lamindb/curators/_cellxgene_schemas/__init__.py +190 -18
- lamindb/curators/_cellxgene_schemas/schema_versions.csv +43 -0
- lamindb/models/_feature_manager.py +86 -42
- lamindb/models/_from_values.py +110 -119
- lamindb/models/_label_manager.py +17 -10
- lamindb/models/artifact.py +170 -102
- lamindb/models/can_curate.py +200 -231
- lamindb/models/feature.py +76 -47
- lamindb/models/project.py +69 -7
- lamindb/models/query_set.py +12 -2
- lamindb/models/record.py +77 -50
- lamindb/models/run.py +20 -7
- lamindb/models/schema.py +7 -15
- {lamindb-1.2a2.dist-info → lamindb-1.3.1.dist-info}/METADATA +8 -7
- {lamindb-1.2a2.dist-info → lamindb-1.3.1.dist-info}/RECORD +31 -30
- lamindb/curators/_cellxgene_schemas/schema_versions.yml +0 -104
- {lamindb-1.2a2.dist-info → lamindb-1.3.1.dist-info}/LICENSE +0 -0
- {lamindb-1.2a2.dist-info → lamindb-1.3.1.dist-info}/WHEEL +0 -0
lamindb/core/storage/objects.py
CHANGED
@@ -1,25 +1,20 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
from pathlib import PurePosixPath
|
4
|
-
from typing import TYPE_CHECKING, TypeAlias
|
4
|
+
from typing import TYPE_CHECKING, TypeAlias
|
5
5
|
|
6
6
|
from anndata import AnnData
|
7
7
|
from pandas import DataFrame
|
8
8
|
|
9
|
+
from lamindb.core._compat import (
|
10
|
+
with_package_obj,
|
11
|
+
)
|
12
|
+
from lamindb.core.types import ScverseDataStructures
|
13
|
+
|
9
14
|
if TYPE_CHECKING:
|
10
15
|
from lamindb_setup.core.types import UPathStr
|
11
16
|
|
12
|
-
|
13
|
-
MuData = TypeVar("MuData")
|
14
|
-
|
15
|
-
SupportedDataTypes: TypeAlias = AnnData | DataFrame | MuData | SpatialData
|
16
|
-
|
17
|
-
|
18
|
-
def is_package_installed(package_name):
|
19
|
-
import importlib.util
|
20
|
-
|
21
|
-
spec = importlib.util.find_spec(package_name)
|
22
|
-
return spec is not None
|
17
|
+
SupportedDataTypes: TypeAlias = DataFrame | ScverseDataStructures
|
23
18
|
|
24
19
|
|
25
20
|
def infer_suffix(dmem: SupportedDataTypes, format: str | None = None):
|
@@ -38,25 +33,34 @@ def infer_suffix(dmem: SupportedDataTypes, format: str | None = None):
|
|
38
33
|
if isinstance(dmem, DataFrame):
|
39
34
|
return ".parquet"
|
40
35
|
|
41
|
-
if
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
36
|
+
if with_package_obj(
|
37
|
+
dmem,
|
38
|
+
"MuData",
|
39
|
+
"mudata",
|
40
|
+
lambda obj: True, # Just checking type, not calling any method
|
41
|
+
)[0]:
|
42
|
+
return ".h5mu"
|
43
|
+
|
44
|
+
has_spatialdata, spatialdata_suffix = with_package_obj(
|
45
|
+
dmem,
|
46
|
+
"SpatialData",
|
47
|
+
"spatialdata",
|
48
|
+
lambda obj: (
|
49
|
+
format
|
50
|
+
if format is not None and format in {"spatialdata.zarr", "zarr"}
|
51
|
+
else ".zarr"
|
52
|
+
if format is None
|
53
|
+
else (_ for _ in ()).throw(
|
54
|
+
ValueError(
|
55
|
+
"Error when specifying SpatialData storage format, it should be"
|
56
|
+
f" 'zarr', 'spatialdata.zarr', not '{format}'. Check 'format'"
|
57
|
+
" or the suffix of 'key'."
|
58
|
+
)
|
59
|
+
)
|
60
|
+
),
|
61
|
+
)
|
62
|
+
if has_spatialdata:
|
63
|
+
return spatialdata_suffix
|
60
64
|
else:
|
61
65
|
raise NotImplementedError
|
62
66
|
|
@@ -78,18 +82,15 @@ def write_to_disk(dmem: SupportedDataTypes, filepath: UPathStr) -> None:
|
|
78
82
|
dmem.to_parquet(filepath)
|
79
83
|
return
|
80
84
|
|
81
|
-
if
|
82
|
-
|
83
|
-
|
84
|
-
if isinstance(dmem, MuData):
|
85
|
-
dmem.write(filepath)
|
86
|
-
return
|
85
|
+
if with_package_obj(dmem, "MuData", "mudata", lambda obj: obj.write(filepath))[0]:
|
86
|
+
return
|
87
87
|
|
88
|
-
if
|
89
|
-
|
88
|
+
if with_package_obj(
|
89
|
+
dmem,
|
90
|
+
"SpatialData",
|
91
|
+
"spatialdata",
|
92
|
+
lambda obj: obj.write(filepath, overwrite=True),
|
93
|
+
)[0]:
|
94
|
+
return
|
90
95
|
|
91
|
-
|
92
|
-
dmem.write(filepath, overwrite=True)
|
93
|
-
return
|
94
|
-
else:
|
95
|
-
raise NotImplementedError
|
96
|
+
raise NotImplementedError
|
lamindb/core/types.py
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import TYPE_CHECKING, TypeVar
|
4
|
+
|
5
|
+
from anndata import AnnData
|
1
6
|
from lamindb_setup.core.types import UPathStr
|
2
7
|
|
3
8
|
from lamindb.base.types import (
|
4
|
-
|
9
|
+
Dtype,
|
5
10
|
FieldAttr,
|
6
11
|
ListLike,
|
7
12
|
StrField,
|
8
13
|
TransformType,
|
9
14
|
)
|
15
|
+
|
16
|
+
MuData = TypeVar("MuData")
|
17
|
+
SpatialData = TypeVar("SpatialData")
|
18
|
+
|
19
|
+
ScverseDataStructures = AnnData | MuData | SpatialData
|