lamindb_setup 1.3.2__tar.gz → 1.4.0__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.3.2 → lamindb_setup-1.4.0}/.gitignore +2 -2
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/PKG-INFO +2 -2
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/01-init-local-instance.ipynb +1 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/02-connect-local-instance.ipynb +1 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/03-add-managed-storage.ipynb +9 -9
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/04-test-bionty.ipynb +2 -10
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/07-keep-artifacts-local.ipynb +3 -4
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-empty-init.ipynb +1 -4
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/__init__.py +1 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_close.py +0 -3
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_connect_instance.py +1 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_delete.py +1 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_init_instance.py +26 -10
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_set_managed_storage.py +1 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_hub_client.py +3 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_hub_core.py +6 -5
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_settings_instance.py +35 -37
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_settings_load.py +1 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_settings_save.py +1 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_settings_storage.py +55 -35
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_settings_store.py +1 -0
- lamindb_setup-1.4.0/lamindb_setup/core/_setup_bionty_sources.py +44 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/django.py +1 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/upath.py +23 -18
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/pyproject.toml +1 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_connect_instance.py +1 -1
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_init_instance.py +2 -4
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-local/scripts/script-connect-fine-grained-access.py +1 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-local/test_all.py +2 -2
- lamindb_setup-1.3.2/lamindb_setup/core/_setup_bionty_sources.py +0 -116
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/.github/workflows/build.yml +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/.github/workflows/doc-changes.yml +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/.pre-commit-config.yaml +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/LICENSE +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/README.md +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/changelog.md +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/08-test-multi-session.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-cloud/test_notebooks.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-cache-management.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-cloud-sync.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-connect-anonymously-set-token.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-import-schema.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-init-load-local-anonymously.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-insufficient-user-info.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/hub-prod/test_notebooks2.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/index.md +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/notebooks.md +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/docs/reference.md +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_cache.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_check.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_check_setup.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_django.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_entry_points.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_exportdb.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_importdb.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_migrate.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_register_instance.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_schema.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_schema_metadata.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_setup_user.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/_silence_loggers.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/__init__.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_aws_options.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_aws_storage.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_deprecated.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_docs.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_hub_crud.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_hub_utils.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_private_django_api.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_settings.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/_settings_user.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/cloud_sqlite_locker.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/exceptions.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/hashing.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/lamindb_setup/core/types.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/noxfile.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_delete_instance.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_edge_request.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_login.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_migrate.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-cloud/test_set_storage.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-local/conftest.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-local/test_update_schema_in_hub.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-prod/conftest.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-prod/test_aws_options_manager.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-prod/test_django.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-prod/test_global_settings.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-prod/test_switch_and_fallback_env.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/hub-prod/test_upath.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/storage/test_entry_point.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/storage/test_hashing.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/storage/test_storage_access.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/storage/test_storage_basis.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/storage/test_storage_settings.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/storage/test_storage_stats.py +0 -0
- {lamindb_setup-1.3.2 → lamindb_setup-1.4.0}/tests/storage/test_to_url.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: lamindb_setup
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Setup & configure LaminDB.
|
|
5
5
|
Author-email: Lamin Labs <open-source@lamin.ai>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -15,13 +15,13 @@ Requires-Dist: universal_pathlib==0.2.6
|
|
|
15
15
|
Requires-Dist: botocore<2.0.0
|
|
16
16
|
Requires-Dist: supabase>=2.8.1,<=2.11.0
|
|
17
17
|
Requires-Dist: storage3!=0.11.2; python_version < '3.11'
|
|
18
|
+
Requires-Dist: pyjwt<3.0.0
|
|
18
19
|
Requires-Dist: psutil
|
|
19
20
|
Requires-Dist: packaging
|
|
20
21
|
Requires-Dist: urllib3<2 ; extra == "aws"
|
|
21
22
|
Requires-Dist: aiobotocore[boto3]>=2.5.4,<3.0.0 ; extra == "aws"
|
|
22
23
|
Requires-Dist: s3fs>=2023.12.2,<=2025.2.0,!=2024.10.0 ; extra == "aws"
|
|
23
24
|
Requires-Dist: line_profiler ; extra == "dev"
|
|
24
|
-
Requires-Dist: pyjwt<3.0.0 ; extra == "dev"
|
|
25
25
|
Requires-Dist: psycopg2-binary ; extra == "dev"
|
|
26
26
|
Requires-Dist: python-dotenv ; extra == "dev"
|
|
27
27
|
Requires-Dist: nox ; extra == "dev"
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"assert ln_setup.settings.storage.id is not None\n",
|
|
59
59
|
"assert (\n",
|
|
60
60
|
" ln_setup.settings.instance.db\n",
|
|
61
|
-
" == f\"sqlite:///{Path('./mydata').resolve().as_posix()}/
|
|
61
|
+
" == f\"sqlite:///{Path('./mydata').resolve().as_posix()}/.lamindb/lamin.db\"\n",
|
|
62
62
|
")\n",
|
|
63
63
|
"assert ln_setup.settings.storage._instance_id == ln_setup.settings.instance._id\n",
|
|
64
64
|
"assert (\n",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"assert ln_setup.settings.instance.storage.root == root_path\n",
|
|
129
129
|
"assert (\n",
|
|
130
130
|
" ln_setup.settings.instance.db\n",
|
|
131
|
-
" == f\"sqlite:///{root_path.as_posix()}/
|
|
131
|
+
" == f\"sqlite:///{root_path.as_posix()}/.lamindb/lamin.db\"\n",
|
|
132
132
|
")"
|
|
133
133
|
]
|
|
134
134
|
},
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"storage2_uid = ln_setup.settings.storage.uid\n",
|
|
134
134
|
"assert ln_setup.settings.storage.root_as_str == f\"{Path.cwd()}/storage2\"\n",
|
|
135
135
|
"assert (\n",
|
|
136
|
-
" ln_setup.settings.storage.root / \".lamindb/
|
|
136
|
+
" ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
|
|
137
137
|
").read_text() == ln_setup.settings.storage.uid\n",
|
|
138
138
|
"assert ln_setup.settings.storage.is_on_hub"
|
|
139
139
|
]
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"source": [
|
|
166
166
|
"assert ln_setup.settings.storage.root_as_str == f\"{Path.cwd()}/storage1\"\n",
|
|
167
167
|
"assert (\n",
|
|
168
|
-
" ln_setup.settings.storage.root / \".lamindb/
|
|
168
|
+
" ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
|
|
169
169
|
").read_text() == ln_setup.settings.storage.uid\n",
|
|
170
170
|
"assert ln_setup.settings.storage.is_on_hub\n",
|
|
171
171
|
"assert ln_setup.settings.storage.uid == storage1_uid"
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"source": [
|
|
199
199
|
"assert ln_setup.settings.storage.root_as_str == f\"{Path.cwd()}/storage1\"\n",
|
|
200
200
|
"assert (\n",
|
|
201
|
-
" ln_setup.settings.storage.root / \".lamindb/
|
|
201
|
+
" ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
|
|
202
202
|
").read_text() == ln_setup.settings.storage.uid\n",
|
|
203
203
|
"assert ln_setup.settings.storage.is_on_hub\n",
|
|
204
204
|
"assert ln_setup.settings.storage.uid == storage1_uid"
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
"storage2_uid = ln_setup.settings.storage.uid\n",
|
|
225
225
|
"assert ln_setup.settings.storage.root_as_str == f\"{Path.cwd()}/storage2\"\n",
|
|
226
226
|
"assert (\n",
|
|
227
|
-
" ln_setup.settings.storage.root / \".lamindb/
|
|
227
|
+
" ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
|
|
228
228
|
").read_text() == ln_setup.settings.storage.uid\n",
|
|
229
229
|
"assert ln_setup.settings.storage.is_on_hub\n",
|
|
230
230
|
"assert ln_setup.settings.storage.uid == storage2_uid"
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
"assert ln_setup.settings.storage.root_as_str == \"s3://lamindb-ci/storage3\"\n",
|
|
264
264
|
"assert ln_setup.settings.storage.region == \"us-west-1\"\n",
|
|
265
265
|
"assert (\n",
|
|
266
|
-
" ln_setup.settings.storage.root / \".lamindb/
|
|
266
|
+
" ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
|
|
267
267
|
").read_text() == ln_setup.settings.storage.uid\n",
|
|
268
268
|
"# root.fs contains the underlying fsspec filesystem\n",
|
|
269
269
|
"assert (\n",
|
|
@@ -338,13 +338,13 @@
|
|
|
338
338
|
"metadata": {},
|
|
339
339
|
"outputs": [],
|
|
340
340
|
"source": [
|
|
341
|
-
"from laminhub_rest.core.
|
|
342
|
-
"from laminhub_rest.core.account
|
|
341
|
+
"from laminhub_rest.core.legacy._instance_collaborator import InstanceCollaboratorHandler\n",
|
|
342
|
+
"from laminhub_rest.core.account import AccountHandler\n",
|
|
343
343
|
"from lamindb_setup.core._hub_client import connect_hub_with_auth\n",
|
|
344
344
|
"from lamindb.models import User\n",
|
|
345
345
|
"\n",
|
|
346
346
|
"admin_hub = connect_hub_with_auth()\n",
|
|
347
|
-
"testuser2 =
|
|
347
|
+
"testuser2 = AccountHandler(admin_hub).get_by_handle(\"testuser2\")\n",
|
|
348
348
|
"InstanceCollaboratorHandler(admin_hub).add(\n",
|
|
349
349
|
" instance_id=instance_id,\n",
|
|
350
350
|
" account_id=testuser2.id,\n",
|
|
@@ -457,7 +457,7 @@
|
|
|
457
457
|
"name": "python",
|
|
458
458
|
"nbconvert_exporter": "python",
|
|
459
459
|
"pygments_lexer": "ipython3",
|
|
460
|
-
"version": "3.
|
|
460
|
+
"version": "3.10.16"
|
|
461
461
|
},
|
|
462
462
|
"vscode": {
|
|
463
463
|
"interpreter": {
|
|
@@ -70,10 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"outputs": [],
|
|
72
72
|
"source": [
|
|
73
|
-
"
|
|
74
|
-
"\n",
|
|
75
|
-
"assert sources_df.shape[0] > 0\n",
|
|
76
|
-
"assert bionty_base_settings.lamindb_sources.exists()"
|
|
73
|
+
"assert sources_df.shape[0] > 0"
|
|
77
74
|
]
|
|
78
75
|
},
|
|
79
76
|
{
|
|
@@ -140,7 +137,7 @@
|
|
|
140
137
|
],
|
|
141
138
|
"metadata": {
|
|
142
139
|
"kernelspec": {
|
|
143
|
-
"display_name": "
|
|
140
|
+
"display_name": "py310",
|
|
144
141
|
"language": "python",
|
|
145
142
|
"name": "python3"
|
|
146
143
|
},
|
|
@@ -155,11 +152,6 @@
|
|
|
155
152
|
"nbconvert_exporter": "python",
|
|
156
153
|
"pygments_lexer": "ipython3",
|
|
157
154
|
"version": "3.10.13"
|
|
158
|
-
},
|
|
159
|
-
"vscode": {
|
|
160
|
-
"interpreter": {
|
|
161
|
-
"hash": "61b4062b24dfb1010f420dad5aa3bd73a4d2af47d0ec44eafec465a35a9d7239"
|
|
162
|
-
}
|
|
163
155
|
}
|
|
164
156
|
},
|
|
165
157
|
"nbformat": 4,
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
"assert ln_setup.settings.instance.storage.type_is_cloud\n",
|
|
32
32
|
"assert ln_setup.settings.instance.storage.root_as_str == storage\n",
|
|
33
33
|
"assert (\n",
|
|
34
|
-
" ln_setup.settings.instance._sqlite_file.as_posix()\n",
|
|
35
|
-
" == f\"{storage}/{ln_setup.settings.instance._id.hex}.lndb\"\n",
|
|
34
|
+
" ln_setup.settings.instance._sqlite_file.as_posix() == f\"{storage}/.lamindb/lamin.db\"\n",
|
|
36
35
|
")"
|
|
37
36
|
]
|
|
38
37
|
},
|
|
@@ -75,7 +74,7 @@
|
|
|
75
74
|
" == UPath(\"./my_storage_local\").resolve().as_posix()\n",
|
|
76
75
|
")\n",
|
|
77
76
|
"assert (\n",
|
|
78
|
-
" ln_setup.settings.instance.storage_local.root / \".lamindb/
|
|
77
|
+
" ln_setup.settings.instance.storage_local.root / \".lamindb/storage_uid.txt\"\n",
|
|
79
78
|
").read_text() == ln_setup.settings.instance.storage_local.uid\n",
|
|
80
79
|
"assert ln_setup.settings.instance.storage_local is not None\n",
|
|
81
80
|
"# the remote storage location is still in the regular slot\n",
|
|
@@ -109,7 +108,7 @@
|
|
|
109
108
|
" == UPath(\"./my_storage_local2\").resolve().as_posix()\n",
|
|
110
109
|
")\n",
|
|
111
110
|
"assert (\n",
|
|
112
|
-
" ln_setup.settings.instance.storage_local.root / \".lamindb/
|
|
111
|
+
" ln_setup.settings.instance.storage_local.root / \".lamindb/storage_uid.txt\"\n",
|
|
113
112
|
").read_text() == ln_setup.settings.instance.storage_local.uid"
|
|
114
113
|
]
|
|
115
114
|
},
|
|
@@ -74,10 +74,7 @@
|
|
|
74
74
|
"assert ln_setup.settings.storage.type_is_cloud\n",
|
|
75
75
|
"assert ln_setup.settings.storage.root_as_str == root_str\n",
|
|
76
76
|
"assert ln_setup.settings.storage.region == \"us-east-1\"\n",
|
|
77
|
-
"assert (\
|
|
78
|
-
" str(ln_setup.settings.instance._sqlite_file)\n",
|
|
79
|
-
" == f\"{root_str}/{ln_setup.settings.instance._id.hex}.lndb\"\n",
|
|
80
|
-
")"
|
|
77
|
+
"assert str(ln_setup.settings.instance._sqlite_file) == f\"{root_str}/.lamindb/lamin.db\""
|
|
81
78
|
]
|
|
82
79
|
},
|
|
83
80
|
{
|
|
@@ -4,7 +4,6 @@ from lamin_utils import logger
|
|
|
4
4
|
|
|
5
5
|
from .core._settings import settings
|
|
6
6
|
from .core._settings_store import current_instance_settings_file
|
|
7
|
-
from .core._setup_bionty_sources import delete_bionty_sources_yaml
|
|
8
7
|
from .core.cloud_sqlite_locker import clear_locker
|
|
9
8
|
|
|
10
9
|
|
|
@@ -24,8 +23,6 @@ def close(mute: bool = False) -> None:
|
|
|
24
23
|
logger.warning("did not upload cache file - not enough permissions")
|
|
25
24
|
else:
|
|
26
25
|
raise e
|
|
27
|
-
if "bionty" in settings.instance.modules:
|
|
28
|
-
delete_bionty_sources_yaml()
|
|
29
26
|
current_instance_settings_file().unlink()
|
|
30
27
|
clear_locker()
|
|
31
28
|
if not mute:
|
|
@@ -169,6 +169,7 @@ def _connect_instance(
|
|
|
169
169
|
if (schema_id := instance_result["schema_id"]) is None
|
|
170
170
|
else UUID(schema_id),
|
|
171
171
|
fine_grained_access=instance_result.get("fine_grained_access", False),
|
|
172
|
+
db_permissions=instance_result.get("db_permissions", None),
|
|
172
173
|
)
|
|
173
174
|
else:
|
|
174
175
|
if hub_result != "anonymous-user":
|
|
@@ -131,7 +131,7 @@ def delete(slug: str, force: bool = False, require_empty: bool = True) -> int |
|
|
|
131
131
|
# this will error if the user doesn't have permission
|
|
132
132
|
delete_instance_on_hub(isettings._id, require_empty=False)
|
|
133
133
|
delete_by_isettings(isettings)
|
|
134
|
-
# if .
|
|
134
|
+
# if lamin.db file was delete, then we might count -1
|
|
135
135
|
if n_files <= 0 and isettings.storage.type == "local":
|
|
136
136
|
# dir is only empty after sqlite file was delete via delete_by_isettings
|
|
137
137
|
if (isettings.storage.root / ".lamindb").exists():
|
|
@@ -14,6 +14,7 @@ from lamin_utils import logger
|
|
|
14
14
|
from ._close import close as close_instance
|
|
15
15
|
from ._silence_loggers import silence_loggers
|
|
16
16
|
from .core import InstanceSettings
|
|
17
|
+
from .core._docs import doc_args
|
|
17
18
|
from .core._settings import settings
|
|
18
19
|
from .core._settings_instance import is_local_db_url
|
|
19
20
|
from .core._settings_storage import StorageSettings, init_storage
|
|
@@ -95,11 +96,16 @@ def register_user(usettings):
|
|
|
95
96
|
pass
|
|
96
97
|
|
|
97
98
|
|
|
98
|
-
def
|
|
99
|
-
"""Register user & storage in DB."""
|
|
99
|
+
def register_initial_records(isettings: InstanceSettings, usettings):
|
|
100
|
+
"""Register space, user & storage in DB."""
|
|
100
101
|
from django.db.utils import OperationalError
|
|
102
|
+
from lamindb.models import Space
|
|
101
103
|
|
|
102
104
|
try:
|
|
105
|
+
Space.objects.get_or_create(
|
|
106
|
+
name="All",
|
|
107
|
+
description="Every team & user with access to the instance has access.",
|
|
108
|
+
)
|
|
103
109
|
register_user(usettings)
|
|
104
110
|
register_storage_in_instance(isettings.storage)
|
|
105
111
|
except OperationalError as error:
|
|
@@ -208,22 +214,32 @@ ln.Artifact.using("laminlabs/cellxgene").filter()
|
|
|
208
214
|
Or do you want to switch off auto-connect via `lamin settings set auto-connect false`?
|
|
209
215
|
"""
|
|
210
216
|
|
|
217
|
+
DOC_STORAGE_ARG = "A local or remote folder (`'s3://...'` or `'gs://...'`). Defaults to current working directory."
|
|
218
|
+
DOC_INSTANCE_NAME = (
|
|
219
|
+
"Instance name. If not passed, it will equal the folder name passed to `storage`."
|
|
220
|
+
)
|
|
221
|
+
DOC_DB = "Database connection URL. Defaults to `None`, which implies an SQLite file in the storage location."
|
|
222
|
+
DOC_MODULES = "Comma-separated string of schema modules."
|
|
223
|
+
DOC_LOW_LEVEL_KWARGS = "Keyword arguments for low-level control."
|
|
224
|
+
|
|
211
225
|
|
|
226
|
+
@doc_args(DOC_STORAGE_ARG, DOC_INSTANCE_NAME, DOC_DB, DOC_MODULES, DOC_LOW_LEVEL_KWARGS)
|
|
212
227
|
def init(
|
|
213
228
|
*,
|
|
214
|
-
storage: UPathStr,
|
|
229
|
+
storage: UPathStr = ".",
|
|
215
230
|
name: str | None = None,
|
|
216
231
|
db: PostgresDsn | None = None,
|
|
217
232
|
modules: str | None = None,
|
|
218
233
|
**kwargs,
|
|
219
234
|
) -> None:
|
|
220
|
-
"""
|
|
235
|
+
"""Init a LaminDB instance.
|
|
221
236
|
|
|
222
237
|
Args:
|
|
223
|
-
storage:
|
|
224
|
-
name:
|
|
225
|
-
db:
|
|
226
|
-
modules:
|
|
238
|
+
storage: {}
|
|
239
|
+
name: {}
|
|
240
|
+
db: {}
|
|
241
|
+
modules: {}
|
|
242
|
+
**kwargs: {}
|
|
227
243
|
"""
|
|
228
244
|
isettings = None
|
|
229
245
|
ssettings = None
|
|
@@ -359,8 +375,8 @@ def load_from_isettings(
|
|
|
359
375
|
user = settings.user if user is None else user
|
|
360
376
|
|
|
361
377
|
if init:
|
|
362
|
-
# during init
|
|
363
|
-
|
|
378
|
+
# during init space, user and storage need to be registered
|
|
379
|
+
register_initial_records(isettings, user)
|
|
364
380
|
write_bionty_sources(isettings)
|
|
365
381
|
isettings._update_cloud_sqlite_file(unlock_cloud_sqlite=False)
|
|
366
382
|
else:
|
|
@@ -31,7 +31,7 @@ def set_managed_storage(root: UPathStr, **fs_kwargs):
|
|
|
31
31
|
)
|
|
32
32
|
# here the storage is registered in the hub
|
|
33
33
|
# hub_record_status="hub-record-created" if a new record is created
|
|
34
|
-
# "hub-record-
|
|
34
|
+
# "hub-record-retrieved" if the storage is in the hub already
|
|
35
35
|
ssettings, hub_record_status = init_storage(
|
|
36
36
|
root=root, instance_id=settings.instance._id, register_hub=True
|
|
37
37
|
)
|
|
@@ -69,7 +69,9 @@ def connect_hub(
|
|
|
69
69
|
# function_client_timeout=5 by default
|
|
70
70
|
# increase to avoid rare timeouts for edge functions
|
|
71
71
|
client_options = ClientOptions(
|
|
72
|
-
auto_refresh_token=False,
|
|
72
|
+
auto_refresh_token=False,
|
|
73
|
+
function_client_timeout=20,
|
|
74
|
+
postgrest_client_timeout=20,
|
|
73
75
|
)
|
|
74
76
|
return create_client(env.supabase_api_url, env.supabase_anon_key, client_options)
|
|
75
77
|
|
|
@@ -7,6 +7,7 @@ from importlib import metadata
|
|
|
7
7
|
from typing import TYPE_CHECKING, Literal
|
|
8
8
|
from uuid import UUID
|
|
9
9
|
|
|
10
|
+
import jwt
|
|
10
11
|
from lamin_utils import logger
|
|
11
12
|
from postgrest.exceptions import APIError
|
|
12
13
|
|
|
@@ -121,7 +122,7 @@ def init_storage_hub(
|
|
|
121
122
|
auto_populate_instance: bool = True,
|
|
122
123
|
created_by: UUID | None = None,
|
|
123
124
|
access_token: str | None = None,
|
|
124
|
-
) -> Literal["hub-record-
|
|
125
|
+
) -> Literal["hub-record-retrieved", "hub-record-created"]:
|
|
125
126
|
if settings.user.handle != "anonymous" or access_token is not None:
|
|
126
127
|
return call_with_fallback_auth(
|
|
127
128
|
_init_storage_hub,
|
|
@@ -135,7 +136,7 @@ def init_storage_hub(
|
|
|
135
136
|
_select_storage, ssettings=ssettings, update_uid=True
|
|
136
137
|
)
|
|
137
138
|
if storage_exists:
|
|
138
|
-
return "hub-record-
|
|
139
|
+
return "hub-record-retrieved"
|
|
139
140
|
else:
|
|
140
141
|
raise ValueError("Log in to create a storage location on the hub.")
|
|
141
142
|
|
|
@@ -145,7 +146,7 @@ def _init_storage_hub(
|
|
|
145
146
|
ssettings: StorageSettings,
|
|
146
147
|
auto_populate_instance: bool,
|
|
147
148
|
created_by: UUID | None = None,
|
|
148
|
-
) -> Literal["hub-record-
|
|
149
|
+
) -> Literal["hub-record-retrieved", "hub-record-created"]:
|
|
149
150
|
from lamindb_setup import settings
|
|
150
151
|
|
|
151
152
|
created_by = settings.user._uuid if created_by is None else created_by
|
|
@@ -153,7 +154,7 @@ def _init_storage_hub(
|
|
|
153
154
|
# database
|
|
154
155
|
root = ssettings.root_as_str
|
|
155
156
|
if _select_storage(ssettings, update_uid=True, client=client):
|
|
156
|
-
return "hub-record-
|
|
157
|
+
return "hub-record-retrieved"
|
|
157
158
|
if ssettings.type_is_cloud:
|
|
158
159
|
id = uuid.uuid5(uuid.NAMESPACE_URL, root)
|
|
159
160
|
else:
|
|
@@ -548,7 +549,7 @@ def _sign_in_hub_api_key(api_key: str, client: Client):
|
|
|
548
549
|
access_token = json.loads(response)["accessToken"]
|
|
549
550
|
# probably need more info here to avoid additional queries
|
|
550
551
|
# like handle, uid etc
|
|
551
|
-
account_id =
|
|
552
|
+
account_id = jwt.decode(access_token, options={"verify_signature": False})["sub"]
|
|
552
553
|
client.postgrest.auth(access_token)
|
|
553
554
|
# normally public.account.id is equal to auth.user.id
|
|
554
555
|
data = client.table("account").select("*").eq("id", account_id).execute().data
|
|
@@ -13,7 +13,12 @@ from ._hub_client import call_with_fallback
|
|
|
13
13
|
from ._hub_crud import select_account_handle_name_by_lnid
|
|
14
14
|
from ._hub_utils import LaminDsn, LaminDsnModel
|
|
15
15
|
from ._settings_save import save_instance_settings
|
|
16
|
-
from ._settings_storage import
|
|
16
|
+
from ._settings_storage import (
|
|
17
|
+
LEGACY_STORAGE_UID_FILE_KEY,
|
|
18
|
+
STORAGE_UID_FILE_KEY,
|
|
19
|
+
StorageSettings,
|
|
20
|
+
init_storage,
|
|
21
|
+
)
|
|
17
22
|
from ._settings_store import current_instance_settings_file, instance_settings_file
|
|
18
23
|
from .cloud_sqlite_locker import (
|
|
19
24
|
EXPIRATION_TIME,
|
|
@@ -60,6 +65,7 @@ class InstanceSettings:
|
|
|
60
65
|
api_url: str | None = None,
|
|
61
66
|
schema_id: UUID | None = None,
|
|
62
67
|
fine_grained_access: bool = False,
|
|
68
|
+
db_permissions: str | None = None,
|
|
63
69
|
_locker_user: UserSettings | None = None, # user to lock for if cloud sqlite
|
|
64
70
|
):
|
|
65
71
|
from ._hub_utils import validate_db_arg
|
|
@@ -83,6 +89,8 @@ class InstanceSettings:
|
|
|
83
89
|
# private, whether fine grained access is used
|
|
84
90
|
# needed to be set to request jwt etc
|
|
85
91
|
self._fine_grained_access = fine_grained_access
|
|
92
|
+
# permissions for db such as jwt, read, write etc.
|
|
93
|
+
self._db_permissions = db_permissions
|
|
86
94
|
# if None then settings.user is used
|
|
87
95
|
self._locker_user = _locker_user
|
|
88
96
|
|
|
@@ -144,32 +152,27 @@ class InstanceSettings:
|
|
|
144
152
|
for record in all_local_records:
|
|
145
153
|
root_path = Path(record.root)
|
|
146
154
|
if root_path.exists():
|
|
147
|
-
marker_path = root_path /
|
|
148
|
-
if marker_path.exists():
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
except PermissionError:
|
|
155
|
+
marker_path = root_path / STORAGE_UID_FILE_KEY
|
|
156
|
+
if not marker_path.exists():
|
|
157
|
+
legacy_filepath = root_path / LEGACY_STORAGE_UID_FILE_KEY
|
|
158
|
+
if legacy_filepath.exists():
|
|
152
159
|
logger.warning(
|
|
153
|
-
f"
|
|
160
|
+
f"found legacy marker file, renaming it from {legacy_filepath} to {marker_path}"
|
|
154
161
|
)
|
|
155
|
-
|
|
156
|
-
if uid == record.uid:
|
|
157
|
-
found = True
|
|
158
|
-
break
|
|
159
|
-
elif uid == "":
|
|
160
|
-
try:
|
|
161
|
-
# legacy instance that was not yet marked properly
|
|
162
|
-
mark_storage_root(record.root, record.uid)
|
|
163
|
-
except PermissionError:
|
|
164
|
-
logger.warning(
|
|
165
|
-
f"ignoring the following location because no permission to write to it: {marker_path}"
|
|
166
|
-
)
|
|
167
|
-
continue
|
|
162
|
+
legacy_filepath.rename(marker_path)
|
|
168
163
|
else:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
164
|
+
raise ValueError(
|
|
165
|
+
f"local storage location '{root_path}' is corrupted, cannot find marker file with storage uid"
|
|
166
|
+
)
|
|
167
|
+
try:
|
|
168
|
+
uid = marker_path.read_text()
|
|
169
|
+
except PermissionError:
|
|
170
|
+
logger.warning(
|
|
171
|
+
f"ignoring the following location because no permission to read it: {marker_path}"
|
|
172
|
+
)
|
|
173
|
+
continue
|
|
174
|
+
if uid == record.uid:
|
|
175
|
+
found = True
|
|
173
176
|
break
|
|
174
177
|
if found:
|
|
175
178
|
return StorageSettings(record.root)
|
|
@@ -295,7 +298,8 @@ class InstanceSettings:
|
|
|
295
298
|
@property
|
|
296
299
|
def _sqlite_file(self) -> UPath:
|
|
297
300
|
"""SQLite file."""
|
|
298
|
-
|
|
301
|
+
filepath = self.storage.root / ".lamindb/lamin.db"
|
|
302
|
+
return filepath
|
|
299
303
|
|
|
300
304
|
@property
|
|
301
305
|
def _sqlite_file_local(self) -> Path:
|
|
@@ -477,24 +481,18 @@ class InstanceSettings:
|
|
|
477
481
|
|
|
478
482
|
disable_auto_connect(setup_django)(self, init=True)
|
|
479
483
|
|
|
480
|
-
from lamindb.models import Space
|
|
481
|
-
|
|
482
|
-
Space.objects.get_or_create(
|
|
483
|
-
name="All",
|
|
484
|
-
description="Every team & user with access to the instance has access.",
|
|
485
|
-
)
|
|
486
|
-
|
|
487
484
|
def _load_db(self) -> tuple[bool, str]:
|
|
488
485
|
# Is the database available and initialized as LaminDB?
|
|
489
486
|
# returns a tuple of status code and message
|
|
490
487
|
if self.dialect == "sqlite" and not self._sqlite_file.exists():
|
|
491
|
-
legacy_file = self.storage.key_to_filepath(f"{self.
|
|
488
|
+
legacy_file = self.storage.key_to_filepath(f"{self._id.hex}.lndb")
|
|
492
489
|
if legacy_file.exists():
|
|
493
|
-
|
|
494
|
-
"The SQLite file
|
|
495
|
-
f" {legacy_file} to {self._sqlite_file}"
|
|
490
|
+
logger.warning(
|
|
491
|
+
f"The SQLite file is being renamed from {legacy_file} to {self._sqlite_file}"
|
|
496
492
|
)
|
|
497
|
-
|
|
493
|
+
legacy_file.rename(self._sqlite_file)
|
|
494
|
+
else:
|
|
495
|
+
return False, f"SQLite file {self._sqlite_file} does not exist"
|
|
498
496
|
# we need the local sqlite to setup django
|
|
499
497
|
self._update_local_sqlite_file()
|
|
500
498
|
# setting up django also performs a check for migrations & prints them
|
|
@@ -104,6 +104,7 @@ def setup_instance_from_store(store: InstanceSettingsStore) -> InstanceSettings:
|
|
|
104
104
|
api_url=_null_to_value(store.api_url),
|
|
105
105
|
schema_id=None if store.schema_id == "null" else UUID(store.schema_id),
|
|
106
106
|
fine_grained_access=store.fine_grained_access,
|
|
107
|
+
db_permissions=_null_to_value(store.db_permissions),
|
|
107
108
|
)
|
|
108
109
|
|
|
109
110
|
|