lamindb 0.69.7__py3-none-any.whl → 0.69.8__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 +1 -1
- lamindb/_annotate.py +46 -42
- lamindb/_artifact.py +63 -64
- lamindb/_can_validate.py +29 -25
- lamindb/_collection.py +28 -32
- lamindb/_feature.py +10 -8
- lamindb/_feature_set.py +17 -15
- lamindb/_filter.py +2 -2
- lamindb/_finish.py +14 -8
- lamindb/_from_values.py +13 -9
- lamindb/_is_versioned.py +2 -2
- lamindb/_parents.py +16 -11
- lamindb/_query_manager.py +8 -4
- lamindb/_query_set.py +15 -15
- lamindb/_registry.py +36 -34
- lamindb/_run.py +3 -5
- lamindb/_save.py +13 -11
- lamindb/_transform.py +9 -11
- lamindb/_ulabel.py +11 -9
- lamindb/_view.py +3 -2
- lamindb/core/_data.py +21 -17
- lamindb/core/_feature_manager.py +17 -12
- lamindb/core/_label_manager.py +13 -9
- lamindb/core/_mapped_collection.py +16 -12
- lamindb/core/_run_context.py +21 -17
- lamindb/core/_settings.py +19 -16
- lamindb/core/_sync_git.py +4 -5
- lamindb/core/_track_environment.py +6 -1
- lamindb/core/_transform_settings.py +3 -3
- lamindb/core/_view_tree.py +2 -1
- lamindb/core/datasets/_core.py +3 -2
- lamindb/core/datasets/_fake.py +2 -2
- lamindb/core/storage/_anndata_sizes.py +2 -0
- lamindb/core/storage/_backed_access.py +17 -12
- lamindb/core/storage/_zarr.py +7 -3
- lamindb/core/storage/file.py +10 -6
- lamindb/core/storage/object.py +7 -3
- lamindb/core/versioning.py +12 -8
- lamindb/integrations/_vitessce.py +2 -0
- {lamindb-0.69.7.dist-info → lamindb-0.69.8.dist-info}/METADATA +4 -4
- lamindb-0.69.8.dist-info/RECORD +54 -0
- lamindb-0.69.7.dist-info/RECORD +0 -54
- {lamindb-0.69.7.dist-info → lamindb-0.69.8.dist-info}/LICENSE +0 -0
- {lamindb-0.69.7.dist-info → lamindb-0.69.8.dist-info}/WHEEL +0 -0
lamindb/__init__.py
CHANGED
lamindb/_annotate.py
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
-
from
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import TYPE_CHECKING, Iterable
|
2
4
|
|
3
5
|
import anndata as ad
|
4
6
|
import lamindb_setup as ln_setup
|
5
7
|
import pandas as pd
|
6
8
|
from lamin_utils import colors, logger
|
7
9
|
from lnschema_core import Artifact, Collection, Feature, Registry, Run, ULabel
|
8
|
-
|
10
|
+
|
11
|
+
if TYPE_CHECKING:
|
12
|
+
from lnschema_core.types import FieldAttr
|
9
13
|
|
10
14
|
|
11
15
|
class ValidationError(ValueError):
|
@@ -19,9 +23,9 @@ class AnnotateLookup:
|
|
19
23
|
|
20
24
|
def __init__(
|
21
25
|
self,
|
22
|
-
categorials:
|
23
|
-
slots:
|
24
|
-
using:
|
26
|
+
categorials: dict[str, FieldAttr],
|
27
|
+
slots: dict[str, FieldAttr] = None,
|
28
|
+
using: str | None = None,
|
25
29
|
) -> None:
|
26
30
|
if slots is None:
|
27
31
|
slots = {}
|
@@ -91,8 +95,8 @@ class DataFrameAnnotator:
|
|
91
95
|
self,
|
92
96
|
df: pd.DataFrame,
|
93
97
|
columns: FieldAttr = Feature.name,
|
94
|
-
categoricals:
|
95
|
-
using:
|
98
|
+
categoricals: dict[str, FieldAttr] | None = None,
|
99
|
+
using: str | None = None,
|
96
100
|
verbosity: str = "hint",
|
97
101
|
**kwargs,
|
98
102
|
) -> None:
|
@@ -106,15 +110,15 @@ class DataFrameAnnotator:
|
|
106
110
|
self._artifact = None
|
107
111
|
self._collection = None
|
108
112
|
self._validated = False
|
109
|
-
self._kwargs:
|
113
|
+
self._kwargs: dict = kwargs
|
110
114
|
self._save_columns()
|
111
115
|
|
112
116
|
@property
|
113
|
-
def fields(self) ->
|
117
|
+
def fields(self) -> dict:
|
114
118
|
"""Return the columns fields to validate against."""
|
115
119
|
return self._fields
|
116
120
|
|
117
|
-
def lookup(self, using:
|
121
|
+
def lookup(self, using: str | None = None) -> AnnotateLookup:
|
118
122
|
"""Lookup features and labels.
|
119
123
|
|
120
124
|
Args:
|
@@ -260,11 +264,11 @@ class DataFrameAnnotator:
|
|
260
264
|
|
261
265
|
def save_collection(
|
262
266
|
self,
|
263
|
-
artifact:
|
267
|
+
artifact: Artifact | Iterable[Artifact],
|
264
268
|
name: str,
|
265
|
-
description:
|
266
|
-
reference:
|
267
|
-
reference_type:
|
269
|
+
description: str | None = None,
|
270
|
+
reference: str | None = None,
|
271
|
+
reference_type: str | None = None,
|
268
272
|
) -> Collection:
|
269
273
|
"""Save a collection from artifact/artifacts.
|
270
274
|
|
@@ -319,7 +323,7 @@ class AnnDataAnnotator(DataFrameAnnotator):
|
|
319
323
|
self,
|
320
324
|
adata: ad.AnnData,
|
321
325
|
var_index: FieldAttr,
|
322
|
-
categoricals:
|
326
|
+
categoricals: dict[str, FieldAttr],
|
323
327
|
using: str = "default",
|
324
328
|
verbosity: str = "hint",
|
325
329
|
**kwargs,
|
@@ -342,11 +346,11 @@ class AnnDataAnnotator(DataFrameAnnotator):
|
|
342
346
|
return self._var_field
|
343
347
|
|
344
348
|
@property
|
345
|
-
def categoricals(self) ->
|
349
|
+
def categoricals(self) -> dict:
|
346
350
|
"""Return the obs fields to validate against."""
|
347
351
|
return self._obs_fields
|
348
352
|
|
349
|
-
def lookup(self, using:
|
353
|
+
def lookup(self, using: str | None = None) -> AnnotateLookup:
|
350
354
|
"""Lookup features and labels."""
|
351
355
|
return AnnotateLookup(
|
352
356
|
categorials=self._obs_fields,
|
@@ -413,9 +417,9 @@ class Annotate:
|
|
413
417
|
def from_df(
|
414
418
|
cls,
|
415
419
|
df: pd.DataFrame,
|
416
|
-
categoricals:
|
420
|
+
categoricals: dict[str, FieldAttr] | None = None,
|
417
421
|
columns: FieldAttr = Feature.name,
|
418
|
-
using:
|
422
|
+
using: str | None = None,
|
419
423
|
verbosity: str = "hint",
|
420
424
|
**kwargs,
|
421
425
|
) -> DataFrameAnnotator:
|
@@ -433,7 +437,7 @@ class Annotate:
|
|
433
437
|
cls,
|
434
438
|
adata: ad.AnnData,
|
435
439
|
var_index: FieldAttr,
|
436
|
-
categoricals:
|
440
|
+
categoricals: dict[str, FieldAttr],
|
437
441
|
using: str = "default",
|
438
442
|
verbosity: str = "hint",
|
439
443
|
**kwargs,
|
@@ -448,7 +452,7 @@ class Annotate:
|
|
448
452
|
)
|
449
453
|
|
450
454
|
|
451
|
-
def get_registry_instance(registry: Registry, using:
|
455
|
+
def get_registry_instance(registry: Registry, using: str | None = None) -> Registry:
|
452
456
|
"""Get a registry instance using a specific instance."""
|
453
457
|
if using is not None and using != "default":
|
454
458
|
return registry.using(using)
|
@@ -465,8 +469,8 @@ def standardize_and_inspect(
|
|
465
469
|
|
466
470
|
|
467
471
|
def check_registry_organism(
|
468
|
-
registry: Registry, organism:
|
469
|
-
) ->
|
472
|
+
registry: Registry, organism: str | None = None
|
473
|
+
) -> str | None:
|
470
474
|
"""Check if a registry needs an organism and return the organism name."""
|
471
475
|
if hasattr(registry, "organism_id"):
|
472
476
|
import bionty as bt
|
@@ -484,7 +488,7 @@ def validate_categories(
|
|
484
488
|
values: Iterable[str],
|
485
489
|
field: FieldAttr,
|
486
490
|
key: str,
|
487
|
-
using:
|
491
|
+
using: str | None = None,
|
488
492
|
**kwargs,
|
489
493
|
) -> bool:
|
490
494
|
"""Validate ontology terms in a pandas series using LaminDB registries."""
|
@@ -560,8 +564,8 @@ def validate_categories(
|
|
560
564
|
|
561
565
|
def validate_categories_in_df(
|
562
566
|
df: pd.DataFrame,
|
563
|
-
fields:
|
564
|
-
using:
|
567
|
+
fields: dict[str, FieldAttr],
|
568
|
+
using: str | None = None,
|
565
569
|
**kwargs,
|
566
570
|
) -> bool:
|
567
571
|
"""Validate categories in DataFrame columns using LaminDB registries."""
|
@@ -580,8 +584,8 @@ def validate_categories_in_df(
|
|
580
584
|
def validate_anndata(
|
581
585
|
adata: ad.AnnData,
|
582
586
|
var_field: FieldAttr,
|
583
|
-
obs_fields:
|
584
|
-
using:
|
587
|
+
obs_fields: dict[str, FieldAttr],
|
588
|
+
using: str | None = None,
|
585
589
|
**kwargs,
|
586
590
|
) -> bool:
|
587
591
|
"""Inspect metadata in an AnnData object using LaminDB registries."""
|
@@ -604,9 +608,9 @@ def validate_anndata(
|
|
604
608
|
|
605
609
|
|
606
610
|
def save_artifact(
|
607
|
-
data:
|
611
|
+
data: pd.DataFrame | ad.AnnData,
|
608
612
|
description: str,
|
609
|
-
fields:
|
613
|
+
fields: dict[str, FieldAttr],
|
610
614
|
columns_field: FieldAttr,
|
611
615
|
**kwargs,
|
612
616
|
) -> Artifact:
|
@@ -631,7 +635,7 @@ def save_artifact(
|
|
631
635
|
raise ValueError("data must be a DataFrame or AnnData object")
|
632
636
|
artifact.save()
|
633
637
|
|
634
|
-
feature_kwargs:
|
638
|
+
feature_kwargs: dict = {}
|
635
639
|
organism = check_registry_organism(
|
636
640
|
columns_field.field.model, kwargs.pop("organism", None)
|
637
641
|
)
|
@@ -662,14 +666,14 @@ def save_artifact(
|
|
662
666
|
|
663
667
|
|
664
668
|
def update_registry(
|
665
|
-
values:
|
669
|
+
values: list[str],
|
666
670
|
field: FieldAttr,
|
667
671
|
key: str,
|
668
672
|
save_function: str = "add_new_from",
|
669
|
-
using:
|
673
|
+
using: str | None = None,
|
670
674
|
validated_only: bool = True,
|
671
|
-
kwargs:
|
672
|
-
df:
|
675
|
+
kwargs: dict | None = None,
|
676
|
+
df: pd.DataFrame | None = None,
|
673
677
|
) -> None:
|
674
678
|
"""Save features or labels records in the default instance from the using instance.
|
675
679
|
|
@@ -703,7 +707,7 @@ def update_registry(
|
|
703
707
|
settings.verbosity = verbosity
|
704
708
|
return
|
705
709
|
|
706
|
-
labels_saved:
|
710
|
+
labels_saved: dict = {"from public": [], "without reference": []}
|
707
711
|
|
708
712
|
(
|
709
713
|
labels_saved[f"from {using}"],
|
@@ -757,7 +761,7 @@ def update_registry(
|
|
757
761
|
|
758
762
|
|
759
763
|
def log_saved_labels(
|
760
|
-
labels_saved:
|
764
|
+
labels_saved: dict,
|
761
765
|
key: str,
|
762
766
|
save_function: str,
|
763
767
|
model_field: str,
|
@@ -795,7 +799,7 @@ def log_saved_labels(
|
|
795
799
|
)
|
796
800
|
|
797
801
|
|
798
|
-
def save_ulabels_with_parent(values:
|
802
|
+
def save_ulabels_with_parent(values: list[str], field: FieldAttr, key: str) -> None:
|
799
803
|
"""Save a parent label for the given labels."""
|
800
804
|
registry = field.field.model
|
801
805
|
assert registry == ULabel
|
@@ -808,11 +812,11 @@ def save_ulabels_with_parent(values: List[str], field: FieldAttr, key: str) -> N
|
|
808
812
|
|
809
813
|
|
810
814
|
def update_registry_from_using_instance(
|
811
|
-
values:
|
815
|
+
values: list[str],
|
812
816
|
field: FieldAttr,
|
813
|
-
using:
|
814
|
-
kwargs:
|
815
|
-
) ->
|
817
|
+
using: str | None = None,
|
818
|
+
kwargs: dict | None = None,
|
819
|
+
) -> tuple[list[str], list[str]]:
|
816
820
|
"""Save features or labels records from the using instance.
|
817
821
|
|
818
822
|
Args:
|
lamindb/_artifact.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
from pathlib import Path, PurePath, PurePosixPath
|
2
|
-
from typing import TYPE_CHECKING, Any
|
4
|
+
from typing import TYPE_CHECKING, Any
|
3
5
|
|
4
6
|
import fsspec
|
5
7
|
import lamindb_setup as ln_setup
|
@@ -11,7 +13,6 @@ from lamindb_setup._init_instance import register_storage
|
|
11
13
|
from lamindb_setup.core import StorageSettings
|
12
14
|
from lamindb_setup.core._docs import doc_args
|
13
15
|
from lamindb_setup.core.hashing import b16_to_b64, hash_file, hash_md5s_from_dir
|
14
|
-
from lamindb_setup.core.types import UPathStr
|
15
16
|
from lamindb_setup.core.upath import (
|
16
17
|
create_path,
|
17
18
|
extract_suffix_from_path,
|
@@ -53,15 +54,17 @@ from .core._data import (
|
|
53
54
|
from .core.storage.file import AUTO_KEY_PREFIX
|
54
55
|
|
55
56
|
if TYPE_CHECKING:
|
57
|
+
from lamindb_setup.core.types import UPathStr
|
58
|
+
|
56
59
|
from lamindb.core.storage._backed_access import AnnDataAccessor, BackedAccessor
|
57
60
|
|
58
61
|
|
59
62
|
def process_pathlike(
|
60
63
|
filepath: UPath,
|
61
64
|
default_storage: Storage,
|
62
|
-
using_key:
|
65
|
+
using_key: str | None,
|
63
66
|
skip_existence_check: bool = False,
|
64
|
-
) ->
|
67
|
+
) -> tuple[Storage, bool]:
|
65
68
|
if not skip_existence_check:
|
66
69
|
try: # check if file exists
|
67
70
|
if not filepath.exists():
|
@@ -111,13 +114,13 @@ def process_pathlike(
|
|
111
114
|
|
112
115
|
def process_data(
|
113
116
|
provisional_uid: str,
|
114
|
-
data:
|
115
|
-
format:
|
116
|
-
key:
|
117
|
+
data: UPathStr | DataLike,
|
118
|
+
format: str | None,
|
119
|
+
key: str | None,
|
117
120
|
default_storage: Storage,
|
118
|
-
using_key:
|
121
|
+
using_key: str | None,
|
119
122
|
skip_existence_check: bool = False,
|
120
|
-
) ->
|
123
|
+
) -> tuple[Any, Path | UPath, str, Storage, bool]:
|
121
124
|
"""Serialize a data object that's provided as file or in memory."""
|
122
125
|
# if not overwritten, data gets stored in default storage
|
123
126
|
if isinstance(data, (str, Path, UPath)): # UPathStr, spelled out
|
@@ -170,10 +173,10 @@ def process_data(
|
|
170
173
|
def get_stat_or_artifact(
|
171
174
|
path: UPath,
|
172
175
|
suffix: str,
|
173
|
-
memory_rep:
|
176
|
+
memory_rep: Any | None = None,
|
174
177
|
check_hash: bool = True,
|
175
|
-
using_key:
|
176
|
-
) ->
|
178
|
+
using_key: str | None = None,
|
179
|
+
) -> tuple[int, str | None, str | None, int | None] | Artifact:
|
177
180
|
n_objects = None
|
178
181
|
if settings.upon_file_create_skip_size_hash:
|
179
182
|
return None, None, None, n_objects
|
@@ -245,8 +248,8 @@ def get_stat_or_artifact(
|
|
245
248
|
|
246
249
|
|
247
250
|
def check_path_in_existing_storage(
|
248
|
-
path:
|
249
|
-
) ->
|
251
|
+
path: Path | UPath, using_key: str | None
|
252
|
+
) -> Storage | bool:
|
250
253
|
for storage in Storage.objects.using(using_key).filter().all():
|
251
254
|
# if path is part of storage, return it
|
252
255
|
if check_path_is_child_of_root(path, root=create_path(storage.root)):
|
@@ -254,9 +257,7 @@ def check_path_in_existing_storage(
|
|
254
257
|
return False
|
255
258
|
|
256
259
|
|
257
|
-
def check_path_is_child_of_root(
|
258
|
-
path: Union[Path, UPath], root: Optional[Union[Path, UPath]]
|
259
|
-
) -> bool:
|
260
|
+
def check_path_is_child_of_root(path: Path | UPath, root: Path | UPath | None) -> bool:
|
260
261
|
path = UPath(str(path)) if not isinstance(path, UPath) else path
|
261
262
|
root = UPath(str(root)) if not isinstance(root, UPath) else root
|
262
263
|
|
@@ -276,8 +277,8 @@ def check_path_is_child_of_root(
|
|
276
277
|
|
277
278
|
|
278
279
|
def get_relative_path_to_directory(
|
279
|
-
path:
|
280
|
-
) ->
|
280
|
+
path: PurePath | Path | UPath, directory: PurePath | Path | UPath
|
281
|
+
) -> PurePath | Path:
|
281
282
|
if isinstance(directory, UPath) and not isinstance(directory, LocalPathClasses):
|
282
283
|
# UPath.relative_to() is not behaving as it should (2023-04-07)
|
283
284
|
# need to lstrip otherwise inconsistent behavior across trailing slashes
|
@@ -296,13 +297,13 @@ def get_relative_path_to_directory(
|
|
296
297
|
|
297
298
|
def get_artifact_kwargs_from_data(
|
298
299
|
*,
|
299
|
-
data:
|
300
|
-
key:
|
301
|
-
run:
|
302
|
-
format:
|
300
|
+
data: Path | UPath | str | pd.DataFrame | AnnData,
|
301
|
+
key: str | None,
|
302
|
+
run: Run | None,
|
303
|
+
format: str | None,
|
303
304
|
provisional_uid: str,
|
304
305
|
default_storage: Storage,
|
305
|
-
using_key:
|
306
|
+
using_key: str | None = None,
|
306
307
|
skip_check_exists: bool = False,
|
307
308
|
):
|
308
309
|
run = get_run(run)
|
@@ -399,8 +400,8 @@ def get_artifact_kwargs_from_data(
|
|
399
400
|
def log_storage_hint(
|
400
401
|
*,
|
401
402
|
check_path_in_storage: bool,
|
402
|
-
storage:
|
403
|
-
key:
|
403
|
+
storage: Storage | None,
|
404
|
+
key: str | None,
|
404
405
|
uid: str,
|
405
406
|
suffix: str,
|
406
407
|
is_dir: bool,
|
@@ -447,7 +448,7 @@ def data_is_mudata(data: DataLike): # pragma: no cover
|
|
447
448
|
return False
|
448
449
|
|
449
450
|
|
450
|
-
def _check_accessor_artifact(data: Any, accessor:
|
451
|
+
def _check_accessor_artifact(data: Any, accessor: str | None = None):
|
451
452
|
if accessor is None and not isinstance(data, (str, Path, UPath)):
|
452
453
|
if isinstance(data, pd.DataFrame):
|
453
454
|
logger.warning("data is a DataFrame, please use .from_df()")
|
@@ -476,17 +477,17 @@ def __init__(artifact: Artifact, *args, **kwargs):
|
|
476
477
|
if len(args) > 1:
|
477
478
|
raise ValueError("Only one non-keyword arg allowed: data")
|
478
479
|
|
479
|
-
data:
|
480
|
-
key:
|
481
|
-
run:
|
482
|
-
description:
|
480
|
+
data: str | Path = kwargs.pop("data") if len(args) == 0 else args[0]
|
481
|
+
key: str | None = kwargs.pop("key") if "key" in kwargs else None
|
482
|
+
run: Run | None = kwargs.pop("run") if "run" in kwargs else None
|
483
|
+
description: str | None = (
|
483
484
|
kwargs.pop("description") if "description" in kwargs else None
|
484
485
|
)
|
485
|
-
is_new_version_of:
|
486
|
+
is_new_version_of: Artifact | None = (
|
486
487
|
kwargs.pop("is_new_version_of") if "is_new_version_of" in kwargs else None
|
487
488
|
)
|
488
|
-
version:
|
489
|
-
visibility:
|
489
|
+
version: str | None = kwargs.pop("version") if "version" in kwargs else None
|
490
|
+
visibility: int | None = (
|
490
491
|
kwargs.pop("visibility")
|
491
492
|
if "visibility" in kwargs
|
492
493
|
else VisibilityChoice.default.value
|
@@ -571,14 +572,14 @@ def __init__(artifact: Artifact, *args, **kwargs):
|
|
571
572
|
@doc_args(Artifact.from_df.__doc__)
|
572
573
|
def from_df(
|
573
574
|
cls,
|
574
|
-
df:
|
575
|
-
key:
|
576
|
-
description:
|
577
|
-
run:
|
578
|
-
version:
|
579
|
-
is_new_version_of:
|
575
|
+
df: pd.DataFrame,
|
576
|
+
key: str | None = None,
|
577
|
+
description: str | None = None,
|
578
|
+
run: Run | None = None,
|
579
|
+
version: str | None = None,
|
580
|
+
is_new_version_of: Artifact | None = None,
|
580
581
|
**kwargs,
|
581
|
-
) ->
|
582
|
+
) -> Artifact:
|
582
583
|
"""{}."""
|
583
584
|
artifact = Artifact(
|
584
585
|
data=df,
|
@@ -597,14 +598,14 @@ def from_df(
|
|
597
598
|
@doc_args(Artifact.from_anndata.__doc__)
|
598
599
|
def from_anndata(
|
599
600
|
cls,
|
600
|
-
adata:
|
601
|
-
key:
|
602
|
-
description:
|
603
|
-
run:
|
604
|
-
version:
|
605
|
-
is_new_version_of:
|
601
|
+
adata: AnnData,
|
602
|
+
key: str | None = None,
|
603
|
+
description: str | None = None,
|
604
|
+
run: Run | None = None,
|
605
|
+
version: str | None = None,
|
606
|
+
is_new_version_of: Artifact | None = None,
|
606
607
|
**kwargs,
|
607
|
-
) ->
|
608
|
+
) -> Artifact:
|
608
609
|
"""{}."""
|
609
610
|
artifact = Artifact(
|
610
611
|
data=adata,
|
@@ -624,10 +625,10 @@ def from_anndata(
|
|
624
625
|
def from_dir(
|
625
626
|
cls,
|
626
627
|
path: UPathStr,
|
627
|
-
key:
|
628
|
+
key: str | None = None,
|
628
629
|
*,
|
629
|
-
run:
|
630
|
-
) ->
|
630
|
+
run: Run | None = None,
|
631
|
+
) -> list[Artifact]:
|
631
632
|
"""{}."""
|
632
633
|
logger.warning(
|
633
634
|
"this creates one artifact per file in the directory - you might simply call"
|
@@ -639,7 +640,7 @@ def from_dir(
|
|
639
640
|
storage, use_existing_storage = process_pathlike(
|
640
641
|
folderpath, default_storage, using_key
|
641
642
|
)
|
642
|
-
folder_key_path:
|
643
|
+
folder_key_path: PurePath | Path
|
643
644
|
if key is None:
|
644
645
|
if not use_existing_storage:
|
645
646
|
logger.warning(
|
@@ -724,9 +725,9 @@ def from_dir(
|
|
724
725
|
# docstring handled through attach_func_to_class_method
|
725
726
|
def replace(
|
726
727
|
self,
|
727
|
-
data:
|
728
|
-
run:
|
729
|
-
format:
|
728
|
+
data: UPathStr | DataLike,
|
729
|
+
run: Run | None = None,
|
730
|
+
format: str | None = None,
|
730
731
|
) -> None:
|
731
732
|
default_storage = settings._storage_settings.record
|
732
733
|
kwargs, privates = get_artifact_kwargs_from_data(
|
@@ -784,9 +785,7 @@ def replace(
|
|
784
785
|
|
785
786
|
|
786
787
|
# docstring handled through attach_func_to_class_method
|
787
|
-
def backed(
|
788
|
-
self, is_run_input: Optional[bool] = None
|
789
|
-
) -> Union["AnnDataAccessor", "BackedAccessor"]:
|
788
|
+
def backed(self, is_run_input: bool | None = None) -> AnnDataAccessor | BackedAccessor:
|
790
789
|
suffixes = (".h5", ".hdf5", ".h5ad", ".zrad", ".zarr")
|
791
790
|
if self.suffix not in suffixes:
|
792
791
|
raise ValueError(
|
@@ -810,7 +809,7 @@ def backed(
|
|
810
809
|
|
811
810
|
# docstring handled through attach_func_to_class_method
|
812
811
|
def load(
|
813
|
-
self, is_run_input:
|
812
|
+
self, is_run_input: bool | None = None, stream: bool = False, **kwargs
|
814
813
|
) -> DataLike:
|
815
814
|
_track_run_input(self, is_run_input)
|
816
815
|
if hasattr(self, "_memory_rep") and self._memory_rep is not None:
|
@@ -822,7 +821,7 @@ def load(
|
|
822
821
|
|
823
822
|
|
824
823
|
# docstring handled through attach_func_to_class_method
|
825
|
-
def stage(self, is_run_input:
|
824
|
+
def stage(self, is_run_input: bool | None = None) -> Path:
|
826
825
|
_track_run_input(self, is_run_input)
|
827
826
|
|
828
827
|
using_key = settings._using_key
|
@@ -833,9 +832,9 @@ def stage(self, is_run_input: Optional[bool] = None) -> Path:
|
|
833
832
|
# docstring handled through attach_func_to_class_method
|
834
833
|
def delete(
|
835
834
|
self,
|
836
|
-
permanent:
|
837
|
-
storage:
|
838
|
-
using_key:
|
835
|
+
permanent: bool | None = None,
|
836
|
+
storage: bool | None = None,
|
837
|
+
using_key: str | None = None,
|
839
838
|
) -> None:
|
840
839
|
# by default, we only move artifacts into the trash (visibility = -1)
|
841
840
|
trash_visibility = VisibilityChoice.trash.value
|
@@ -927,7 +926,7 @@ def _save_skip_storage(file, *args, **kwargs) -> None:
|
|
927
926
|
|
928
927
|
@property # type: ignore
|
929
928
|
@doc_args(Artifact.path.__doc__)
|
930
|
-
def path(self) ->
|
929
|
+
def path(self) -> Path | UPath:
|
931
930
|
"""{}."""
|
932
931
|
using_key = settings._using_key
|
933
932
|
return filepath_from_artifact(self, using_key)
|