lamindb 1.1.0__py3-none-any.whl → 1.2.0__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 (74) hide show
  1. lamindb/__init__.py +33 -26
  2. lamindb/_finish.py +9 -1
  3. lamindb/_tracked.py +26 -3
  4. lamindb/_view.py +2 -3
  5. lamindb/base/__init__.py +1 -1
  6. lamindb/base/ids.py +1 -10
  7. lamindb/base/users.py +1 -4
  8. lamindb/core/__init__.py +7 -65
  9. lamindb/core/_compat.py +60 -0
  10. lamindb/core/_context.py +50 -22
  11. lamindb/core/_mapped_collection.py +4 -2
  12. lamindb/core/_settings.py +6 -6
  13. lamindb/core/_sync_git.py +1 -1
  14. lamindb/core/_track_environment.py +2 -1
  15. lamindb/core/datasets/_small.py +3 -3
  16. lamindb/core/loaders.py +43 -20
  17. lamindb/core/storage/_anndata_accessor.py +8 -3
  18. lamindb/core/storage/_backed_access.py +14 -7
  19. lamindb/core/storage/_pyarrow_dataset.py +24 -9
  20. lamindb/core/storage/_tiledbsoma.py +8 -6
  21. lamindb/core/storage/_zarr.py +104 -25
  22. lamindb/core/storage/objects.py +63 -28
  23. lamindb/core/storage/paths.py +16 -13
  24. lamindb/core/types.py +10 -0
  25. lamindb/curators/__init__.py +176 -149
  26. lamindb/errors.py +1 -1
  27. lamindb/integrations/_vitessce.py +4 -4
  28. lamindb/migrations/0089_subsequent_runs.py +159 -0
  29. lamindb/migrations/0090_runproject_project_runs.py +73 -0
  30. lamindb/migrations/{0088_squashed.py → 0090_squashed.py} +245 -177
  31. lamindb/models/__init__.py +79 -0
  32. lamindb/{core → models}/_describe.py +3 -3
  33. lamindb/{core → models}/_django.py +8 -5
  34. lamindb/{core → models}/_feature_manager.py +103 -87
  35. lamindb/{_from_values.py → models/_from_values.py} +5 -2
  36. lamindb/{core/versioning.py → models/_is_versioned.py} +94 -6
  37. lamindb/{core → models}/_label_manager.py +10 -17
  38. lamindb/{core/relations.py → models/_relations.py} +8 -1
  39. lamindb/models/artifact.py +2602 -0
  40. lamindb/{_can_curate.py → models/can_curate.py} +349 -180
  41. lamindb/models/collection.py +683 -0
  42. lamindb/models/core.py +135 -0
  43. lamindb/models/feature.py +643 -0
  44. lamindb/models/flextable.py +163 -0
  45. lamindb/{_parents.py → models/has_parents.py} +55 -49
  46. lamindb/models/project.py +384 -0
  47. lamindb/{_query_manager.py → models/query_manager.py} +10 -8
  48. lamindb/{_query_set.py → models/query_set.py} +64 -32
  49. lamindb/models/record.py +1762 -0
  50. lamindb/models/run.py +563 -0
  51. lamindb/{_save.py → models/save.py} +18 -8
  52. lamindb/models/schema.py +732 -0
  53. lamindb/models/transform.py +360 -0
  54. lamindb/models/ulabel.py +249 -0
  55. {lamindb-1.1.0.dist-info → lamindb-1.2.0.dist-info}/METADATA +6 -6
  56. lamindb-1.2.0.dist-info/RECORD +95 -0
  57. lamindb/_artifact.py +0 -1361
  58. lamindb/_collection.py +0 -440
  59. lamindb/_feature.py +0 -316
  60. lamindb/_is_versioned.py +0 -40
  61. lamindb/_record.py +0 -1065
  62. lamindb/_run.py +0 -60
  63. lamindb/_schema.py +0 -347
  64. lamindb/_storage.py +0 -15
  65. lamindb/_transform.py +0 -170
  66. lamindb/_ulabel.py +0 -56
  67. lamindb/_utils.py +0 -9
  68. lamindb/base/validation.py +0 -63
  69. lamindb/core/_data.py +0 -491
  70. lamindb/core/fields.py +0 -12
  71. lamindb/models.py +0 -4435
  72. lamindb-1.1.0.dist-info/RECORD +0 -95
  73. {lamindb-1.1.0.dist-info → lamindb-1.2.0.dist-info}/LICENSE +0 -0
  74. {lamindb-1.1.0.dist-info → lamindb-1.2.0.dist-info}/WHEEL +0 -0
@@ -11,13 +11,14 @@ from lamindb_setup.core.upath import (
11
11
  )
12
12
 
13
13
  from lamindb.core._settings import settings
14
- from lamindb.models import Artifact, Storage
15
14
 
16
15
  if TYPE_CHECKING:
17
16
  from pathlib import Path
18
17
 
19
18
  from lamindb_setup.core.types import UPathStr
20
19
 
20
+ from lamindb.models.artifact import Artifact
21
+
21
22
 
22
23
  AUTO_KEY_PREFIX = ".lamindb/"
23
24
 
@@ -41,24 +42,21 @@ def auto_storage_key_from_artifact_uid(uid: str, suffix: str, is_dir: bool) -> s
41
42
  return storage_key
42
43
 
43
44
 
44
- def _safely_resolve(upath: UPath) -> UPath:
45
- if upath.protocol in {"http", "https"}:
46
- resolve_kwargs = {"follow_redirects": False}
47
- else:
48
- resolve_kwargs = {}
49
- return upath.resolve(**resolve_kwargs)
50
-
51
-
52
45
  def check_path_is_child_of_root(path: UPathStr, root: UPathStr) -> bool:
53
46
  if fsspec.utils.get_protocol(str(path)) != fsspec.utils.get_protocol(str(root)):
54
47
  return False
55
- path_upath = _safely_resolve(UPath(path))
56
- root_upath = _safely_resolve(UPath(root))
48
+ path_upath = UPath(path)
49
+ root_upath = UPath(root)
57
50
  if path_upath.protocol == "s3":
58
51
  endpoint_path = path_upath.storage_options.get("endpoint_url", "")
59
52
  endpoint_root = root_upath.storage_options.get("endpoint_url", "")
60
53
  if endpoint_path != endpoint_root:
61
54
  return False
55
+ # we don't resolve http links because they can resolve into a different domain
56
+ # for example into a temporary url
57
+ if path_upath.protocol not in {"http", "https"}:
58
+ path_upath = path_upath.resolve()
59
+ root_upath = root_upath.resolve()
62
60
  # str is needed to eliminate UPath storage_options
63
61
  # which affect equality checks
64
62
  return UPath(str(root_upath)) in UPath(str(path_upath)).parents
@@ -73,6 +71,8 @@ def attempt_accessing_path(
73
71
  ) -> tuple[UPath, StorageSettings]:
74
72
  # check whether the file is in the default db and whether storage
75
73
  # matches default storage
74
+ from lamindb.models import Storage
75
+
76
76
  if (
77
77
  artifact._state.db in ("default", None)
78
78
  and artifact.storage_id == settings._storage_settings.id
@@ -134,7 +134,7 @@ def filepath_cache_key_from_artifact(
134
134
 
135
135
 
136
136
  def store_file_or_folder(
137
- local_path: UPathStr, storage_path: UPath, print_progress: bool = True
137
+ local_path: UPathStr, storage_path: UPath, print_progress: bool = True, **kwargs
138
138
  ) -> None:
139
139
  """Store file or folder (localpath) at storagepath."""
140
140
  local_path = UPath(local_path)
@@ -155,7 +155,10 @@ def store_file_or_folder(
155
155
  else:
156
156
  create_folder = None
157
157
  storage_path.upload_from(
158
- local_path, create_folder=create_folder, print_progress=print_progress
158
+ local_path,
159
+ create_folder=create_folder,
160
+ print_progress=print_progress,
161
+ **kwargs,
159
162
  )
160
163
  else: # storage path is local
161
164
  if local_path.resolve().as_posix() == storage_path.resolve().as_posix():
lamindb/core/types.py CHANGED
@@ -1,3 +1,8 @@
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 (
@@ -7,3 +12,8 @@ from lamindb.base.types import (
7
12
  StrField,
8
13
  TransformType,
9
14
  )
15
+
16
+ MuData = TypeVar("MuData")
17
+ SpatialData = TypeVar("SpatialData")
18
+
19
+ ScverseDataStructures = AnnData | MuData | SpatialData