lamindb_setup 0.78.0__py3-none-any.whl → 0.79.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.
- lamindb_setup/__init__.py +1 -1
- lamindb_setup/_connect_instance.py +8 -2
- lamindb_setup/_init_instance.py +21 -9
- lamindb_setup/core/_settings_storage.py +2 -2
- lamindb_setup/core/django.py +11 -1
- {lamindb_setup-0.78.0.dist-info → lamindb_setup-0.79.0.dist-info}/METADATA +1 -1
- {lamindb_setup-0.78.0.dist-info → lamindb_setup-0.79.0.dist-info}/RECORD +9 -9
- {lamindb_setup-0.78.0.dist-info → lamindb_setup-0.79.0.dist-info}/LICENSE +0 -0
- {lamindb_setup-0.78.0.dist-info → lamindb_setup-0.79.0.dist-info}/WHEEL +0 -0
lamindb_setup/__init__.py
CHANGED
|
@@ -9,7 +9,11 @@ from lamin_utils import logger
|
|
|
9
9
|
|
|
10
10
|
from ._check_setup import _check_instance_setup
|
|
11
11
|
from ._close import close as close_instance
|
|
12
|
-
from ._init_instance import
|
|
12
|
+
from ._init_instance import (
|
|
13
|
+
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE,
|
|
14
|
+
CannotSwitchDefaultInstance,
|
|
15
|
+
load_from_isettings,
|
|
16
|
+
)
|
|
13
17
|
from ._silence_loggers import silence_loggers
|
|
14
18
|
from .core._hub_core import connect_instance_hub
|
|
15
19
|
from .core._hub_utils import (
|
|
@@ -224,7 +228,9 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
|
|
|
224
228
|
logger.info(f"connected lamindb: {settings.instance.slug}")
|
|
225
229
|
return None
|
|
226
230
|
else:
|
|
227
|
-
raise
|
|
231
|
+
raise CannotSwitchDefaultInstance(
|
|
232
|
+
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE
|
|
233
|
+
)
|
|
228
234
|
elif (
|
|
229
235
|
_write_settings
|
|
230
236
|
and settings._instance_exists
|
lamindb_setup/_init_instance.py
CHANGED
|
@@ -26,7 +26,7 @@ if TYPE_CHECKING:
|
|
|
26
26
|
from .core.types import UPathStr
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def get_schema_module_name(schema_name) -> str:
|
|
29
|
+
def get_schema_module_name(schema_name, raise_import_error: bool = True) -> str | None:
|
|
30
30
|
import importlib.util
|
|
31
31
|
|
|
32
32
|
name_attempts = [f"lnschema_{schema_name.replace('-', '_')}", schema_name]
|
|
@@ -34,9 +34,11 @@ def get_schema_module_name(schema_name) -> str:
|
|
|
34
34
|
module_spec = importlib.util.find_spec(name)
|
|
35
35
|
if module_spec is not None:
|
|
36
36
|
return name
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
message = f"Schema module '{schema_name}' is not installed → no access to its labels & registries (resolve via `pip install {schema_name}`)"
|
|
38
|
+
if raise_import_error:
|
|
39
|
+
raise ImportError(message)
|
|
40
|
+
logger.warning(message.lower())
|
|
41
|
+
return None
|
|
40
42
|
|
|
41
43
|
|
|
42
44
|
def register_storage_in_instance(ssettings: StorageSettings):
|
|
@@ -180,6 +182,8 @@ def validate_init_args(
|
|
|
180
182
|
validate_schema_arg,
|
|
181
183
|
)
|
|
182
184
|
|
|
185
|
+
if storage is None:
|
|
186
|
+
raise SystemExit("✗ `storage` argument can't be `None`")
|
|
183
187
|
# should be called as the first thing
|
|
184
188
|
name_str = infer_instance_name(storage=storage, name=name, db=db)
|
|
185
189
|
owner_str = settings.user.handle if _user is None else _user.handle
|
|
@@ -206,10 +210,18 @@ def validate_init_args(
|
|
|
206
210
|
return name_str, instance_id, instance_state, instance_slug
|
|
207
211
|
|
|
208
212
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
class CannotSwitchDefaultInstance(SystemExit):
|
|
214
|
+
pass
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE = """
|
|
218
|
+
You cannot write to different instances in the same Python session.
|
|
219
|
+
|
|
220
|
+
Do you want to read from another instance via `Record.using()`? For example:
|
|
221
|
+
|
|
222
|
+
ln.Artifact.using("laminlabs/cellxgene").filter()
|
|
223
|
+
|
|
224
|
+
Or do you want to switch off auto-connect via `lamin settings set auto-connect false`?
|
|
213
225
|
"""
|
|
214
226
|
|
|
215
227
|
|
|
@@ -248,7 +260,7 @@ def init(
|
|
|
248
260
|
from ._check_setup import _check_instance_setup
|
|
249
261
|
|
|
250
262
|
if _check_instance_setup() and not _test:
|
|
251
|
-
raise
|
|
263
|
+
raise CannotSwitchDefaultInstance(MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE)
|
|
252
264
|
elif _write_settings:
|
|
253
265
|
close_instance(mute=True)
|
|
254
266
|
from .core._hub_core import init_instance as init_instance_hub
|
|
@@ -85,8 +85,8 @@ def init_storage(
|
|
|
85
85
|
StorageSettings,
|
|
86
86
|
Literal["hub-record-not-created", "hub-record-retireved", "hub-record-created"],
|
|
87
87
|
]:
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
assert root is not None, "`root` argument can't be `None`"
|
|
89
|
+
|
|
90
90
|
root_str = str(root) # ensure we have a string
|
|
91
91
|
if ".lamindb" in root_str:
|
|
92
92
|
raise ValueError(
|
lamindb_setup/core/django.py
CHANGED
|
@@ -55,7 +55,17 @@ def setup_django(
|
|
|
55
55
|
from .._init_instance import get_schema_module_name
|
|
56
56
|
|
|
57
57
|
schema_names = ["core"] + list(isettings.schema)
|
|
58
|
-
|
|
58
|
+
raise_import_error = True if init else False
|
|
59
|
+
installed_apps = [
|
|
60
|
+
package_name
|
|
61
|
+
for n in schema_names
|
|
62
|
+
if (
|
|
63
|
+
package_name := get_schema_module_name(
|
|
64
|
+
n, raise_import_error=raise_import_error
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
is not None
|
|
68
|
+
]
|
|
59
69
|
if view_schema:
|
|
60
70
|
installed_apps = installed_apps[::-1] # to fix how apps appear
|
|
61
71
|
installed_apps += ["schema_graph", "django.contrib.staticfiles"]
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
lamindb_setup/__init__.py,sha256=
|
|
1
|
+
lamindb_setup/__init__.py,sha256=UEOTdiNVX6I8dLRxhPxeKjfNRyjzd2Kua0notBhVObM,1714
|
|
2
2
|
lamindb_setup/_cache.py,sha256=1XnM-V_KprbjpgPY7Bg3FYn53Iz_2_fEgcMOaSdKKbg,1332
|
|
3
3
|
lamindb_setup/_check.py,sha256=28PcG8Kp6OpjSLSi1r2boL2Ryeh6xkaCL87HFbjs6GA,129
|
|
4
4
|
lamindb_setup/_check_setup.py,sha256=6cSfpmVOSgU7YiVHfJpBTGTQ7rrnwunt1pJT_jkgNM8,3196
|
|
5
5
|
lamindb_setup/_close.py,sha256=cXNwK7QTTyNFt2XTpLnO3KHljJ7ShOcISk95np_dltE,1239
|
|
6
|
-
lamindb_setup/_connect_instance.py,sha256=
|
|
6
|
+
lamindb_setup/_connect_instance.py,sha256=ClSM1zQAqVmNBapmB7H3dzmnWdn1dkpr_y5HAsF74XU,16070
|
|
7
7
|
lamindb_setup/_delete.py,sha256=yjLIegM2Lh6sWRSTTybI17wK_kA4_pF_k3iVUkkgEAE,5681
|
|
8
8
|
lamindb_setup/_django.py,sha256=DWUTjjVhEViX0S-zIkeqQgKovWqVgWMl4Y0ANwlA3Pw,1505
|
|
9
9
|
lamindb_setup/_entry_points.py,sha256=Hs2oJQOCTaGUdWn-1mufM6qUZr9W_EJ_Oc3f0_Vc0Yw,616
|
|
10
10
|
lamindb_setup/_exportdb.py,sha256=43g77-tH-vAlTn8ig1mMD9-KXLKvxUeDLaq0gVu3l-c,2114
|
|
11
11
|
lamindb_setup/_importdb.py,sha256=yYYShzUajTsR-cTW4CZ-UNDWZY2uE5PAgNbp-wn8Ogc,1874
|
|
12
|
-
lamindb_setup/_init_instance.py,sha256=
|
|
12
|
+
lamindb_setup/_init_instance.py,sha256=6Db289T2A2464KqW0NsfSKg59zrhfny9RZxBgb9kPVs,14340
|
|
13
13
|
lamindb_setup/_migrate.py,sha256=x_b4k4XRfLSD-EEFMc324yK6DIK7goW33wUytbIWlNs,8917
|
|
14
14
|
lamindb_setup/_register_instance.py,sha256=alQuYp2f8Ct8xvRC1gt8p_HZ0tqCd3gZD3kiPBLPpsI,1269
|
|
15
15
|
lamindb_setup/_schema.py,sha256=b3uzhhWpV5mQtDwhMINc2MabGCnGLESy51ito3yl6Wc,679
|
|
@@ -31,17 +31,17 @@ lamindb_setup/core/_settings.py,sha256=ZIcQ3aLNRsAkoaCmse9QuMc2atDWkiraApZn0ZMOW
|
|
|
31
31
|
lamindb_setup/core/_settings_instance.py,sha256=ajcq9zRNE598tTqyMkMqaEOubVfFeE998DPtbgyzK3A,18801
|
|
32
32
|
lamindb_setup/core/_settings_load.py,sha256=5OpghcbkrK9KBM_0Iu-61FTI76UbOpPkkJpUittXS-w,4098
|
|
33
33
|
lamindb_setup/core/_settings_save.py,sha256=rxGxgaK5i9exKqSJERQQyY1WZio20meoQJoYXlVW-1w,3138
|
|
34
|
-
lamindb_setup/core/_settings_storage.py,sha256=
|
|
34
|
+
lamindb_setup/core/_settings_storage.py,sha256=u9CyOFxtV7M2Cs_L4k3dUVg3_fsl8SqLwBioMu06Acc,12310
|
|
35
35
|
lamindb_setup/core/_settings_store.py,sha256=WcsgOmgnu9gztcrhp-N4OONNZyxICHV8M0HdJllTaEo,2219
|
|
36
36
|
lamindb_setup/core/_settings_user.py,sha256=vmh8-SDJqlF4zRqAH2loS21_TEYWX4tiG-grQys6-0c,1474
|
|
37
37
|
lamindb_setup/core/_setup_bionty_sources.py,sha256=o2L5Ww8TKgSqJtL4cGUcpJwLNYxA9BZgddhCMCu_E2g,3428
|
|
38
38
|
lamindb_setup/core/cloud_sqlite_locker.py,sha256=i6TrT7HG0lqliPvZTlsZ_uplPaqhPBbabyfeR32SkA8,7107
|
|
39
|
-
lamindb_setup/core/django.py,sha256=
|
|
39
|
+
lamindb_setup/core/django.py,sha256=E4U9nUlV2kHd-G5v6iSdFGAAWixlQDxOFwMwOMG9xfw,3864
|
|
40
40
|
lamindb_setup/core/exceptions.py,sha256=4NpLUNUIfXYVTFX2FvLZF8RW34exk2Vn2X3G4YhnTRg,276
|
|
41
41
|
lamindb_setup/core/hashing.py,sha256=bkuvZyAuC7-Y_qZumJd_rybF-upJ5J3KxnKiymRUifw,3148
|
|
42
42
|
lamindb_setup/core/types.py,sha256=zJii2le38BJUmsNVvzDrbzGYr0yaeb-9Rw9IKmsBr3k,523
|
|
43
43
|
lamindb_setup/core/upath.py,sha256=EPLLm62q-Y3hZzd-286cynFMttXKDNXNOKL3_QGkeug,27215
|
|
44
|
-
lamindb_setup-0.
|
|
45
|
-
lamindb_setup-0.
|
|
46
|
-
lamindb_setup-0.
|
|
47
|
-
lamindb_setup-0.
|
|
44
|
+
lamindb_setup-0.79.0.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
|
|
45
|
+
lamindb_setup-0.79.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
46
|
+
lamindb_setup-0.79.0.dist-info/METADATA,sha256=sMW1HnGk3llbrrA1BIvx_bAa6xmnMqTYRjnDTlfaTS4,1743
|
|
47
|
+
lamindb_setup-0.79.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|