lamindb_setup 1.7.0__tar.gz → 1.7.2__tar.gz
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-1.7.0 → lamindb_setup-1.7.2}/PKG-INFO +1 -1
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/08-test-multi-session.ipynb +37 -10
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/__init__.py +1 -1
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_connect_instance.py +7 -4
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_init_instance.py +15 -7
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_hub_client.py +1 -1
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_hub_core.py +10 -8
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_settings.py +69 -7
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_settings_instance.py +7 -7
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_settings_user.py +2 -2
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-prod/test_global_settings.py +25 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/.github/workflows/build.yml +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/.github/workflows/doc-changes.yml +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/.gitignore +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/.pre-commit-config.yaml +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/LICENSE +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/README.md +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/changelog.md +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/02-connect-local-instance.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/03-add-managed-storage.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-cloud/test_notebooks.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-cache-management.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-cloud-sync.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-empty-init.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-import-schema.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-init-load-local-anonymously.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-insufficient-user-info.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test_notebooks2.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/index.md +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/notebooks.md +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/reference.md +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_cache.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_check.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_check_setup.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_delete.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_disconnect.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_django.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_entry_points.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_exportdb.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_importdb.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_migrate.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_register_instance.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_schema.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_schema_metadata.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_set_managed_storage.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_setup_user.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/_silence_loggers.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/__init__.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_aws_options.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_aws_storage.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_deprecated.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_docs.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_hub_crud.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_hub_utils.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_private_django_api.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_settings_load.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_settings_save.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_settings_storage.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_settings_store.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/cloud_sqlite_locker.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/django.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/exceptions.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/hashing.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/types.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/core/upath.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/errors.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/py.typed +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/lamindb_setup/types.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/noxfile.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/pyproject.toml +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_connect_instance.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_delete_instance.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_edge_request.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_init_instance.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_login.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_migrate.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_set_storage.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-local/conftest.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-local/scripts/script-connect-fine-grained-access.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-local/test_all.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-local/test_update_schema_in_hub.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-prod/conftest.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-prod/test_aws_options_manager.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-prod/test_django.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-prod/test_switch_and_fallback_env.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-prod/test_upath.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/storage/test_entry_point.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/storage/test_hashing.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/storage/test_storage_access.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/storage/test_storage_basis.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/storage/test_storage_settings.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/storage/test_storage_stats.py +0 -0
- {lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/storage/test_to_url.py +0 -0
|
@@ -54,15 +54,6 @@
|
|
|
54
54
|
"ln_setup.init(storage=\"./testsetup\")"
|
|
55
55
|
]
|
|
56
56
|
},
|
|
57
|
-
{
|
|
58
|
-
"cell_type": "code",
|
|
59
|
-
"execution_count": null,
|
|
60
|
-
"metadata": {},
|
|
61
|
-
"outputs": [],
|
|
62
|
-
"source": [
|
|
63
|
-
"assert ln_setup.settings.instance.slug == \"testuser1/testsetup\""
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
57
|
{
|
|
67
58
|
"cell_type": "code",
|
|
68
59
|
"execution_count": null,
|
|
@@ -120,7 +111,43 @@
|
|
|
120
111
|
"cell_type": "markdown",
|
|
121
112
|
"metadata": {},
|
|
122
113
|
"source": [
|
|
123
|
-
"
|
|
114
|
+
"Let us try to init another instance in the same Python session:"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"cell_type": "code",
|
|
119
|
+
"execution_count": null,
|
|
120
|
+
"metadata": {},
|
|
121
|
+
"outputs": [],
|
|
122
|
+
"source": [
|
|
123
|
+
"from lamindb_setup._init_instance import CannotSwitchDefaultInstance\n",
|
|
124
|
+
"\n",
|
|
125
|
+
"with pytest.raises(CannotSwitchDefaultInstance):\n",
|
|
126
|
+
" ln_setup.init(storage=\"./testsetup2\")\n",
|
|
127
|
+
"with pytest.raises(CannotSwitchDefaultInstance):\n",
|
|
128
|
+
" ln_setup.connect(\"testsetup\")\n",
|
|
129
|
+
"with pytest.raises(RuntimeError):\n",
|
|
130
|
+
" ln_setup.migrate.create()\n",
|
|
131
|
+
"with pytest.raises(RuntimeError):\n",
|
|
132
|
+
" ln_setup.migrate.deploy()\n",
|
|
133
|
+
"\n",
|
|
134
|
+
"assert ln_setup.settings.instance.slug == \"testuser1/testsetup\""
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"cell_type": "markdown",
|
|
139
|
+
"metadata": {},
|
|
140
|
+
"source": [
|
|
141
|
+
"Reset `django` and connect to another instance:"
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"cell_type": "code",
|
|
146
|
+
"execution_count": null,
|
|
147
|
+
"metadata": {},
|
|
148
|
+
"outputs": [],
|
|
149
|
+
"source": [
|
|
150
|
+
"ln_setup.core.django.reset_django()"
|
|
124
151
|
]
|
|
125
152
|
},
|
|
126
153
|
{
|
|
@@ -9,7 +9,10 @@ from lamin_utils import logger
|
|
|
9
9
|
|
|
10
10
|
from ._check_setup import _check_instance_setup, _get_current_instance_settings
|
|
11
11
|
from ._disconnect import disconnect
|
|
12
|
-
from ._init_instance import
|
|
12
|
+
from ._init_instance import (
|
|
13
|
+
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE,
|
|
14
|
+
load_from_isettings,
|
|
15
|
+
)
|
|
13
16
|
from ._silence_loggers import silence_loggers
|
|
14
17
|
from .core._hub_core import connect_instance_hub
|
|
15
18
|
from .core._hub_utils import (
|
|
@@ -238,9 +241,9 @@ def connect(instance: str | None = None, **kwargs: Any) -> str | tuple | None:
|
|
|
238
241
|
logger.important(f"connected lamindb: {settings.instance.slug}")
|
|
239
242
|
return None
|
|
240
243
|
else:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
raise CannotSwitchDefaultInstance(
|
|
245
|
+
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE
|
|
246
|
+
)
|
|
244
247
|
elif (
|
|
245
248
|
_write_settings
|
|
246
249
|
and settings._instance_exists
|
|
@@ -98,24 +98,24 @@ def register_initial_records(isettings: InstanceSettings, usettings: UserSetting
|
|
|
98
98
|
|
|
99
99
|
try:
|
|
100
100
|
Space.objects.get_or_create(
|
|
101
|
-
uid="a",
|
|
101
|
+
uid=12 * "a",
|
|
102
102
|
name="all",
|
|
103
103
|
description="Every team & user with access to the instance has access.",
|
|
104
104
|
)
|
|
105
105
|
Branch.objects.get_or_create(
|
|
106
106
|
id=-1,
|
|
107
|
-
uid="t",
|
|
107
|
+
uid=12 * "t",
|
|
108
108
|
name="trash",
|
|
109
109
|
description="The trash.",
|
|
110
110
|
)
|
|
111
111
|
Branch.objects.get_or_create(
|
|
112
112
|
id=0,
|
|
113
|
-
uid="a",
|
|
113
|
+
uid=12 * "a",
|
|
114
114
|
name="archive",
|
|
115
115
|
description="The archive.",
|
|
116
116
|
)
|
|
117
117
|
Branch.objects.get_or_create(
|
|
118
|
-
uid="m",
|
|
118
|
+
uid=12 * "m",
|
|
119
119
|
name="main",
|
|
120
120
|
description="The main & default branch of the instance.",
|
|
121
121
|
)
|
|
@@ -215,6 +215,16 @@ def validate_init_args(
|
|
|
215
215
|
return name_str, instance_id, instance_state, instance_slug
|
|
216
216
|
|
|
217
217
|
|
|
218
|
+
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE = """
|
|
219
|
+
You cannot write to different instances in the same Python session.
|
|
220
|
+
|
|
221
|
+
Do you want to read from another instance via `SQLRecord.using()`? For example:
|
|
222
|
+
|
|
223
|
+
ln.Artifact.using("laminlabs/cellxgene").filter()
|
|
224
|
+
|
|
225
|
+
Or do you want to switch off auto-connect via `lamin settings set auto-connect false`?
|
|
226
|
+
"""
|
|
227
|
+
|
|
218
228
|
DOC_STORAGE_ARG = "A local or remote folder (`'s3://...'` or `'gs://...'`). Defaults to current working directory."
|
|
219
229
|
DOC_INSTANCE_NAME = (
|
|
220
230
|
"Instance name. If not passed, it will equal the folder name passed to `storage`."
|
|
@@ -262,9 +272,7 @@ def init(
|
|
|
262
272
|
from ._check_setup import _check_instance_setup
|
|
263
273
|
|
|
264
274
|
if _check_instance_setup() and not _test:
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
reset_django()
|
|
275
|
+
raise CannotSwitchDefaultInstance(MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE)
|
|
268
276
|
elif _write_settings:
|
|
269
277
|
disconnect(mute=True)
|
|
270
278
|
from .core._hub_core import init_instance_hub
|
|
@@ -70,7 +70,7 @@ def connect_hub(
|
|
|
70
70
|
# increase to avoid rare timeouts for edge functions
|
|
71
71
|
client_options = ClientOptions(
|
|
72
72
|
auto_refresh_token=False,
|
|
73
|
-
function_client_timeout=
|
|
73
|
+
function_client_timeout=30,
|
|
74
74
|
postgrest_client_timeout=20,
|
|
75
75
|
)
|
|
76
76
|
return create_client(env.supabase_api_url, env.supabase_anon_key, client_options)
|
|
@@ -380,14 +380,16 @@ def _connect_instance_hub(
|
|
|
380
380
|
.data
|
|
381
381
|
)
|
|
382
382
|
if len(data) != 0 and (instance_data := data[0]["instance"]) is not None:
|
|
383
|
-
new_name = instance_data["name"]
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
383
|
+
new_name = instance_data["name"]
|
|
384
|
+
# the instance was renamed
|
|
385
|
+
if new_name != name:
|
|
386
|
+
logger.warning(
|
|
387
|
+
f"'{owner}/{name}' was renamed, please use '{owner}/{new_name}'"
|
|
388
|
+
)
|
|
389
|
+
response = client.functions.invoke(
|
|
390
|
+
"get-instance-settings-v1",
|
|
391
|
+
invoke_options={"body": {"owner": owner, "name": new_name}},
|
|
392
|
+
)
|
|
391
393
|
# no instance found, check why is that
|
|
392
394
|
if response == b"{}":
|
|
393
395
|
# try the via single requests, will take more time
|
|
@@ -22,6 +22,8 @@ from .upath import LocalPathClasses, UPath
|
|
|
22
22
|
if TYPE_CHECKING:
|
|
23
23
|
from pathlib import Path
|
|
24
24
|
|
|
25
|
+
from lamindb.models import Branch, Space
|
|
26
|
+
|
|
25
27
|
from lamindb_setup.core import InstanceSettings, StorageSettings, UserSettings
|
|
26
28
|
from lamindb_setup.types import UPathStr
|
|
27
29
|
|
|
@@ -54,6 +56,8 @@ class SetupSettings:
|
|
|
54
56
|
_instance_settings_env: str | None = None
|
|
55
57
|
|
|
56
58
|
_auto_connect_path: Path = settings_dir / "auto_connect"
|
|
59
|
+
_branch_path: Path = settings_dir / "branch_uid.txt"
|
|
60
|
+
_space_path: Path = settings_dir / "space_uid.txt"
|
|
57
61
|
_private_django_api_path: Path = settings_dir / "private_django_api"
|
|
58
62
|
|
|
59
63
|
_cache_dir: Path | None = None
|
|
@@ -91,6 +95,58 @@ class SetupSettings:
|
|
|
91
95
|
else:
|
|
92
96
|
self._auto_connect_path.unlink(missing_ok=True)
|
|
93
97
|
|
|
98
|
+
@property
|
|
99
|
+
def branch(self) -> Branch:
|
|
100
|
+
"""Default branch."""
|
|
101
|
+
from lamindb import Branch
|
|
102
|
+
|
|
103
|
+
idlike: str | int = 1
|
|
104
|
+
if self._branch_path.exists():
|
|
105
|
+
idlike = self._branch_path.read_text()
|
|
106
|
+
return Branch.get(idlike)
|
|
107
|
+
|
|
108
|
+
@branch.setter
|
|
109
|
+
def branch(self, value: str | Branch) -> None:
|
|
110
|
+
from lamindb import Branch, Q
|
|
111
|
+
from lamindb.errors import DoesNotExist
|
|
112
|
+
|
|
113
|
+
if isinstance(value, Branch):
|
|
114
|
+
assert value._state.adding is False, "Branch must be saved"
|
|
115
|
+
branch_record = value
|
|
116
|
+
else:
|
|
117
|
+
branch_record = Branch.filter(Q(name=value) | Q(uid=value)).one_or_none()
|
|
118
|
+
if branch_record is None:
|
|
119
|
+
raise DoesNotExist(
|
|
120
|
+
f"Branch '{value}', please check on the hub UI whether you have the correct `uid` or `name`."
|
|
121
|
+
)
|
|
122
|
+
self._branch_path.write_text(branch_record.uid)
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
def space(self) -> Space:
|
|
126
|
+
"""Default space."""
|
|
127
|
+
from lamindb import Space
|
|
128
|
+
|
|
129
|
+
idlike: str | int = 1
|
|
130
|
+
if self._space_path.exists():
|
|
131
|
+
idlike = self._space_path.read_text()
|
|
132
|
+
return Space.get(idlike)
|
|
133
|
+
|
|
134
|
+
@space.setter
|
|
135
|
+
def space(self, value: str | Space) -> None:
|
|
136
|
+
from lamindb import Q, Space
|
|
137
|
+
from lamindb.errors import DoesNotExist
|
|
138
|
+
|
|
139
|
+
if isinstance(value, Space):
|
|
140
|
+
assert value._state.adding is False, "Space must be saved"
|
|
141
|
+
space_record = value
|
|
142
|
+
else:
|
|
143
|
+
space_record = Space.filter(Q(name=value) | Q(uid=value)).one_or_none()
|
|
144
|
+
if space_record is None:
|
|
145
|
+
raise DoesNotExist(
|
|
146
|
+
f"Space '{value}', please check on the hub UI whether you have the correct `uid` or `name`."
|
|
147
|
+
)
|
|
148
|
+
self._space_path.write_text(space_record.uid)
|
|
149
|
+
|
|
94
150
|
@property
|
|
95
151
|
def is_connected(self) -> bool:
|
|
96
152
|
"""Determine whether the current instance is fully connected and ready to use.
|
|
@@ -205,16 +261,22 @@ class SetupSettings:
|
|
|
205
261
|
# do not show current setting representation when building docs
|
|
206
262
|
if "sphinx" in sys.modules:
|
|
207
263
|
return object.__repr__(self)
|
|
208
|
-
repr =
|
|
209
|
-
repr += f"Private Django API: {self.private_django_api}\n"
|
|
210
|
-
repr += f"Cache directory: {self.cache_dir.as_posix()}\n"
|
|
211
|
-
repr += f"User settings directory: {settings_dir.as_posix()}\n"
|
|
212
|
-
repr += f"System settings directory: {system_settings_dir.as_posix()}\n"
|
|
213
|
-
repr += self.user.__repr__() + "\n"
|
|
264
|
+
repr = ""
|
|
214
265
|
if self._instance_exists:
|
|
266
|
+
repr += "Current branch & space:\n"
|
|
267
|
+
repr += f" - branch: {self.branch.name}\n"
|
|
268
|
+
repr += f" - space: {self.space.name}\n"
|
|
215
269
|
repr += self.instance.__repr__()
|
|
216
270
|
else:
|
|
217
|
-
repr += "
|
|
271
|
+
repr += "Current instance: None"
|
|
272
|
+
repr += "\nConfig:\n"
|
|
273
|
+
repr += f" - auto-connect in Python: {self.auto_connect}\n"
|
|
274
|
+
repr += f" - private Django API: {self.private_django_api}\n"
|
|
275
|
+
repr += "Local directories:\n"
|
|
276
|
+
repr += f" - cache: {self.cache_dir.as_posix()}\n"
|
|
277
|
+
repr += f" - user settings: {settings_dir.as_posix()}\n"
|
|
278
|
+
repr += f" - system settings: {system_settings_dir.as_posix()}\n"
|
|
279
|
+
repr += self.user.__repr__()
|
|
218
280
|
return repr
|
|
219
281
|
|
|
220
282
|
|
|
@@ -97,13 +97,13 @@ class InstanceSettings:
|
|
|
97
97
|
|
|
98
98
|
def __repr__(self):
|
|
99
99
|
"""Rich string representation."""
|
|
100
|
-
representation =
|
|
101
|
-
attrs = ["
|
|
100
|
+
representation = "Current instance:"
|
|
101
|
+
attrs = ["slug", "storage", "db", "modules", "git_repo"]
|
|
102
102
|
for attr in attrs:
|
|
103
103
|
value = getattr(self, attr)
|
|
104
104
|
if attr == "storage":
|
|
105
|
-
representation += f"\n- storage root: {value.root_as_str}"
|
|
106
|
-
representation += f"\n- storage region: {value.region}"
|
|
105
|
+
representation += f"\n - storage root: {value.root_as_str}"
|
|
106
|
+
representation += f"\n - storage region: {value.region}"
|
|
107
107
|
elif attr == "db":
|
|
108
108
|
if self.dialect != "sqlite":
|
|
109
109
|
model = LaminDsnModel(db=value)
|
|
@@ -117,11 +117,11 @@ class InstanceSettings:
|
|
|
117
117
|
)
|
|
118
118
|
else:
|
|
119
119
|
db_print = value
|
|
120
|
-
representation += f"\n- {attr}: {db_print}"
|
|
120
|
+
representation += f"\n - {attr}: {db_print}"
|
|
121
121
|
elif attr == "modules":
|
|
122
|
-
representation += f"\n- {attr}: {value if value else '{}'}"
|
|
122
|
+
representation += f"\n - {attr}: {value if value else '{}'}"
|
|
123
123
|
else:
|
|
124
|
-
representation += f"\n- {attr}: {value}"
|
|
124
|
+
representation += f"\n - {attr}: {value}"
|
|
125
125
|
return representation
|
|
126
126
|
|
|
127
127
|
@property
|
|
@@ -38,11 +38,11 @@ class UserSettings:
|
|
|
38
38
|
|
|
39
39
|
def __repr__(self) -> str:
|
|
40
40
|
"""Rich string representation."""
|
|
41
|
-
representation =
|
|
41
|
+
representation = "Current user:"
|
|
42
42
|
attrs = ["handle", "email", "uid"]
|
|
43
43
|
for attr in attrs:
|
|
44
44
|
value = getattr(self, attr)
|
|
45
|
-
representation += f"\n- {attr}: {value}"
|
|
45
|
+
representation += f"\n - {attr}: {value}"
|
|
46
46
|
return representation
|
|
47
47
|
|
|
48
48
|
@property
|
|
@@ -4,6 +4,7 @@ import subprocess
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
6
|
import lamindb_setup as ln_setup
|
|
7
|
+
import pytest
|
|
7
8
|
from lamindb_setup.core.hashing import hash_dir
|
|
8
9
|
|
|
9
10
|
|
|
@@ -16,6 +17,30 @@ def test_auto_connect():
|
|
|
16
17
|
ln_setup.settings.auto_connect = current_state
|
|
17
18
|
|
|
18
19
|
|
|
20
|
+
def test_branch():
|
|
21
|
+
import lamindb as ln
|
|
22
|
+
|
|
23
|
+
ln_setup.settings._branch_path.unlink(missing_ok=True)
|
|
24
|
+
assert ln_setup.settings.branch.uid == 12 * "m"
|
|
25
|
+
ln_setup.settings.branch = "archive"
|
|
26
|
+
assert ln_setup.settings._branch_path.read_text() == 12 * "a"
|
|
27
|
+
ln_setup.settings.branch = "main"
|
|
28
|
+
assert ln_setup.settings._branch_path.read_text() == 12 * "m"
|
|
29
|
+
with pytest.raises(ln.errors.DoesNotExist):
|
|
30
|
+
ln_setup.settings.branch = "not_exists"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_space():
|
|
34
|
+
import lamindb as ln
|
|
35
|
+
|
|
36
|
+
ln_setup.settings._space_path.unlink(missing_ok=True)
|
|
37
|
+
assert ln_setup.settings.space.uid == 12 * "a"
|
|
38
|
+
ln_setup.settings.space = "all"
|
|
39
|
+
assert ln_setup.settings._space_path.read_text() == 12 * "a"
|
|
40
|
+
with pytest.raises(ln.errors.DoesNotExist):
|
|
41
|
+
ln_setup.settings.space = "not_exists"
|
|
42
|
+
|
|
43
|
+
|
|
19
44
|
def test_private_django_api():
|
|
20
45
|
from django import db
|
|
21
46
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/docs/hub-prod/test-init-load-local-anonymously.ipynb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lamindb_setup-1.7.0 → lamindb_setup-1.7.2}/tests/hub-cloud/test_init_pass_user_no_writes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|