lamindb_setup 0.76.4__py2.py3-none-any.whl → 0.76.6__py2.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_setup/__init__.py +1 -1
- lamindb_setup/_init_instance.py +1 -1
- lamindb_setup/_set_managed_storage.py +16 -2
- lamindb_setup/core/_hub_core.py +6 -6
- lamindb_setup/core/_settings_instance.py +1 -1
- lamindb_setup/core/_settings_storage.py +22 -5
- {lamindb_setup-0.76.4.dist-info → lamindb_setup-0.76.6.dist-info}/METADATA +1 -1
- {lamindb_setup-0.76.4.dist-info → lamindb_setup-0.76.6.dist-info}/RECORD +10 -10
- {lamindb_setup-0.76.4.dist-info → lamindb_setup-0.76.6.dist-info}/LICENSE +0 -0
- {lamindb_setup-0.76.4.dist-info → lamindb_setup-0.76.6.dist-info}/WHEEL +0 -0
lamindb_setup/__init__.py
CHANGED
lamindb_setup/_init_instance.py
CHANGED
|
@@ -250,7 +250,7 @@ def init(
|
|
|
250
250
|
# see a way of making this more elegant; should become possible if we
|
|
251
251
|
# remove the instance.storage_id FK on the hub
|
|
252
252
|
prevent_register_hub = is_local_db_url(db) if db is not None else False
|
|
253
|
-
ssettings = init_storage(
|
|
253
|
+
ssettings, _ = init_storage(
|
|
254
254
|
storage,
|
|
255
255
|
instance_id=instance_id,
|
|
256
256
|
init_instance=True,
|
|
@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
|
|
|
5
5
|
from lamin_utils import logger
|
|
6
6
|
|
|
7
7
|
from ._init_instance import register_storage_in_instance
|
|
8
|
+
from .core._hub_core import delete_storage_record
|
|
8
9
|
from .core._settings import settings
|
|
9
10
|
from .core._settings_storage import init_storage
|
|
10
11
|
|
|
@@ -28,14 +29,27 @@ def set_managed_storage(root: UPathStr, **fs_kwargs):
|
|
|
28
29
|
raise ValueError(
|
|
29
30
|
"Can't add additional managed storage locations for instances that aren't managed through the hub."
|
|
30
31
|
)
|
|
31
|
-
|
|
32
|
+
# here the storage is registered in the hub
|
|
33
|
+
# hub_record_status="hub-record-created" if a new record is created
|
|
34
|
+
# "hub-record-retireved" if the storage is in the hub already
|
|
35
|
+
ssettings, hub_record_status = init_storage(
|
|
32
36
|
root=root, instance_id=settings.instance._id, register_hub=True
|
|
33
37
|
)
|
|
34
38
|
if ssettings._instance_id is None:
|
|
35
39
|
raise ValueError(
|
|
36
40
|
f"Cannot manage storage without write access: {ssettings.root}"
|
|
37
41
|
)
|
|
42
|
+
|
|
43
|
+
# here the storage is saved in the instance
|
|
44
|
+
# if any error happens the record in the hub is deleted
|
|
45
|
+
# if it was created earlier and not retrieved
|
|
46
|
+
try:
|
|
47
|
+
register_storage_in_instance(ssettings)
|
|
48
|
+
except Exception as e:
|
|
49
|
+
if hub_record_status == "hub-record-created" and ssettings._uuid is not None:
|
|
50
|
+
delete_storage_record(ssettings._uuid) # type: ignore
|
|
51
|
+
raise e
|
|
52
|
+
|
|
38
53
|
settings.instance._storage = ssettings
|
|
39
54
|
settings.instance._persist() # this also updates the settings object
|
|
40
|
-
register_storage_in_instance(ssettings)
|
|
41
55
|
settings.storage._set_fs_kwargs(**fs_kwargs)
|
lamindb_setup/core/_hub_core.py
CHANGED
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
import uuid
|
|
6
6
|
from importlib import metadata
|
|
7
|
-
from typing import TYPE_CHECKING
|
|
7
|
+
from typing import TYPE_CHECKING, Literal
|
|
8
8
|
from uuid import UUID
|
|
9
9
|
|
|
10
10
|
from lamin_utils import logger
|
|
@@ -119,7 +119,7 @@ def _select_storage(
|
|
|
119
119
|
def init_storage(
|
|
120
120
|
ssettings: StorageSettings,
|
|
121
121
|
auto_populate_instance: bool = True,
|
|
122
|
-
) ->
|
|
122
|
+
) -> Literal["hub-record-retireved", "hub-record-created"]:
|
|
123
123
|
if settings.user.handle != "anonymous":
|
|
124
124
|
return call_with_fallback_auth(
|
|
125
125
|
_init_storage,
|
|
@@ -131,21 +131,21 @@ def init_storage(
|
|
|
131
131
|
_select_storage, ssettings=ssettings, update_uid=True
|
|
132
132
|
)
|
|
133
133
|
if storage_exists:
|
|
134
|
-
return
|
|
134
|
+
return "hub-record-retireved"
|
|
135
135
|
else:
|
|
136
136
|
raise ValueError("Log in to create a storage location on the hub.")
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
def _init_storage(
|
|
140
140
|
ssettings: StorageSettings, auto_populate_instance: bool, client: Client
|
|
141
|
-
) ->
|
|
141
|
+
) -> Literal["hub-record-retireved", "hub-record-created"]:
|
|
142
142
|
from lamindb_setup import settings
|
|
143
143
|
|
|
144
144
|
# storage roots are always stored without the trailing slash in the SQL
|
|
145
145
|
# database
|
|
146
146
|
root = ssettings.root_as_str
|
|
147
147
|
if _select_storage(ssettings, update_uid=True, client=client):
|
|
148
|
-
return
|
|
148
|
+
return "hub-record-retireved"
|
|
149
149
|
if ssettings.type_is_cloud:
|
|
150
150
|
id = uuid.uuid5(uuid.NAMESPACE_URL, root)
|
|
151
151
|
else:
|
|
@@ -181,7 +181,7 @@ def _init_storage(
|
|
|
181
181
|
# on root & description
|
|
182
182
|
client.table("storage").upsert(fields).execute()
|
|
183
183
|
ssettings._uuid_ = id
|
|
184
|
-
return
|
|
184
|
+
return "hub-record-created"
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
def delete_instance(identifier: UUID | str, require_empty: bool = True) -> str | None:
|
|
@@ -230,7 +230,7 @@ class InstanceSettings:
|
|
|
230
230
|
return None
|
|
231
231
|
local_root = UPath(local_root)
|
|
232
232
|
assert isinstance(local_root, LocalPathClasses)
|
|
233
|
-
self._storage_local = init_storage(local_root, self._id, register_hub=True) # type: ignore
|
|
233
|
+
self._storage_local, _ = init_storage(local_root, self._id, register_hub=True) # type: ignore
|
|
234
234
|
register_storage_in_instance(self._storage_local) # type: ignore
|
|
235
235
|
logger.important(f"defaulting to local storage: {self._storage_local.root}")
|
|
236
236
|
|
|
@@ -83,10 +83,17 @@ def init_storage(
|
|
|
83
83
|
register_hub: bool | None = None,
|
|
84
84
|
prevent_register_hub: bool = False,
|
|
85
85
|
init_instance: bool = False,
|
|
86
|
-
) ->
|
|
86
|
+
) -> tuple[
|
|
87
|
+
StorageSettings,
|
|
88
|
+
Literal["hub-record-not-created", "hub-record-retireved", "hub-record-created"],
|
|
89
|
+
]:
|
|
87
90
|
if root is None:
|
|
88
91
|
raise ValueError("`storage` argument can't be `None`")
|
|
89
92
|
root_str = str(root) # ensure we have a string
|
|
93
|
+
if ".lamindb" in root_str:
|
|
94
|
+
raise ValueError(
|
|
95
|
+
'Please pass a folder name that does not end or contain ".lamindb"'
|
|
96
|
+
)
|
|
90
97
|
uid = base62(12)
|
|
91
98
|
region = None
|
|
92
99
|
lamin_env = os.getenv("LAMIN_ENV")
|
|
@@ -117,13 +124,19 @@ def init_storage(
|
|
|
117
124
|
region=region,
|
|
118
125
|
instance_id=instance_id,
|
|
119
126
|
)
|
|
127
|
+
# this stores the result of init_storage_hub
|
|
128
|
+
hub_record_status: Literal[
|
|
129
|
+
"hub-record-not-created", "hub-record-retireved", "hub-record-created"
|
|
130
|
+
] = "hub-record-not-created"
|
|
120
131
|
# the below might update the uid with one that's already taken on the hub
|
|
121
132
|
if not prevent_register_hub:
|
|
122
133
|
if ssettings.type_is_cloud or register_hub:
|
|
123
134
|
from ._hub_core import delete_storage_record
|
|
124
135
|
from ._hub_core import init_storage as init_storage_hub
|
|
125
136
|
|
|
126
|
-
|
|
137
|
+
hub_record_status = init_storage_hub(
|
|
138
|
+
ssettings, auto_populate_instance=not init_instance
|
|
139
|
+
)
|
|
127
140
|
# below comes last only if everything else was successful
|
|
128
141
|
try:
|
|
129
142
|
# (federated) credentials for AWS access are provisioned under-the-hood
|
|
@@ -133,10 +146,14 @@ def init_storage(
|
|
|
133
146
|
logger.important(
|
|
134
147
|
f"due to lack of write access, LaminDB won't manage storage location: {ssettings.root}"
|
|
135
148
|
)
|
|
136
|
-
|
|
149
|
+
# we have to check hub_record_status here because
|
|
150
|
+
# _select_storage inside init_storage_hub also populates ssettings._uuid
|
|
151
|
+
# and we don't want to delete an existing storage record here
|
|
152
|
+
# only newly created
|
|
153
|
+
if hub_record_status == "hub-record-created" and ssettings._uuid is not None:
|
|
137
154
|
delete_storage_record(ssettings._uuid) # type: ignore
|
|
138
155
|
ssettings._instance_id = None
|
|
139
|
-
return ssettings
|
|
156
|
+
return ssettings, hub_record_status
|
|
140
157
|
|
|
141
158
|
|
|
142
159
|
def _process_cache_path(cache_path: str | Path | UPath | None):
|
|
@@ -171,7 +188,7 @@ class StorageSettings:
|
|
|
171
188
|
(self._root_init / ".lamindb").mkdir(parents=True, exist_ok=True)
|
|
172
189
|
self._root_init = self._root_init.resolve()
|
|
173
190
|
except Exception:
|
|
174
|
-
logger.warning("unable to create .lamindb folder")
|
|
191
|
+
logger.warning(f"unable to create .lamindb folder in {self._root_init}")
|
|
175
192
|
pass
|
|
176
193
|
self._root = None
|
|
177
194
|
self._instance_id = instance_id
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
lamindb_setup/__init__.py,sha256=
|
|
1
|
+
lamindb_setup/__init__.py,sha256=oS0T4Bi_gmUMhmQgSv_QLNn_UX7KoGP3pVyA6cv1XBI,1542
|
|
2
2
|
lamindb_setup/_cache.py,sha256=wA7mbysANwe8hPNbjDo9bOmXJ0xIyaS5iyxIpxSWji4,846
|
|
3
3
|
lamindb_setup/_check.py,sha256=28PcG8Kp6OpjSLSi1r2boL2Ryeh6xkaCL87HFbjs6GA,129
|
|
4
4
|
lamindb_setup/_check_setup.py,sha256=cNEL9Q4yPpmEkGKHH8JgullWl1VUZwALJ4RHn9wZypY,2613
|
|
@@ -8,12 +8,12 @@ lamindb_setup/_delete.py,sha256=Y8KSFYgY0UHAvjd7cCL6hZ_XiLeJwx50BguVATcj_Xo,5524
|
|
|
8
8
|
lamindb_setup/_django.py,sha256=EoyWvFzH0i9wxjy4JZhcoXCTckztP_Mrl6FbYQnMmLE,1534
|
|
9
9
|
lamindb_setup/_exportdb.py,sha256=43g77-tH-vAlTn8ig1mMD9-KXLKvxUeDLaq0gVu3l-c,2114
|
|
10
10
|
lamindb_setup/_importdb.py,sha256=yYYShzUajTsR-cTW4CZ-UNDWZY2uE5PAgNbp-wn8Ogc,1874
|
|
11
|
-
lamindb_setup/_init_instance.py,sha256=
|
|
11
|
+
lamindb_setup/_init_instance.py,sha256=VxHgD2i0hrFm2f_WCX76YmS_Lsx2iufrMtfab82r8X0,12391
|
|
12
12
|
lamindb_setup/_migrate.py,sha256=P4n3x0SYzO9szjF2-JMa7z4mQadtWjHv5ow4HbCDZLI,8864
|
|
13
13
|
lamindb_setup/_register_instance.py,sha256=alQuYp2f8Ct8xvRC1gt8p_HZ0tqCd3gZD3kiPBLPpsI,1269
|
|
14
14
|
lamindb_setup/_schema.py,sha256=b3uzhhWpV5mQtDwhMINc2MabGCnGLESy51ito3yl6Wc,679
|
|
15
15
|
lamindb_setup/_schema_metadata.py,sha256=nF29OuMNswJUCyvSyOHEUQLQ7PcfB7uwvczloBYSWuU,13187
|
|
16
|
-
lamindb_setup/_set_managed_storage.py,sha256=
|
|
16
|
+
lamindb_setup/_set_managed_storage.py,sha256=4tDxXQMt8Gw028uY3vIQxZQ7qBNXhQMc8saarNK_Z-s,2043
|
|
17
17
|
lamindb_setup/_setup_user.py,sha256=6Oc7Rke-yRQSZbuntdUAz8QbJ6UuPzYHI9FnYlf_q-A,3670
|
|
18
18
|
lamindb_setup/_silence_loggers.py,sha256=AKF_YcHvX32eGXdsYK8MJlxEaZ-Uo2f6QDRzjKFCtws,1568
|
|
19
19
|
lamindb_setup/core/__init__.py,sha256=BxIVMX5HQq8oZ1OuY_saUEJz5Tdd7gaCPngxVu5iou4,417
|
|
@@ -22,15 +22,15 @@ lamindb_setup/core/_aws_storage.py,sha256=nEjeUv4xUVpoV0Lx-zjjmyb9w804bDyaeiM-Oq
|
|
|
22
22
|
lamindb_setup/core/_deprecated.py,sha256=3qxUI1dnDlSeR0BYrv7ucjqRBEojbqotPgpShXs4KF8,2520
|
|
23
23
|
lamindb_setup/core/_docs.py,sha256=3k-YY-oVaJd_9UIY-LfBg_u8raKOCNfkZQPA73KsUhs,276
|
|
24
24
|
lamindb_setup/core/_hub_client.py,sha256=Gpt3TmxWQMVenKugCu1agUb-xGN9YFsQOKmrHuFiiDs,5605
|
|
25
|
-
lamindb_setup/core/_hub_core.py,sha256=
|
|
25
|
+
lamindb_setup/core/_hub_core.py,sha256=2Ni7vIkUcZw9ryBLgjercvLsdAL8-3xZNmrxyzNCU98,17049
|
|
26
26
|
lamindb_setup/core/_hub_crud.py,sha256=eZErpq9t1Cp2ULBSi457ekrcqfesw4Y6IJgaqyrINMY,5276
|
|
27
27
|
lamindb_setup/core/_hub_utils.py,sha256=w5IRtrxZcvxmGSJslzuZF89ewkzXV4cCUmZUVrqmAfo,3026
|
|
28
28
|
lamindb_setup/core/_private_django_api.py,sha256=KIn43HOhiRjkbTbddyJqv-WNTTa1bAizbM1tWXoXPBg,2869
|
|
29
29
|
lamindb_setup/core/_settings.py,sha256=46axQ5HPvI0X9YuotgdpuSOfSo7qYU1DudIx3vxpFk0,4471
|
|
30
|
-
lamindb_setup/core/_settings_instance.py,sha256=
|
|
30
|
+
lamindb_setup/core/_settings_instance.py,sha256=azgqSWEnTfZM9ghgdF6atvIxoUP6fx49Y9tZTqMQTuc,17589
|
|
31
31
|
lamindb_setup/core/_settings_load.py,sha256=bRkGgaEnLZmnOlU5ptDoSM-YXzC2l0Cb7RBoBY6VH9k,3717
|
|
32
32
|
lamindb_setup/core/_settings_save.py,sha256=n_tYfb9EBSxwm4LHyPRHJptE5uB8lmHhcRkz1JkAmhg,2781
|
|
33
|
-
lamindb_setup/core/_settings_storage.py,sha256=
|
|
33
|
+
lamindb_setup/core/_settings_storage.py,sha256=jFdoIkSn1gPDDZKjAlgKyrlsHBqZDOvv-UnuUI7aD_4,14249
|
|
34
34
|
lamindb_setup/core/_settings_store.py,sha256=VEE8Ff2A7y4j8ksOaa7g48jNaOqe1PBnBjb1PKKGUKU,2115
|
|
35
35
|
lamindb_setup/core/_settings_user.py,sha256=P2lC4WDRAFfT-Xq3MlXJ-wMKIHCoGNhMTQfRGIAyUNQ,1344
|
|
36
36
|
lamindb_setup/core/_setup_bionty_sources.py,sha256=ANBIiWHoYxLBQqsiKs-rCq3k-p6D34T4NM28gkY6YLA,3389
|
|
@@ -40,7 +40,7 @@ lamindb_setup/core/exceptions.py,sha256=eoI7AXgATgDVzgArtN7CUvpaMUC067vsBg5LHCsW
|
|
|
40
40
|
lamindb_setup/core/hashing.py,sha256=Y2cvEaqtm3KwpHqj5ZG2f_sLaXhsQT4oDrmJdHbOQeo,3116
|
|
41
41
|
lamindb_setup/core/types.py,sha256=bcYnZ0uM_2NXKJCl94Mmc-uYrQlRUUVKG3sK2N-F-N4,532
|
|
42
42
|
lamindb_setup/core/upath.py,sha256=EPLLm62q-Y3hZzd-286cynFMttXKDNXNOKL3_QGkeug,27215
|
|
43
|
-
lamindb_setup-0.76.
|
|
44
|
-
lamindb_setup-0.76.
|
|
45
|
-
lamindb_setup-0.76.
|
|
46
|
-
lamindb_setup-0.76.
|
|
43
|
+
lamindb_setup-0.76.6.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
|
|
44
|
+
lamindb_setup-0.76.6.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
45
|
+
lamindb_setup-0.76.6.dist-info/METADATA,sha256=aipPhnfIkB8MWkSmDkqbCSb-iOcQNbbs0lcQzqa5_w8,1638
|
|
46
|
+
lamindb_setup-0.76.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|