lamindb 0.63.5__py3-none-any.whl → 0.64.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.
@@ -13,7 +13,7 @@ from lamindb_setup.dev.upath import (
13
13
  create_path,
14
14
  infer_filesystem,
15
15
  )
16
- from lnschema_core.models import File, Storage
16
+ from lnschema_core.models import Artifact, Storage
17
17
 
18
18
  try:
19
19
  from ._zarr import read_adata_zarr
@@ -27,31 +27,42 @@ AUTO_KEY_PREFIX = ".lamindb/"
27
27
 
28
28
 
29
29
  # add type annotations back asap when re-organizing the module
30
- def auto_storage_key_from_file(file: File):
31
- if file.key is None or file.key_is_virtual:
32
- return auto_storage_key_from_id_suffix(file.uid, file.suffix)
30
+ def auto_storage_key_from_artifact(artifact: Artifact):
31
+ if artifact.key is None or artifact.key_is_virtual:
32
+ is_dir = artifact.n_objects is not None
33
+ return auto_storage_key_from_artifact_uid(artifact.uid, artifact.suffix, is_dir)
33
34
  else:
34
- return file.key
35
+ return artifact.key
35
36
 
36
37
 
37
- def auto_storage_key_from_id_suffix(uid: str, suffix: str) -> str:
38
- assert isinstance(uid, str)
38
+ def auto_storage_key_from_artifact_uid(uid: str, suffix: str, is_dir: bool) -> str:
39
39
  assert isinstance(suffix, str)
40
- storage_key = f"{AUTO_KEY_PREFIX}{uid}{suffix}"
40
+ if is_dir:
41
+ uid_storage = uid[:16] # 16 chars, leave 4 chars for versioning
42
+ else:
43
+ uid_storage = uid
44
+ storage_key = f"{AUTO_KEY_PREFIX}{uid_storage}{suffix}"
41
45
  return storage_key
42
46
 
43
47
 
44
- def attempt_accessing_path(file: File, storage_key: str):
48
+ def attempt_accessing_path(artifact: Artifact, storage_key: str):
45
49
  # check whether the file is in the default db and whether storage
46
50
  # matches default storage
47
- if file._state.db in ("default", None) and file.storage_id == settings.storage.id:
51
+ if (
52
+ artifact._state.db in ("default", None)
53
+ and artifact.storage_id == settings.storage.id
54
+ ):
48
55
  path = settings.storage.key_to_filepath(storage_key)
49
56
  else:
50
- logger.debug("file.path is slightly slower for files outside default storage")
51
- if file._state.db not in ("default", None):
52
- storage = Storage.using(file._state.db).filter(id=file.storage_id).one()
57
+ logger.debug(
58
+ "artifact.path is slightly slower for files outside default storage"
59
+ )
60
+ if artifact._state.db not in ("default", None):
61
+ storage = (
62
+ Storage.using(artifact._state.db).filter(id=artifact.storage_id).one()
63
+ )
53
64
  else:
54
- storage = Storage.filter(id=file.storage_id).one()
65
+ storage = Storage.filter(id=artifact.storage_id).one()
55
66
  # find a better way than passing None to instance_settings in the future!
56
67
  storage_settings = StorageSettings(storage.root)
57
68
  path = storage_settings.key_to_filepath(storage_key)
@@ -59,11 +70,11 @@ def attempt_accessing_path(file: File, storage_key: str):
59
70
 
60
71
 
61
72
  # add type annotations back asap when re-organizing the module
62
- def filepath_from_file(file: File):
63
- if hasattr(file, "_local_filepath") and file._local_filepath is not None:
64
- return file._local_filepath.resolve()
65
- storage_key = auto_storage_key_from_file(file)
66
- path = attempt_accessing_path(file, storage_key)
73
+ def filepath_from_artifact(artifact: Artifact):
74
+ if hasattr(artifact, "_local_filepath") and artifact._local_filepath is not None:
75
+ return artifact._local_filepath.resolve()
76
+ storage_key = auto_storage_key_from_artifact(artifact)
77
+ path = attempt_accessing_path(artifact, storage_key)
67
78
  return path
68
79
 
69
80
 
@@ -75,20 +86,15 @@ def read_adata_h5ad(filepath, **kwargs) -> ad.AnnData:
75
86
  return adata
76
87
 
77
88
 
78
- def store_object(localpath: Union[str, Path, UPath], storagekey: str) -> float:
79
- """Store arbitrary file to configured storage location.
89
+ def store_artifact(localpath: Union[str, Path, UPath], storagekey: str) -> None:
90
+ """Store directory or file to configured storage location.
80
91
 
81
92
  Returns size in bytes.
82
93
  """
83
94
  storagepath: UPath = settings.instance.storage.key_to_filepath(storagekey)
84
95
  localpath = Path(localpath)
85
-
86
- if localpath.is_file():
87
- size = localpath.stat().st_size
88
- else:
89
- size = sum(f.stat().st_size for f in localpath.rglob("*") if f.is_file())
90
-
91
96
  if not isinstance(storagepath, LocalPathClasses):
97
+ # this uploads files and directories
92
98
  storagepath.upload_from(localpath, recursive=True, print_progress=True)
93
99
  else: # storage path is local
94
100
  storagepath.parent.mkdir(parents=True, exist_ok=True)
@@ -101,16 +107,15 @@ def store_object(localpath: Union[str, Path, UPath], storagekey: str) -> float:
101
107
  if storagepath.exists():
102
108
  shutil.rmtree(storagepath)
103
109
  shutil.copytree(localpath, storagepath)
104
- return float(size) # because this is how we store in the db
105
110
 
106
111
 
107
- def delete_storage_using_key(file: File, storage_key: str):
108
- filepath = attempt_accessing_path(file, storage_key)
112
+ def delete_storage_using_key(artifact: Artifact, storage_key: str):
113
+ filepath = attempt_accessing_path(artifact, storage_key)
109
114
  delete_storage(filepath)
110
115
 
111
116
 
112
117
  def delete_storage(storagepath: Union[Path, UPath]):
113
- """Delete arbitrary file."""
118
+ """Delete arbitrary artifact."""
114
119
  if storagepath.is_file():
115
120
  storagepath.unlink()
116
121
  elif storagepath.is_dir():
lamindb/dev/versioning.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from typing import Optional, Tuple, Union
2
2
 
3
3
  from lnschema_core import ids
4
- from lnschema_core.models import File, Transform
4
+ from lnschema_core.models import Artifact, Transform
5
5
 
6
6
 
7
7
  def set_version(version: Optional[str] = None, previous_version: Optional[str] = None):
@@ -46,7 +46,7 @@ def init_uid(
46
46
  return gen_full_id()
47
47
 
48
48
 
49
- def get_initial_version_id(is_new_version_of: Union[File, Transform]):
49
+ def get_initial_version_id(is_new_version_of: Union[Artifact, Transform]):
50
50
  if is_new_version_of.initial_version_id is None:
51
51
  initial_version_id = is_new_version_of.id
52
52
  else:
@@ -55,7 +55,7 @@ def get_initial_version_id(is_new_version_of: Union[File, Transform]):
55
55
 
56
56
 
57
57
  def get_ids_from_old_version(
58
- is_new_version_of: Union[File, Transform],
58
+ is_new_version_of: Union[Artifact, Transform],
59
59
  version: Optional[str],
60
60
  n_full_id: int = 20,
61
61
  ) -> Tuple[str, int, str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamindb
3
- Version: 0.63.5
3
+ Version: 0.64.1
4
4
  Summary: A data framework for biology.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Requires-Python: >=3.8
@@ -8,10 +8,10 @@ Description-Content-Type: text/markdown
8
8
  Classifier: Programming Language :: Python :: 3.8
9
9
  Classifier: Programming Language :: Python :: 3.9
10
10
  Classifier: Programming Language :: Python :: 3.10
11
- Requires-Dist: lnschema_core==0.57.6
12
- Requires-Dist: lamindb_setup==0.61.2
11
+ Requires-Dist: lnschema_core==0.58.1
12
+ Requires-Dist: lamindb_setup==0.61.4
13
13
  Requires-Dist: lamin_utils==0.12.0
14
- Requires-Dist: lamin_cli==0.2.5
14
+ Requires-Dist: lamin_cli==0.3.0
15
15
  Requires-Dist: rapidfuzz
16
16
  Requires-Dist: pyarrow
17
17
  Requires-Dist: typing_extensions!=4.6.0
@@ -27,7 +27,7 @@ Requires-Dist: boto3==1.28.17 ; extra == "aws"
27
27
  Requires-Dist: aiobotocore==2.5.4 ; extra == "aws"
28
28
  Requires-Dist: fsspec[s3]==2023.9.0 ; extra == "aws"
29
29
  Requires-Dist: s3fs>=2023.9.0 ; extra == "aws"
30
- Requires-Dist: lnschema_bionty==0.35.3 ; extra == "bionty"
30
+ Requires-Dist: lnschema_bionty==0.36.1 ; extra == "bionty"
31
31
  Requires-Dist: pandas<2 ; extra == "dev"
32
32
  Requires-Dist: pre-commit ; extra == "dev"
33
33
  Requires-Dist: nox ; extra == "dev"
@@ -0,0 +1,48 @@
1
+ lamindb/__init__.py,sha256=p8sA7vnVgcf5Xi8zfLL9d3iftj3msKBrxApZf5s73zE,2826
2
+ lamindb/_artifact.py,sha256=BbZ9DmCUr94qB39m3QwID0WiasXIbHh6P2MeK5NmqeQ,38496
3
+ lamindb/_dataset.py,sha256=7LmHG-Ax3TO0wVJTis8wTijRjjYmWvyiwO2tpkC5z9s,17057
4
+ lamindb/_delete.py,sha256=29bZ9l_TiXT5fl1KY9mqdAVJsEqQCqunB_XhmS2BUbg,1976
5
+ lamindb/_feature.py,sha256=X5PygRkAHAI_vhgVXnSq9vEmB8kjRYhge2CuNhuWUKs,5970
6
+ lamindb/_feature_set.py,sha256=Y3AQis-gqcjzRRXzo3MoUCbgYC5_leFDj3Na6iDfCtI,8602
7
+ lamindb/_filter.py,sha256=OBdctpgboD1FnPYIsARrnMIEL0oa4ZT2Uw8m-777G4M,1159
8
+ lamindb/_from_values.py,sha256=LiSuMSlyDpfpVccfpt9lje0Qu1xHqhp12rqQkPYRX60,11904
9
+ lamindb/_parents.py,sha256=rzwfJKT2LJUR-5V88PPd3kBHUPPNg6C8RPCl41YMBsM,13847
10
+ lamindb/_query_manager.py,sha256=oPlUlZfdm9xsqAop2y-W9XCXUFK_E4eWwtEQHb8b1Do,4444
11
+ lamindb/_query_set.py,sha256=ur_xpZBiigwi-uJ4VK2jJbA-Itgz2aT2GnT-zBX5yFo,10106
12
+ lamindb/_registry.py,sha256=NTq0GLRL_h4DiymQUB4ZFOuS7IcFvXd7q9Uea6d9Pko,16778
13
+ lamindb/_run.py,sha256=659lqY32GW7F41rFUUo37OftUa38-p8yaV9Z0oF32CE,1120
14
+ lamindb/_save.py,sha256=6vzlzkR8zbzMHhbbSJ1JzyfpUn8YViAuO3t64eC2_9M,10500
15
+ lamindb/_storage.py,sha256=HUdXGj4839C606gvxWXo0tDITbtbuyJKOgUPhagYPTI,415
16
+ lamindb/_transform.py,sha256=87yUTz0RndJ_C98tBt4t2SPw8fksRgqJKwCQG_H40Kk,2515
17
+ lamindb/_ulabel.py,sha256=lEAENh_dluNkBi8xKUH_CjJNMXldOm2liy6Rg3IH1pE,1900
18
+ lamindb/_utils.py,sha256=LGdiW4k3GClLz65vKAVRkL6Tw-Gkx9DWAdez1jyA5bE,428
19
+ lamindb/_validate.py,sha256=p_aqvmu90N-yHFhECnU9PhWu7veOxUxDVn-mNaK4FI0,14380
20
+ lamindb/_view.py,sha256=gHtxY_Bp6zF7t0qFltzzmbf2cKbJY-iGnQiq-sAlW7k,2184
21
+ lamindb/dev/__init__.py,sha256=Jj5iicXQkK262umfQzixBLZ3TEQ3qfWJGOdeBPXekyo,1088
22
+ lamindb/dev/_data.py,sha256=Vv009K3kiKOr5E2gUNYrAhya7KaFDV4ychU7de8vcB4,16941
23
+ lamindb/dev/_feature_manager.py,sha256=fTxj8Fdn4rmnWajVcg3WqaHfP572-D2qmbArKZysj5s,8091
24
+ lamindb/dev/_label_manager.py,sha256=OdNGM6Y9wyviYIGzDdZ5gzYmQ06aL5yReA43f-5W2WU,7382
25
+ lamindb/dev/_mapped_dataset.py,sha256=HJa7dsdOhKUVSZeu7zpqb42iJj-yLvrAiFFgyoGa1UQ,11136
26
+ lamindb/dev/_run_context.py,sha256=g52yJ27AToH66wsTwxHswtAMZmPYsmP_FIM4_9QswSk,23001
27
+ lamindb/dev/_settings.py,sha256=nixk8lVijCbq_fRlUpkX5gvO9AdgUFjbXzFThAJhGBA,3824
28
+ lamindb/dev/_view_tree.py,sha256=MQQn34fKjOZPf3-rQXb0ht8DQW6wCJAtpLawJz5sPrg,3360
29
+ lamindb/dev/exceptions.py,sha256=PHk5lyBdJPrrEQcid3ItfdNzz3fgiQsUmsEDdz063F0,197
30
+ lamindb/dev/fields.py,sha256=Yzdk2qF2ILNYktyswLTgHNrjCN8-McGsv5pqRdijIZ8,171
31
+ lamindb/dev/hashing.py,sha256=wmioFBv_5G-Gjnm-QU_UtofpB0wBjeEkycof_V9F454,1745
32
+ lamindb/dev/types.py,sha256=svg5S_aynuGfbEOsbmqkR_gF9d9YMzfOkcvGN37Rzvg,232
33
+ lamindb/dev/versioning.py,sha256=ZINBCnv6koUQ6Z02SoSZ0sXj2aIqJj9mJVvbC8Z_5e4,2800
34
+ lamindb/dev/datasets/__init__.py,sha256=clbWOmg4K8Rh94OPFtJasNKdtUHHvR_Lx11jZWMqfok,1350
35
+ lamindb/dev/datasets/_core.py,sha256=tgV3c364GVeWoHDl3xlppib80a7XVQgs37oRuVaYySo,18877
36
+ lamindb/dev/datasets/_fake.py,sha256=S8mNho-oSh1M9x9oOSsUBLLHmBAegsOLlFk6LnF81EA,942
37
+ lamindb/dev/storage/__init__.py,sha256=P6LYolhSu4QNtvp4hEnVpLpW1GueX2BTewbUE8A12ak,368
38
+ lamindb/dev/storage/_anndata_sizes.py,sha256=0XVzA6AQeVGPaGPrhGusKyxFgFjeo3qSN29hxb8D5E8,993
39
+ lamindb/dev/storage/_backed_access.py,sha256=Q6c0hlxN05E0Rt5aqyvlf0WvcVqjtBza77PEew7Syw8,22804
40
+ lamindb/dev/storage/_zarr.py,sha256=7W1Jos1QOOF3f41uML_arQoDTNPZVpRyP2m3SLWaCAo,2766
41
+ lamindb/dev/storage/file.py,sha256=gZ_Px3wjD-mkqHT-lr0xxM2datbE447qR2U0wkmza3o,5730
42
+ lamindb/dev/storage/object.py,sha256=KGuOwwYuN2yCJxTXn9v0LanC0fjKwy_62P-WksHcf40,1140
43
+ lamindb/setup/__init__.py,sha256=8-0F2C4Glx23-b8-D_1CBGgRBM5PppVhazhoXZYOLsg,275
44
+ lamindb/setup/dev/__init__.py,sha256=tBty426VGF2PGqqt2XuNU-WgvOrbOp1aZBDowjLuzgA,242
45
+ lamindb-0.64.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
46
+ lamindb-0.64.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
47
+ lamindb-0.64.1.dist-info/METADATA,sha256=dIykcbtt7uCkgct7FSwbHEN_2oEfX42P9LZVs0TVyAA,3114
48
+ lamindb-0.64.1.dist-info/RECORD,,
@@ -1,48 +0,0 @@
1
- lamindb/__init__.py,sha256=f2y8RKnZNz0ITw4NMuJosvqOhQlC4dWzclc0kR9JXsU,2775
2
- lamindb/_dataset.py,sha256=tcjhrUQ3Cah3PiTH-B8zQQyJ5yc1Aiccib7wW7TFE88,17638
3
- lamindb/_delete.py,sha256=wiYmYnvIEHrDdmw1NiXyfCY9mBt-FI5XNFi5jyR_mkA,1968
4
- lamindb/_feature.py,sha256=X5PygRkAHAI_vhgVXnSq9vEmB8kjRYhge2CuNhuWUKs,5970
5
- lamindb/_feature_set.py,sha256=Y3AQis-gqcjzRRXzo3MoUCbgYC5_leFDj3Na6iDfCtI,8602
6
- lamindb/_file.py,sha256=K8Uk_W_S_R-0SmLK3MYNVhRJTMoHvGbtxT2NFRphtSI,36068
7
- lamindb/_filter.py,sha256=9oXvRMCI5b4N_750njnZr-kh8LfhfS16_FLNYF3B6JM,1151
8
- lamindb/_from_values.py,sha256=LiSuMSlyDpfpVccfpt9lje0Qu1xHqhp12rqQkPYRX60,11904
9
- lamindb/_parents.py,sha256=jq77njBse4JEbQwFjp0Kv7IRD8JmXamxsCuGRLOrqJs,13819
10
- lamindb/_query_manager.py,sha256=M5P4FJrAcWPZwoObU9z6MtowbMuV6SF9sX1AW10dCyg,4388
11
- lamindb/_query_set.py,sha256=ur_xpZBiigwi-uJ4VK2jJbA-Itgz2aT2GnT-zBX5yFo,10106
12
- lamindb/_registry.py,sha256=762NvN3opK_PXG1p_JpLnBb7_g8HNuciwFep_-FOhtc,16770
13
- lamindb/_run.py,sha256=659lqY32GW7F41rFUUo37OftUa38-p8yaV9Z0oF32CE,1120
14
- lamindb/_save.py,sha256=HfJ4cnx959H7r1GOUon2TiHLXbZIjn5PUiIxzN59rLI,10185
15
- lamindb/_storage.py,sha256=HUdXGj4839C606gvxWXo0tDITbtbuyJKOgUPhagYPTI,415
16
- lamindb/_transform.py,sha256=87yUTz0RndJ_C98tBt4t2SPw8fksRgqJKwCQG_H40Kk,2515
17
- lamindb/_ulabel.py,sha256=lEAENh_dluNkBi8xKUH_CjJNMXldOm2liy6Rg3IH1pE,1900
18
- lamindb/_utils.py,sha256=LGdiW4k3GClLz65vKAVRkL6Tw-Gkx9DWAdez1jyA5bE,428
19
- lamindb/_validate.py,sha256=p_aqvmu90N-yHFhECnU9PhWu7veOxUxDVn-mNaK4FI0,14380
20
- lamindb/_view.py,sha256=gHtxY_Bp6zF7t0qFltzzmbf2cKbJY-iGnQiq-sAlW7k,2184
21
- lamindb/dev/__init__.py,sha256=Jj5iicXQkK262umfQzixBLZ3TEQ3qfWJGOdeBPXekyo,1088
22
- lamindb/dev/_data.py,sha256=I4bnAkvT5m1rxvrzozCJjVt8v95D4ESPifi_HTBWsrQ,16885
23
- lamindb/dev/_feature_manager.py,sha256=1Zf98GrK0QdzoX94FZaoQYTehKcBG-Fa3pnb0JGtctM,8051
24
- lamindb/dev/_label_manager.py,sha256=EikCyLc0i80b9j0EOXznu42ERTu_KDv1dXRxeY3IiZU,7366
25
- lamindb/dev/_mapped_dataset.py,sha256=HJa7dsdOhKUVSZeu7zpqb42iJj-yLvrAiFFgyoGa1UQ,11136
26
- lamindb/dev/_run_context.py,sha256=PR8yzr6tapAlwu1lK5rY1qAhrVg5048W6wYw_LlEvic,23001
27
- lamindb/dev/_settings.py,sha256=ldS81qBsCZCSvrt_DgGBXN5jEWifbgU_oYeysoeWGFU,3780
28
- lamindb/dev/_view_tree.py,sha256=qAKSP_elGc5xN8beOwajXDcDMlCfeGqDQ4uvW3rOR0U,3340
29
- lamindb/dev/exceptions.py,sha256=PHk5lyBdJPrrEQcid3ItfdNzz3fgiQsUmsEDdz063F0,197
30
- lamindb/dev/fields.py,sha256=Yzdk2qF2ILNYktyswLTgHNrjCN8-McGsv5pqRdijIZ8,171
31
- lamindb/dev/hashing.py,sha256=IlNrHy-a9NqB0vfqiwIh4sjt40CvaiZIvfK6gMnkxDo,1381
32
- lamindb/dev/types.py,sha256=svg5S_aynuGfbEOsbmqkR_gF9d9YMzfOkcvGN37Rzvg,232
33
- lamindb/dev/versioning.py,sha256=XF7X-Ngat_Ggca7FdtZa5ElOKlOgoxDtxwZlhsCTJZU,2788
34
- lamindb/dev/datasets/__init__.py,sha256=clbWOmg4K8Rh94OPFtJasNKdtUHHvR_Lx11jZWMqfok,1350
35
- lamindb/dev/datasets/_core.py,sha256=H--4RVX7ZeZi_KH7RIiRZZalMqHyAMmRYoCh8hMkAVQ,18853
36
- lamindb/dev/datasets/_fake.py,sha256=S8mNho-oSh1M9x9oOSsUBLLHmBAegsOLlFk6LnF81EA,942
37
- lamindb/dev/storage/__init__.py,sha256=AlViEC4M7fDawYA-y8ORXMn-PhT8bGDSxsWm1tjSUOk,382
38
- lamindb/dev/storage/_anndata_sizes.py,sha256=0XVzA6AQeVGPaGPrhGusKyxFgFjeo3qSN29hxb8D5E8,993
39
- lamindb/dev/storage/_backed_access.py,sha256=hXbspr4xbOX_rDTIynxYsgOb-PgGVOrxyhNToxn9k2c,22768
40
- lamindb/dev/storage/_zarr.py,sha256=7W1Jos1QOOF3f41uML_arQoDTNPZVpRyP2m3SLWaCAo,2766
41
- lamindb/dev/storage/file.py,sha256=KWWBMG72H_ec4LiFaqHiOJsvlNbY8qoJFzleeJ-wA8w,5530
42
- lamindb/dev/storage/object.py,sha256=KGuOwwYuN2yCJxTXn9v0LanC0fjKwy_62P-WksHcf40,1140
43
- lamindb/setup/__init__.py,sha256=8-0F2C4Glx23-b8-D_1CBGgRBM5PppVhazhoXZYOLsg,275
44
- lamindb/setup/dev/__init__.py,sha256=tBty426VGF2PGqqt2XuNU-WgvOrbOp1aZBDowjLuzgA,242
45
- lamindb-0.63.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
46
- lamindb-0.63.5.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
47
- lamindb-0.63.5.dist-info/METADATA,sha256=CyjoHFJkE73UTef6N0f3Gnfji2aaBpUdA_nqTWPMguM,3114
48
- lamindb-0.63.5.dist-info/RECORD,,