lamindb 1.1.1__py3-none-any.whl → 1.2a2__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.
Files changed (64) hide show
  1. lamindb/__init__.py +28 -25
  2. lamindb/_tracked.py +1 -1
  3. lamindb/_view.py +2 -3
  4. lamindb/base/__init__.py +1 -1
  5. lamindb/base/ids.py +1 -10
  6. lamindb/core/__init__.py +7 -65
  7. lamindb/core/_context.py +34 -8
  8. lamindb/core/_settings.py +6 -6
  9. lamindb/core/_sync_git.py +1 -1
  10. lamindb/core/loaders.py +9 -8
  11. lamindb/core/storage/_backed_access.py +4 -2
  12. lamindb/core/storage/_tiledbsoma.py +6 -4
  13. lamindb/core/storage/_zarr.py +32 -11
  14. lamindb/core/storage/objects.py +59 -26
  15. lamindb/core/storage/paths.py +4 -1
  16. lamindb/curators/__init__.py +97 -81
  17. lamindb/errors.py +1 -1
  18. lamindb/integrations/_vitessce.py +4 -4
  19. lamindb/migrations/0089_subsequent_runs.py +159 -0
  20. lamindb/migrations/0090_runproject_project_runs.py +73 -0
  21. lamindb/migrations/{0088_squashed.py → 0090_squashed.py} +245 -177
  22. lamindb/models/__init__.py +79 -0
  23. lamindb/{core → models}/_describe.py +3 -3
  24. lamindb/{core → models}/_django.py +8 -5
  25. lamindb/{core → models}/_feature_manager.py +103 -87
  26. lamindb/{_from_values.py → models/_from_values.py} +5 -2
  27. lamindb/{core/versioning.py → models/_is_versioned.py} +94 -6
  28. lamindb/{core → models}/_label_manager.py +10 -17
  29. lamindb/{core/relations.py → models/_relations.py} +8 -1
  30. lamindb/models/artifact.py +2601 -0
  31. lamindb/{_can_curate.py → models/can_curate.py} +349 -180
  32. lamindb/models/collection.py +683 -0
  33. lamindb/models/core.py +135 -0
  34. lamindb/models/feature.py +643 -0
  35. lamindb/models/flextable.py +163 -0
  36. lamindb/{_parents.py → models/has_parents.py} +55 -49
  37. lamindb/models/project.py +384 -0
  38. lamindb/{_query_manager.py → models/query_manager.py} +10 -8
  39. lamindb/{_query_set.py → models/query_set.py} +28 -24
  40. lamindb/models/record.py +1757 -0
  41. lamindb/models/run.py +563 -0
  42. lamindb/{_save.py → models/save.py} +9 -7
  43. lamindb/models/schema.py +732 -0
  44. lamindb/models/transform.py +360 -0
  45. lamindb/models/ulabel.py +249 -0
  46. {lamindb-1.1.1.dist-info → lamindb-1.2a2.dist-info}/METADATA +5 -5
  47. {lamindb-1.1.1.dist-info → lamindb-1.2a2.dist-info}/RECORD +49 -50
  48. lamindb/_artifact.py +0 -1379
  49. lamindb/_collection.py +0 -440
  50. lamindb/_feature.py +0 -316
  51. lamindb/_is_versioned.py +0 -40
  52. lamindb/_record.py +0 -1064
  53. lamindb/_run.py +0 -60
  54. lamindb/_schema.py +0 -347
  55. lamindb/_storage.py +0 -15
  56. lamindb/_transform.py +0 -170
  57. lamindb/_ulabel.py +0 -56
  58. lamindb/_utils.py +0 -9
  59. lamindb/base/validation.py +0 -63
  60. lamindb/core/_data.py +0 -491
  61. lamindb/core/fields.py +0 -12
  62. lamindb/models.py +0 -4475
  63. {lamindb-1.1.1.dist-info → lamindb-1.2a2.dist-info}/LICENSE +0 -0
  64. {lamindb-1.1.1.dist-info → lamindb-1.2a2.dist-info}/WHEEL +0 -0
lamindb/__init__.py CHANGED
@@ -16,8 +16,8 @@ Registries.
16
16
 
17
17
  Artifact
18
18
  Transform
19
- ULabel
20
19
  Run
20
+ ULabel
21
21
  User
22
22
  Storage
23
23
  Feature
@@ -25,9 +25,17 @@ Registries.
25
25
  Param
26
26
  Collection
27
27
  Project
28
+ Space
28
29
  Reference
29
30
  Person
30
31
 
32
+ Curators & integrations.
33
+
34
+ .. autosummary::
35
+
36
+ curators
37
+ integrations
38
+
31
39
  Key functionality.
32
40
 
33
41
  .. autosummary::
@@ -36,20 +44,19 @@ Key functionality.
36
44
  connect
37
45
  view
38
46
  save
47
+ UPath
48
+ settings
39
49
 
40
- Modules and settings.
50
+ Low-level functionality.
41
51
 
42
52
  .. autosummary::
43
53
  :toctree: .
44
54
 
45
- integrations
46
55
  context
47
- curators
48
- settings
49
56
  errors
50
57
  setup
51
- UPath
52
58
  base
59
+ models
53
60
  core
54
61
 
55
62
  Backward compatibility.
@@ -62,8 +69,16 @@ Backward compatibility.
62
69
 
63
70
  """
64
71
 
72
+ # ruff: noqa: I001
65
73
  # denote a release candidate for 0.1.0 with 0.1rc1, 0.1a1, 0.1b1, etc.
66
- __version__ = "1.1.1"
74
+ __version__ = "1.2a2"
75
+
76
+ import warnings
77
+
78
+ # through SpatialData
79
+ warnings.filterwarnings(
80
+ "ignore", message="The legacy Dask DataFrame implementation is deprecated"
81
+ )
67
82
 
68
83
  from lamindb_setup._check_setup import InstanceNotSetupError as _InstanceNotSetupError
69
84
  from lamindb_setup._check_setup import _check_instance_setup
@@ -79,23 +94,7 @@ def __getattr__(name):
79
94
 
80
95
  if _check_instance_setup(from_module="lamindb"):
81
96
  del __getattr__ # so that imports work out
82
- from . import core # isort: split
83
- from . import (
84
- _artifact,
85
- _can_curate,
86
- _collection,
87
- _feature,
88
- _is_versioned,
89
- _parents,
90
- _record,
91
- _run,
92
- _schema,
93
- _storage,
94
- _transform,
95
- _ulabel,
96
- integrations,
97
- )
98
- from ._save import save
97
+ from . import base
99
98
  from ._tracked import tracked
100
99
  from ._view import view
101
100
  from .core._context import context
@@ -111,12 +110,16 @@ if _check_instance_setup(from_module="lamindb"):
111
110
  Project,
112
111
  Reference,
113
112
  Run,
114
- Schema, # forward compat
113
+ Schema,
115
114
  Storage,
116
115
  Transform,
117
116
  ULabel,
118
117
  User,
118
+ Space,
119
119
  )
120
+ from .models.save import save
121
+ from . import core
122
+ from . import integrations
120
123
 
121
124
  track = context.track # simple access
122
125
  finish = context.finish # simple access
lamindb/_tracked.py CHANGED
@@ -5,8 +5,8 @@ from datetime import datetime, timezone
5
5
  from typing import Callable, ParamSpec, TypeVar
6
6
 
7
7
  from .core._context import context
8
- from .core._feature_manager import infer_feature_type_convert_json
9
8
  from .models import Run, Transform
9
+ from .models._feature_manager import infer_feature_type_convert_json
10
10
 
11
11
  P = ParamSpec("P")
12
12
  R = TypeVar("R")
lamindb/_view.py CHANGED
@@ -9,10 +9,9 @@ from lamin_utils import colors, logger
9
9
  from lamindb_setup import settings
10
10
  from lamindb_setup._init_instance import get_schema_module_name
11
11
 
12
- from lamindb.core import FeatureValue, ParamValue
13
- from lamindb.models import Feature, Record
12
+ from lamindb.models import Feature, FeatureValue, ParamValue, Record
14
13
 
15
- from ._feature import convert_pandas_dtype_to_lamin_dtype
14
+ from .models.feature import convert_pandas_dtype_to_lamin_dtype
16
15
 
17
16
  if TYPE_CHECKING:
18
17
  import pandas as pd
lamindb/base/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Base library.
2
2
 
3
- Is available also when no instance is connected.
3
+ Is available also when no instance is setup.
4
4
 
5
5
  Modules:
6
6
 
lamindb/base/ids.py CHANGED
@@ -1,4 +1,4 @@
1
- """IDs.
1
+ """Universal IDs.
2
2
 
3
3
  Base generators:
4
4
 
@@ -55,15 +55,6 @@ def base62(n_char: int) -> str:
55
55
  return id
56
56
 
57
57
 
58
- # the following cannot be serialized by Django
59
- # class Base62:
60
- # def __init__(self, n_char: int):
61
- # self.n_char = n_char
62
-
63
- # def __call__(self):
64
- # return base62(self.n_char)
65
-
66
-
67
58
  def base26(n_char: int):
68
59
  """ASCII lowercase."""
69
60
  alphabet = string.ascii_lowercase
lamindb/core/__init__.py CHANGED
@@ -1,49 +1,20 @@
1
1
  """Core library.
2
2
 
3
- Registries:
4
-
5
- .. autosummary::
6
- :toctree: .
7
-
8
- BasicRecord
9
- Record
10
- Registry
11
- QuerySet
12
- QueryManager
13
- RecordList
14
- FeatureManager
15
- ParamManager
16
- LabelManager
17
- IsVersioned
18
- CanCurate
19
- HasParents
20
- TracksRun
21
- TracksUpdates
22
- ParamValue
23
- FeatureValue
24
- InspectResult
25
- ValidateFields
26
- fields
27
-
28
- Curators:
3
+ Settings & context:
29
4
 
30
5
  .. autosummary::
31
6
  :toctree: .
32
7
 
33
- CatManager
34
- DataFrameCatManager
35
- AnnDataCatManager
36
- MuDataCatManager
37
- TiledbsomaCatManager
38
- CurateLookup
8
+ Settings
9
+ subsettings
10
+ Context
39
11
 
40
- Settings & context:
12
+ Artifact loaders:
41
13
 
42
14
  .. autosummary::
43
15
  :toctree: .
44
16
 
45
- Settings
46
- Context
17
+ loaders
47
18
 
48
19
  Data loaders:
49
20
 
@@ -57,10 +28,8 @@ Modules:
57
28
  .. autosummary::
58
29
  :toctree: .
59
30
 
60
- loaders
61
31
  datasets
62
32
  storage
63
- subsettings
64
33
  logger
65
34
 
66
35
  """
@@ -68,35 +37,8 @@ Modules:
68
37
  from lamin_utils import logger
69
38
  from lamin_utils._inspect import InspectResult
70
39
 
71
- from lamindb._query_manager import QueryManager
72
- from lamindb._query_set import QuerySet, RecordList
73
- from lamindb.core._feature_manager import FeatureManager, ParamManager
74
- from lamindb.core._label_manager import LabelManager
75
- from lamindb.curators import (
76
- AnnDataCatManager,
77
- CatManager,
78
- CurateLookup,
79
- Curator,
80
- DataFrameCatManager,
81
- MuDataCatManager,
82
- TiledbsomaCatManager,
83
- )
84
- from lamindb.models import (
85
- BasicRecord,
86
- CanCurate,
87
- FeatureValue,
88
- HasParents,
89
- IsVersioned,
90
- ParamValue,
91
- Record,
92
- Registry,
93
- TracksRun,
94
- TracksUpdates,
95
- ValidateFields,
96
- )
97
-
98
40
  from .. import errors as exceptions
99
- from . import _data, datasets, fields, loaders, subsettings, types
41
+ from . import datasets, loaders, subsettings, types
100
42
  from ._context import Context
101
43
  from ._mapped_collection import MappedCollection
102
44
  from ._settings import Settings
lamindb/core/_context.py CHANGED
@@ -11,7 +11,7 @@ from pathlib import Path
11
11
  from typing import TYPE_CHECKING
12
12
 
13
13
  import lamindb_setup as ln_setup
14
- from django.db.models import Func, IntegerField
14
+ from django.db.models import Func, IntegerField, Q
15
15
  from lamin_utils import logger
16
16
  from lamindb_setup.core import deprecated
17
17
  from lamindb_setup.core.hashing import hash_file
@@ -20,21 +20,26 @@ from lamindb.base import ids
20
20
  from lamindb.base.ids import base62_12
21
21
  from lamindb.models import Run, Transform, format_field_value
22
22
 
23
+ from ..core._settings import settings
23
24
  from ..errors import (
24
25
  InconsistentKey,
26
+ InvalidArgument,
25
27
  TrackNotCalled,
26
28
  UpdateContext,
27
29
  )
28
- from ._settings import settings
30
+ from ..models._is_versioned import bump_version as bump_version_function
31
+ from ..models._is_versioned import (
32
+ increment_base62,
33
+ message_update_key_in_version_family,
34
+ )
29
35
  from ._sync_git import get_transform_reference_from_git_repo
30
36
  from ._track_environment import track_environment
31
- from .versioning import bump_version as bump_version_function
32
- from .versioning import increment_base62, message_update_key_in_version_family
33
37
 
34
38
  if TYPE_CHECKING:
35
39
  from lamindb_setup.core.types import UPathStr
36
40
 
37
41
  from lamindb.base.types import TransformType
42
+ from lamindb.models import Project
38
43
 
39
44
  is_run_from_ipython = getattr(builtins, "__IPYTHON__", False)
40
45
 
@@ -198,6 +203,7 @@ class Context:
198
203
  self._run: Run | None = None
199
204
  self._path: Path | None = None
200
205
  """A local path to the script that's running."""
206
+ self._project: Project | None = None
201
207
  self._logging_message_track: str = ""
202
208
  self._logging_message_imports: str = ""
203
209
  self._stream_tracker: LogStreamTracker = LogStreamTracker()
@@ -244,6 +250,11 @@ class Context:
244
250
  def version(self, value: str | None):
245
251
  self._version = value
246
252
 
253
+ @property
254
+ def project(self) -> Project | None:
255
+ """Project to label entities created during the run."""
256
+ return self._project
257
+
247
258
  @property
248
259
  def run(self) -> Run | None:
249
260
  """Managed run of context."""
@@ -253,10 +264,10 @@ class Context:
253
264
  self,
254
265
  transform: str | Transform | None = None,
255
266
  *,
267
+ project: str | None = None,
256
268
  params: dict | None = None,
257
269
  new_run: bool | None = None,
258
270
  path: str | None = None,
259
- log_to_file: bool | None = None,
260
271
  ) -> None:
261
272
  """Track a global run of your Python session.
262
273
 
@@ -270,14 +281,12 @@ class Context:
270
281
 
271
282
  Args:
272
283
  transform: A transform `uid` or record. If `None`, creates a `uid`.
284
+ project: A project `name` or `uid` for labeling entities created during the run.
273
285
  params: A dictionary of parameters to track for the run.
274
286
  new_run: If `False`, loads the latest run of transform
275
287
  (default notebook), if `True`, creates new run (default non-notebook).
276
288
  path: Filepath of notebook or script. Only needed if it can't be
277
289
  automatically detected.
278
- log_to_file: If `True`, logs stdout and stderr to a file and
279
- saves the file within the current run (default non-notebook),
280
- if `False`, does not log the output (default notebook).
281
290
 
282
291
  Examples:
283
292
 
@@ -290,6 +299,17 @@ class Context:
290
299
  >>> ln.track("Onv04I53OgtT0000") # example uid, the last four characters encode the version of the transform
291
300
 
292
301
  """
302
+ from lamindb.models import Project
303
+
304
+ if project is not None:
305
+ project_record = Project.filter(
306
+ Q(name=project) | Q(uid=project)
307
+ ).one_or_none()
308
+ if project_record is None:
309
+ raise InvalidArgument(
310
+ f"Project '{project}' not found, either create it with `ln.Project(name='...').save()` or fix typos."
311
+ )
312
+ self._project = project_record
293
313
  self._logging_message_track = ""
294
314
  self._logging_message_imports = ""
295
315
  if transform is not None and isinstance(transform, str):
@@ -375,6 +395,12 @@ class Context:
375
395
  )
376
396
  self._run = run
377
397
  track_environment(run)
398
+ if self.project is not None:
399
+ # to update a potential project link
400
+ # is only necessary if transform is loaded rather than newly created
401
+ # can be optimized by checking whether the transform is loaded, but it typically is
402
+ self.transform.save()
403
+ log_to_file = None
378
404
  if log_to_file is None:
379
405
  log_to_file = self.transform.type != "notebook"
380
406
  if log_to_file:
lamindb/core/_settings.py CHANGED
@@ -155,12 +155,12 @@ class Settings:
155
155
  def verbosity(self) -> str:
156
156
  """Logger verbosity (default `'warning'`).
157
157
 
158
- - `'error'`: only show error messages
159
- - `'warning'`: also show warning messages
160
- - `'success'`: also show success and save messages
161
- - `'info'`: 💡 also show info messages
162
- - `'hint'`: 💡 also show hint messages
163
- - `'debug'`: 🐛 also show detailed debug messages
158
+ - `'error'`: only show error messages
159
+ - `'warning'`: also show warning messages
160
+ - `'success'`: also show success and save messages
161
+ - `'info'`: also show info messages
162
+ - `'hint'`: also show hint messages
163
+ - `'debug'`: also show detailed debug messages
164
164
  """
165
165
  return VERBOSITY_TO_STR[self._verbosity_int]
166
166
 
lamindb/core/_sync_git.py CHANGED
@@ -7,7 +7,7 @@ from lamin_utils import logger
7
7
  from lamindb_setup import settings as setup_settings
8
8
  from lamindb_setup.core.hashing import hash_code
9
9
 
10
- from ._settings import sanitize_git_repo_url, settings
10
+ from ..core._settings import sanitize_git_repo_url, settings
11
11
 
12
12
 
13
13
  class BlobHashNotFound(SystemExit):
lamindb/core/loaders.py CHANGED
@@ -30,13 +30,13 @@ from lamindb_setup.core.upath import (
30
30
  infer_filesystem,
31
31
  )
32
32
 
33
- from ._settings import settings
33
+ from ..core._settings import settings
34
34
 
35
35
  if TYPE_CHECKING:
36
36
  from lamindb_setup.core.types import UPathStr
37
37
 
38
38
  try:
39
- from .storage._zarr import load_anndata_zarr
39
+ from ..core.storage._zarr import load_anndata_zarr
40
40
  except ImportError:
41
41
 
42
42
  def load_anndata_zarr(storepath): # type: ignore
@@ -179,8 +179,6 @@ def load_to_memory(filepath: UPathStr, **kwargs):
179
179
  """
180
180
  filepath = create_path(filepath)
181
181
 
182
- filepath = settings._storage_settings.cloud_to_local(filepath, print_progress=True)
183
-
184
182
  # infer the correct suffix when .gz is present
185
183
  suffixes = filepath.suffixes
186
184
  suffix = (
@@ -189,8 +187,11 @@ def load_to_memory(filepath: UPathStr, **kwargs):
189
187
  else filepath.suffix
190
188
  )
191
189
 
192
- loader = FILE_LOADERS.get(suffix)
190
+ loader = FILE_LOADERS.get(suffix, None)
193
191
  if loader is None:
194
- return filepath
195
- else:
196
- return loader(filepath, **kwargs)
192
+ raise NotImplementedError(
193
+ f"There is no loader for {suffix} files. Use .cache() to get the path."
194
+ )
195
+
196
+ filepath = settings._storage_settings.cloud_to_local(filepath, print_progress=True)
197
+ return loader(filepath, **kwargs)
@@ -5,8 +5,6 @@ from typing import TYPE_CHECKING, Any, Callable
5
5
 
6
6
  from anndata._io.specs.registry import get_spec
7
7
 
8
- from lamindb.models import Artifact
9
-
10
8
  from ._anndata_accessor import AnnDataAccessor, StorageType, registry
11
9
  from ._pyarrow_dataset import _is_pyarrow_dataset, _open_pyarrow_dataset
12
10
  from ._tiledbsoma import _open_tiledbsoma
@@ -19,6 +17,8 @@ if TYPE_CHECKING:
19
17
  from tiledbsoma import Experiment as SOMAExperiment
20
18
  from upath import UPath
21
19
 
20
+ from lamindb.models.artifact import Artifact
21
+
22
22
 
23
23
  # this dynamically creates a subclass of a context manager class
24
24
  # and reassigns it to an instance of the superclass
@@ -74,6 +74,8 @@ def backed_access(
74
74
  ) -> (
75
75
  AnnDataAccessor | BackedAccessor | SOMACollection | SOMAExperiment | PyArrowDataset
76
76
  ):
77
+ from lamindb.models import Artifact
78
+
77
79
  if isinstance(artifact_or_filepath, Artifact):
78
80
  objectpath, _ = filepath_from_artifact(
79
81
  artifact_or_filepath, using_key=using_key
@@ -12,8 +12,6 @@ from lamindb_setup.core._settings_storage import get_storage_region
12
12
  from lamindb_setup.core.upath import LocalPathClasses, create_path
13
13
  from packaging import version
14
14
 
15
- from lamindb.models import Artifact, Run
16
-
17
15
  if TYPE_CHECKING:
18
16
  from lamindb_setup.core.types import UPathStr
19
17
  from tiledbsoma import Collection as SOMACollection
@@ -21,6 +19,9 @@ if TYPE_CHECKING:
21
19
  from tiledbsoma import Measurement as SOMAMeasurement
22
20
  from upath import UPath
23
21
 
22
+ from lamindb.models.artifact import Artifact
23
+ from lamindb.models.run import Run
24
+
24
25
 
25
26
  def _load_h5ad_zarr(objpath: UPath):
26
27
  from lamindb.core.loaders import load_anndata_zarr, load_h5ad
@@ -134,9 +135,10 @@ def save_tiledbsoma_experiment(
134
135
  except ImportError as e:
135
136
  raise ImportError("Please install tiledbsoma: pip install tiledbsoma") from e
136
137
 
137
- from lamindb.core._data import get_run
138
138
  from lamindb.core.storage.paths import auto_storage_key_from_artifact_uid
139
- from lamindb.core.versioning import create_uid
139
+ from lamindb.models import Artifact
140
+ from lamindb.models._is_versioned import create_uid
141
+ from lamindb.models.artifact import get_run
140
142
 
141
143
  run = get_run(run)
142
144
 
@@ -1,14 +1,14 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import warnings
4
- from typing import TYPE_CHECKING
4
+ from typing import TYPE_CHECKING, Literal
5
5
 
6
6
  import scipy.sparse as sparse
7
7
  import zarr
8
8
  from anndata import __version__ as anndata_version
9
9
  from anndata._io.specs import write_elem
10
- from anndata._io.specs.registry import get_spec
11
10
  from fsspec.implementations.local import LocalFileSystem
11
+ from lamin_utils import logger
12
12
  from lamindb_setup.core.upath import create_mapper, infer_filesystem
13
13
  from packaging import version
14
14
 
@@ -25,15 +25,36 @@ if TYPE_CHECKING:
25
25
  from lamindb_setup.core.types import UPathStr
26
26
 
27
27
 
28
- def zarr_is_adata(storepath: UPathStr) -> bool:
28
+ def identify_zarr_type(
29
+ storepath: UPathStr, *, check: bool = True
30
+ ) -> Literal["anndata", "spatialdata", "unknown"]:
31
+ """Identify whether a zarr store is AnnData, SpatialData, or unknown type."""
32
+ # we can add these cheap suffix-based-checks later
33
+ # also need to check whether the .spatialdata.zarr suffix
34
+ # actually becomes a "standard"; currently we don't recognize it
35
+ # unlike ".anndata.zarr" in VALID_SUFFIXES
36
+ # suffixes = UPath(storepath).suffixes
37
+ # if ".spatialdata" in suffixes:
38
+ # return "spatialdata"
39
+ # elif ".anndata" in suffixes:
40
+ # return "anndata"
41
+
29
42
  fs, storepath_str = infer_filesystem(storepath)
43
+
30
44
  if isinstance(fs, LocalFileSystem):
31
- # this is faster than through an fsspec mapper for local
32
45
  open_obj = storepath_str
33
46
  else:
34
- open_obj = create_mapper(fs, storepath_str, check=True)
35
- storage = zarr.open(open_obj, mode="r")
36
- return get_spec(storage).encoding_type == "anndata"
47
+ open_obj = create_mapper(fs, storepath_str, check=check)
48
+
49
+ try:
50
+ storage = zarr.open(open_obj, mode="r")
51
+ if "spatialdata_attrs" in storage.attrs:
52
+ return "spatialdata"
53
+ if storage.attrs.get("encoding-type", "") == "anndata":
54
+ return "anndata"
55
+ except Exception as error:
56
+ logger.warning(f"an exception occured {error}")
57
+ return "unknown"
37
58
 
38
59
 
39
60
  def load_anndata_zarr(storepath: UPathStr) -> AnnData:
@@ -65,7 +86,7 @@ def write_adata_zarr(
65
86
  adata_size = None
66
87
  cumulative_val = 0
67
88
 
68
- def _cb(key_write: str | None = None):
89
+ def _report_progress(key_write: str | None = None):
69
90
  nonlocal adata_size
70
91
  nonlocal cumulative_val
71
92
 
@@ -91,9 +112,9 @@ def write_adata_zarr(
91
112
 
92
113
  def _write_elem_cb(f, k, elem, dataset_kwargs):
93
114
  write_elem(f, k, elem, dataset_kwargs=dataset_kwargs)
94
- _cb(k)
115
+ _report_progress(k)
95
116
 
96
- _cb(None)
117
+ _report_progress(None)
97
118
  with warnings.catch_warnings():
98
119
  warnings.filterwarnings("ignore", category=UserWarning, module="zarr")
99
120
 
@@ -114,4 +135,4 @@ def write_adata_zarr(
114
135
  )
115
136
  _write_elem_cb(f, "raw", adata.raw, dataset_kwargs=dataset_kwargs)
116
137
  # todo: fix size less than total at the end
117
- _cb(None)
138
+ _report_progress(None)