lamindb_setup 0.77.6__tar.gz → 0.79.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-0.77.6 → lamindb_setup-0.79.0}/PKG-INFO +3 -2
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/02-connect-local-instance.ipynb +2 -25
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/03-add-managed-storage.ipynb +1 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/08-test-multi-session.ipynb +7 -3
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-cache-management.ipynb +23 -47
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-cloud-sync.ipynb +6 -6
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-init-load-local-anonymously.ipynb +1 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-insufficient-user-info.ipynb +1 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/__init__.py +1 -1
- lamindb_setup-0.79.0/lamindb_setup/_cache.py +48 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_check_setup.py +3 -3
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_connect_instance.py +15 -5
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_delete.py +1 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_django.py +0 -2
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_init_instance.py +22 -10
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_setup_user.py +1 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_hub_core.py +5 -66
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_hub_utils.py +1 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings.py +39 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_instance.py +6 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_load.py +14 -2
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_save.py +20 -9
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_storage.py +7 -69
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_user.py +1 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/cloud_sqlite_locker.py +1 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/django.py +11 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/exceptions.py +0 -2
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/hashing.py +3 -1
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/types.py +1 -3
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/noxfile.py +2 -2
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/pyproject.toml +2 -1
- lamindb_setup-0.79.0/tests/hub-cloud/test_edge_request.py +63 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_init_instance.py +8 -2
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-local/test_all.py +34 -58
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/test_switch_and_fallback_env.py +2 -2
- lamindb_setup-0.77.6/lamindb_setup/_cache.py +0 -34
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/.github/workflows/build.yml +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/.github/workflows/doc-changes.yml +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/.gitignore +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/.pre-commit-config.yaml +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/LICENSE +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/README.md +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/changelog.md +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/test_notebooks.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-empty-init.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-import-schema.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test_notebooks2.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/index.md +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/notebooks.md +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/reference.md +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_check.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_close.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_entry_points.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_exportdb.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_importdb.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_migrate.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_register_instance.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_schema.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_schema_metadata.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_set_managed_storage.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_silence_loggers.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/__init__.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_aws_credentials.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_aws_storage.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_deprecated.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_docs.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_hub_client.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_hub_crud.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_private_django_api.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_store.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/upath.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_connect_instance.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_delete_instance.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_login.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_migrate.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_set_storage.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-local/conftest.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-local/test_update_schema_in_hub.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/conftest.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/test_django.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/test_global_settings.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/test_upath.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_entry_point.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_hashing.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_storage_access.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_storage_basis.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_storage_stats.py +0 -0
- {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_to_url.py +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lamindb_setup
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.79.0
|
|
4
4
|
Summary: Setup & configure LaminDB.
|
|
5
5
|
Author-email: Lamin Labs <open-source@lamin.ai>
|
|
6
|
+
Requires-Python: >=3.9
|
|
6
7
|
Description-Content-Type: text/markdown
|
|
7
8
|
Requires-Dist: lnschema_core>=0.51.0
|
|
8
9
|
Requires-Dist: lamin_utils>=0.3.3
|
|
@@ -11,7 +12,7 @@ Requires-Dist: dj_database_url>=1.3.0,<3.0.0
|
|
|
11
12
|
Requires-Dist: pydantic-settings
|
|
12
13
|
Requires-Dist: appdirs<2.0.0
|
|
13
14
|
Requires-Dist: requests
|
|
14
|
-
Requires-Dist: universal_pathlib==0.2.
|
|
15
|
+
Requires-Dist: universal_pathlib==0.2.5
|
|
15
16
|
Requires-Dist: botocore<2.0.0
|
|
16
17
|
Requires-Dist: gotrue>=2.1.0,<2.9.0
|
|
17
18
|
Requires-Dist: supabase==2.2.1
|
{lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/02-connect-local-instance.ipynb
RENAMED
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
},
|
|
20
20
|
"outputs": [],
|
|
21
21
|
"source": [
|
|
22
|
-
"!lamin
|
|
22
|
+
"!lamin disconnect\n",
|
|
23
23
|
"!lamin delete --force mydata\n",
|
|
24
24
|
"!lamin init --storage mydata\n",
|
|
25
|
-
"!lamin
|
|
25
|
+
"!lamin disconnect"
|
|
26
26
|
]
|
|
27
27
|
},
|
|
28
28
|
{
|
|
@@ -85,29 +85,6 @@
|
|
|
85
85
|
")"
|
|
86
86
|
]
|
|
87
87
|
},
|
|
88
|
-
{
|
|
89
|
-
"cell_type": "markdown",
|
|
90
|
-
"id": "0986a5f3",
|
|
91
|
-
"metadata": {},
|
|
92
|
-
"source": [
|
|
93
|
-
"You cannot load another instance in the same Python session:"
|
|
94
|
-
]
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"cell_type": "code",
|
|
98
|
-
"execution_count": null,
|
|
99
|
-
"id": "bc3568ae",
|
|
100
|
-
"metadata": {},
|
|
101
|
-
"outputs": [],
|
|
102
|
-
"source": [
|
|
103
|
-
"import pytest\n",
|
|
104
|
-
"\n",
|
|
105
|
-
"with pytest.raises(RuntimeError):\n",
|
|
106
|
-
" ln_setup.connect(\"testuser2/mydata\")\n",
|
|
107
|
-
"\n",
|
|
108
|
-
"assert ln_setup.settings.instance.slug == \"testuser1/mydata\""
|
|
109
|
-
]
|
|
110
|
-
},
|
|
111
88
|
{
|
|
112
89
|
"cell_type": "markdown",
|
|
113
90
|
"id": "e3701120",
|
|
@@ -113,14 +113,18 @@
|
|
|
113
113
|
"metadata": {},
|
|
114
114
|
"outputs": [],
|
|
115
115
|
"source": [
|
|
116
|
-
"
|
|
116
|
+
"from lamindb_setup._init_instance import CannotSwitchDefaultInstance\n",
|
|
117
|
+
"\n",
|
|
118
|
+
"with pytest.raises(CannotSwitchDefaultInstance):\n",
|
|
117
119
|
" ln_setup.init(storage=\"./testsetup2\")\n",
|
|
118
|
-
"with pytest.raises(
|
|
120
|
+
"with pytest.raises(CannotSwitchDefaultInstance):\n",
|
|
119
121
|
" ln_setup.connect(\"testsetup\")\n",
|
|
120
122
|
"with pytest.raises(RuntimeError):\n",
|
|
121
123
|
" ln_setup.migrate.create()\n",
|
|
122
124
|
"with pytest.raises(RuntimeError):\n",
|
|
123
|
-
" ln_setup.migrate.deploy()"
|
|
125
|
+
" ln_setup.migrate.deploy()\n",
|
|
126
|
+
"\n",
|
|
127
|
+
"assert ln_setup.settings.instance.slug == \"testuser1/testsetup\""
|
|
124
128
|
]
|
|
125
129
|
},
|
|
126
130
|
{
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
"metadata": {},
|
|
16
16
|
"outputs": [],
|
|
17
17
|
"source": [
|
|
18
|
+
"import os\n",
|
|
18
19
|
"import lamindb_setup as ln_setup\n",
|
|
20
|
+
"from lamindb_setup._cache import set_cache_dir\n",
|
|
19
21
|
"from lamindb_setup.core._settings_store import system_storage_settings_file\n",
|
|
20
22
|
"\n",
|
|
21
23
|
"ln_setup.login(\"testuser2\")"
|
|
@@ -67,8 +69,8 @@
|
|
|
67
69
|
"metadata": {},
|
|
68
70
|
"outputs": [],
|
|
69
71
|
"source": [
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
+
"old_cache_dir = ln_setup.settings.cache_dir\n",
|
|
73
|
+
"new_cache_dir = old_cache_dir.parent / \"Cache1\""
|
|
72
74
|
]
|
|
73
75
|
},
|
|
74
76
|
{
|
|
@@ -78,7 +80,7 @@
|
|
|
78
80
|
"metadata": {},
|
|
79
81
|
"outputs": [],
|
|
80
82
|
"source": [
|
|
81
|
-
"
|
|
83
|
+
"set_cache_dir(new_cache_dir)"
|
|
82
84
|
]
|
|
83
85
|
},
|
|
84
86
|
{
|
|
@@ -94,21 +96,11 @@
|
|
|
94
96
|
{
|
|
95
97
|
"cell_type": "code",
|
|
96
98
|
"execution_count": null,
|
|
97
|
-
"id": "
|
|
99
|
+
"id": "c1958c5b",
|
|
98
100
|
"metadata": {},
|
|
99
101
|
"outputs": [],
|
|
100
102
|
"source": [
|
|
101
|
-
"assert ln_setup.settings.
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"cell_type": "code",
|
|
106
|
-
"execution_count": null,
|
|
107
|
-
"id": "5b5ca8a8",
|
|
108
|
-
"metadata": {},
|
|
109
|
-
"outputs": [],
|
|
110
|
-
"source": [
|
|
111
|
-
"assert ln_setup.settings.storage.cache_dir == set_cache_dir"
|
|
103
|
+
"assert ln_setup.settings.cache_dir == new_cache_dir"
|
|
112
104
|
]
|
|
113
105
|
},
|
|
114
106
|
{
|
|
@@ -118,7 +110,7 @@
|
|
|
118
110
|
"metadata": {},
|
|
119
111
|
"outputs": [],
|
|
120
112
|
"source": [
|
|
121
|
-
"assert
|
|
113
|
+
"assert new_cache_dir.exists()"
|
|
122
114
|
]
|
|
123
115
|
},
|
|
124
116
|
{
|
|
@@ -128,7 +120,7 @@
|
|
|
128
120
|
"metadata": {},
|
|
129
121
|
"outputs": [],
|
|
130
122
|
"source": [
|
|
131
|
-
"assert
|
|
123
|
+
"assert new_cache_dir in ln_setup.settings.instance._sqlite_file_local.parents"
|
|
132
124
|
]
|
|
133
125
|
},
|
|
134
126
|
{
|
|
@@ -156,53 +148,35 @@
|
|
|
156
148
|
"metadata": {},
|
|
157
149
|
"outputs": [],
|
|
158
150
|
"source": [
|
|
159
|
-
"assert not any(
|
|
151
|
+
"assert not any(new_cache_dir.iterdir())"
|
|
160
152
|
]
|
|
161
153
|
},
|
|
162
154
|
{
|
|
163
155
|
"cell_type": "markdown",
|
|
164
|
-
"id": "
|
|
165
|
-
"metadata": {},
|
|
166
|
-
"source": [
|
|
167
|
-
"Check that the cache dir is preserved between`close` and `load`."
|
|
168
|
-
]
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"cell_type": "code",
|
|
172
|
-
"execution_count": null,
|
|
173
|
-
"id": "a05bb5a2",
|
|
156
|
+
"id": "e2aeabb4",
|
|
174
157
|
"metadata": {},
|
|
175
|
-
"outputs": [],
|
|
176
158
|
"source": [
|
|
177
|
-
"
|
|
159
|
+
"Setting to `\"null\"` or `None` restores the default directory."
|
|
178
160
|
]
|
|
179
161
|
},
|
|
180
162
|
{
|
|
181
163
|
"cell_type": "code",
|
|
182
164
|
"execution_count": null,
|
|
183
|
-
"id": "
|
|
165
|
+
"id": "95aec7fd",
|
|
184
166
|
"metadata": {},
|
|
185
167
|
"outputs": [],
|
|
186
168
|
"source": [
|
|
187
|
-
"
|
|
188
|
-
]
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"cell_type": "markdown",
|
|
192
|
-
"id": "e2aeabb4",
|
|
193
|
-
"metadata": {},
|
|
194
|
-
"source": [
|
|
195
|
-
"Setting to `\"null\"` or `None` restores the default directory."
|
|
169
|
+
"set_cache_dir(\"null\")"
|
|
196
170
|
]
|
|
197
171
|
},
|
|
198
172
|
{
|
|
199
173
|
"cell_type": "code",
|
|
200
174
|
"execution_count": null,
|
|
201
|
-
"id": "
|
|
175
|
+
"id": "f1923e4d",
|
|
202
176
|
"metadata": {},
|
|
203
177
|
"outputs": [],
|
|
204
178
|
"source": [
|
|
205
|
-
"
|
|
179
|
+
"assert ln_setup.settings.cache_dir == old_cache_dir"
|
|
206
180
|
]
|
|
207
181
|
},
|
|
208
182
|
{
|
|
@@ -212,7 +186,7 @@
|
|
|
212
186
|
"metadata": {},
|
|
213
187
|
"outputs": [],
|
|
214
188
|
"source": [
|
|
215
|
-
"
|
|
189
|
+
"set_cache_dir(None)"
|
|
216
190
|
]
|
|
217
191
|
},
|
|
218
192
|
{
|
|
@@ -222,7 +196,7 @@
|
|
|
222
196
|
"metadata": {},
|
|
223
197
|
"outputs": [],
|
|
224
198
|
"source": [
|
|
225
|
-
"
|
|
199
|
+
"assert ln_setup.settings.cache_dir == old_cache_dir"
|
|
226
200
|
]
|
|
227
201
|
},
|
|
228
202
|
{
|
|
@@ -248,7 +222,8 @@
|
|
|
248
222
|
"metadata": {},
|
|
249
223
|
"outputs": [],
|
|
250
224
|
"source": [
|
|
251
|
-
"
|
|
225
|
+
"exit_status = os.system(\"lamin cache get\")\n",
|
|
226
|
+
"assert exit_status == 0"
|
|
252
227
|
]
|
|
253
228
|
},
|
|
254
229
|
{
|
|
@@ -258,7 +233,8 @@
|
|
|
258
233
|
"metadata": {},
|
|
259
234
|
"outputs": [],
|
|
260
235
|
"source": [
|
|
261
|
-
"
|
|
236
|
+
"exit_status = os.system(\"lamin cache set 'null'\")\n",
|
|
237
|
+
"assert exit_status == 0"
|
|
262
238
|
]
|
|
263
239
|
},
|
|
264
240
|
{
|
|
@@ -297,7 +273,7 @@
|
|
|
297
273
|
"name": "python",
|
|
298
274
|
"nbconvert_exporter": "python",
|
|
299
275
|
"pygments_lexer": "ipython3",
|
|
300
|
-
"version": "3.
|
|
276
|
+
"version": "3.9.17"
|
|
301
277
|
}
|
|
302
278
|
},
|
|
303
279
|
"nbformat": 4,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"import os\n",
|
|
19
19
|
"\n",
|
|
20
20
|
"instance_name = f\"test-sqlite-sync\"\n",
|
|
21
|
-
"!lamin
|
|
21
|
+
"!lamin connect {instance_name}\n",
|
|
22
22
|
"!yes | lamin delete {instance_name}"
|
|
23
23
|
]
|
|
24
24
|
},
|
|
@@ -130,8 +130,8 @@
|
|
|
130
130
|
"metadata": {},
|
|
131
131
|
"outputs": [],
|
|
132
132
|
"source": [
|
|
133
|
-
"assert settings.storage.cloud_to_local_no_update(dir_sync) == settings.
|
|
134
|
-
"assert settings.storage.cloud_to_local_no_update(dir_sync, cache_key=\"dir_cache/key\") == settings.
|
|
133
|
+
"assert settings.storage.cloud_to_local_no_update(dir_sync) == settings.cache_dir / f\"lamindb-ci/{instance_name}/dir_sync\"\n",
|
|
134
|
+
"assert settings.storage.cloud_to_local_no_update(dir_sync, cache_key=\"dir_cache/key\") == settings.cache_dir / \"dir_cache/key\""
|
|
135
135
|
]
|
|
136
136
|
},
|
|
137
137
|
{
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"metadata": {},
|
|
160
160
|
"outputs": [],
|
|
161
161
|
"source": [
|
|
162
|
-
"assert dir_sync_local == settings.
|
|
162
|
+
"assert dir_sync_local == settings.cache_dir / \"dir_cache/key\"\n",
|
|
163
163
|
"assert dir_sync_local.is_dir()\n",
|
|
164
164
|
"assert num_files(dir_sync_local) == 2"
|
|
165
165
|
]
|
|
@@ -312,8 +312,8 @@
|
|
|
312
312
|
"source": [
|
|
313
313
|
"time.sleep(1)\n",
|
|
314
314
|
"cloud_file = dir_sync / \"file1\"\n",
|
|
315
|
-
"# update cloud timestamp
|
|
316
|
-
"cloud_file.touch(
|
|
315
|
+
"# update cloud timestamp\n",
|
|
316
|
+
"cloud_file.fs.touch(cloud_file.as_posix(), truncate=True) \n",
|
|
317
317
|
"\n",
|
|
318
318
|
"assert cloud_file.modified.timestamp() > local_file_new.stat().st_mtime"
|
|
319
319
|
]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
|
|
5
|
+
from lamin_utils import logger
|
|
6
|
+
|
|
7
|
+
from .core._settings_save import save_system_storage_settings
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def clear_cache_dir():
|
|
11
|
+
from lamindb_setup import close, settings
|
|
12
|
+
|
|
13
|
+
if settings.instance._is_cloud_sqlite:
|
|
14
|
+
logger.warning(
|
|
15
|
+
"Closing the current instance to update the cloud sqlite database."
|
|
16
|
+
)
|
|
17
|
+
close()
|
|
18
|
+
|
|
19
|
+
cache_dir = settings.cache_dir
|
|
20
|
+
shutil.rmtree(cache_dir)
|
|
21
|
+
cache_dir.mkdir()
|
|
22
|
+
logger.success("The cache directory was cleared.")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_cache_dir():
|
|
26
|
+
from lamindb_setup import settings
|
|
27
|
+
|
|
28
|
+
return settings.cache_dir.as_posix()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def set_cache_dir(cache_dir: str):
|
|
32
|
+
from lamindb_setup.core._settings import (
|
|
33
|
+
DEFAULT_CACHE_DIR,
|
|
34
|
+
_process_cache_path,
|
|
35
|
+
settings,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
old_cache_dir = settings.cache_dir
|
|
39
|
+
new_cache_dir = _process_cache_path(cache_dir)
|
|
40
|
+
if new_cache_dir is None:
|
|
41
|
+
new_cache_dir = DEFAULT_CACHE_DIR
|
|
42
|
+
if new_cache_dir != old_cache_dir:
|
|
43
|
+
shutil.copytree(old_cache_dir, new_cache_dir, dirs_exist_ok=True)
|
|
44
|
+
shutil.rmtree(old_cache_dir)
|
|
45
|
+
logger.info("The current cache directory was moved to the specified location")
|
|
46
|
+
new_cache_dir = new_cache_dir.resolve()
|
|
47
|
+
save_system_storage_settings(new_cache_dir)
|
|
48
|
+
settings._cache_dir = new_cache_dir
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import importlib as il
|
|
4
4
|
import os
|
|
5
|
-
from typing import TYPE_CHECKING
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
7
|
from lamin_utils import logger
|
|
8
8
|
|
|
@@ -42,9 +42,9 @@ def _get_current_instance_settings() -> InstanceSettings | None:
|
|
|
42
42
|
except Exception as e:
|
|
43
43
|
# user will get more detailed traceback once they run the CLI
|
|
44
44
|
logger.error(
|
|
45
|
-
"Current instance cannot be reached,
|
|
45
|
+
"Current instance cannot be reached, disconnect from it: `lamin disconnect`\n"
|
|
46
46
|
"Alternatively, init or load a connectable instance on the"
|
|
47
|
-
" command line: `lamin
|
|
47
|
+
" command line: `lamin connect <instance>` or `lamin init <...>`"
|
|
48
48
|
)
|
|
49
49
|
raise e
|
|
50
50
|
return isettings
|
|
@@ -9,9 +9,13 @@ 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
|
-
from .core._hub_core import
|
|
18
|
+
from .core._hub_core import connect_instance_hub
|
|
15
19
|
from .core._hub_utils import (
|
|
16
20
|
LaminDsn,
|
|
17
21
|
LaminDsnModel,
|
|
@@ -128,7 +132,7 @@ def _connect_instance(
|
|
|
128
132
|
# on the hub
|
|
129
133
|
# do not call hub if the user is anonymous
|
|
130
134
|
if owner != "anonymous":
|
|
131
|
-
hub_result =
|
|
135
|
+
hub_result = connect_instance_hub(
|
|
132
136
|
owner=owner, name=name, access_token=access_token
|
|
133
137
|
)
|
|
134
138
|
else:
|
|
@@ -160,6 +164,10 @@ def _connect_instance(
|
|
|
160
164
|
git_repo=instance_result["git_repo"],
|
|
161
165
|
keep_artifacts_local=bool(instance_result["keep_artifacts_local"]),
|
|
162
166
|
is_on_hub=True,
|
|
167
|
+
api_url=instance_result["api_url"],
|
|
168
|
+
schema_id=None
|
|
169
|
+
if (schema_id := instance_result["schema_id"]) is None
|
|
170
|
+
else UUID(schema_id),
|
|
163
171
|
)
|
|
164
172
|
else:
|
|
165
173
|
if hub_result != "anonymous-user":
|
|
@@ -220,7 +228,9 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
|
|
|
220
228
|
logger.info(f"connected lamindb: {settings.instance.slug}")
|
|
221
229
|
return None
|
|
222
230
|
else:
|
|
223
|
-
raise
|
|
231
|
+
raise CannotSwitchDefaultInstance(
|
|
232
|
+
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE
|
|
233
|
+
)
|
|
224
234
|
elif (
|
|
225
235
|
_write_settings
|
|
226
236
|
and settings._instance_exists
|
|
@@ -256,7 +266,7 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
|
|
|
256
266
|
logger.warning(
|
|
257
267
|
"SQLite file does not exist in the cloud, but exists locally:"
|
|
258
268
|
f" {isettings._sqlite_file_local}\nTo push the file to the cloud,"
|
|
259
|
-
" call: lamin
|
|
269
|
+
" call: lamin disconnect"
|
|
260
270
|
)
|
|
261
271
|
elif _raise_not_found_error:
|
|
262
272
|
raise SystemExit(msg)
|
|
@@ -24,7 +24,7 @@ def delete_cache(isettings: InstanceSettings):
|
|
|
24
24
|
# avoid init of root
|
|
25
25
|
root = isettings.storage._root_init
|
|
26
26
|
if not isinstance(root, LocalPathClasses):
|
|
27
|
-
cache_dir =
|
|
27
|
+
cache_dir = settings.cache_dir / root.path
|
|
28
28
|
if cache_dir.exists():
|
|
29
29
|
shutil.rmtree(cache_dir)
|
|
30
30
|
|
|
@@ -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
|
|
@@ -309,7 +321,7 @@ def init(
|
|
|
309
321
|
isettings._cloud_sqlite_locker.lock()
|
|
310
322
|
logger.warning(
|
|
311
323
|
"locked instance (to unlock and push changes to the cloud SQLite file,"
|
|
312
|
-
" call: lamin
|
|
324
|
+
" call: lamin disconnect)"
|
|
313
325
|
)
|
|
314
326
|
if register_on_hub and isettings.dialect != "sqlite":
|
|
315
327
|
from ._schema_metadata import update_schema_in_hub
|
|
@@ -325,69 +325,7 @@ def _init_instance(
|
|
|
325
325
|
logger.important(f"go to: https://lamin.ai/{isettings.owner}/{isettings.name}")
|
|
326
326
|
|
|
327
327
|
|
|
328
|
-
def
|
|
329
|
-
*,
|
|
330
|
-
owner: str, # account_handle
|
|
331
|
-
name: str, # instance_name
|
|
332
|
-
access_token: str | None = None,
|
|
333
|
-
) -> tuple[dict, dict] | str:
|
|
334
|
-
from ._settings import settings
|
|
335
|
-
|
|
336
|
-
if settings.user.handle != "anonymous" or access_token is not None:
|
|
337
|
-
return call_with_fallback_auth(
|
|
338
|
-
_connect_instance, owner=owner, name=name, access_token=access_token
|
|
339
|
-
)
|
|
340
|
-
else:
|
|
341
|
-
return call_with_fallback(_connect_instance, owner=owner, name=name)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
def _connect_instance(
|
|
345
|
-
*,
|
|
346
|
-
owner: str, # account_handle
|
|
347
|
-
name: str, # instance_name
|
|
348
|
-
client: Client,
|
|
349
|
-
) -> tuple[dict, dict] | str:
|
|
350
|
-
instance_account_storage = select_instance_by_owner_name(owner, name, client)
|
|
351
|
-
if instance_account_storage is None:
|
|
352
|
-
# try the via single requests, will take more time
|
|
353
|
-
account = select_account_by_handle(owner, client)
|
|
354
|
-
if account is None:
|
|
355
|
-
return "account-not-exists"
|
|
356
|
-
instance = select_instance_by_name(account["id"], name, client)
|
|
357
|
-
if instance is None:
|
|
358
|
-
return "instance-not-found"
|
|
359
|
-
# get default storage
|
|
360
|
-
storage = select_default_storage_by_instance_id(instance["id"], client)
|
|
361
|
-
if storage is None:
|
|
362
|
-
return "default-storage-does-not-exist-on-hub"
|
|
363
|
-
else:
|
|
364
|
-
account = instance_account_storage.pop("account")
|
|
365
|
-
storage = instance_account_storage.pop("storage")
|
|
366
|
-
instance = instance_account_storage
|
|
367
|
-
# check if is postgres instance
|
|
368
|
-
# this used to be a check for `instance["db"] is not None` in earlier versions
|
|
369
|
-
# removed this on 2022-10-25 and can remove from the hub probably for lamindb 1.0
|
|
370
|
-
if instance["db_scheme"] is not None:
|
|
371
|
-
db_user = select_db_user_by_instance(instance["id"], client)
|
|
372
|
-
if db_user is None:
|
|
373
|
-
name, password = "none", "none"
|
|
374
|
-
else:
|
|
375
|
-
name, password = db_user["db_user_name"], db_user["db_user_password"]
|
|
376
|
-
# construct dsn from instance and db_account fields
|
|
377
|
-
db_dsn = LaminDsn.build(
|
|
378
|
-
scheme=instance["db_scheme"],
|
|
379
|
-
user=name,
|
|
380
|
-
password=password,
|
|
381
|
-
host=instance["db_host"],
|
|
382
|
-
port=instance["db_port"],
|
|
383
|
-
database=instance["db_database"],
|
|
384
|
-
)
|
|
385
|
-
instance["db"] = db_dsn
|
|
386
|
-
check_whether_migrations_in_sync(instance["lamindb_version"])
|
|
387
|
-
return instance, storage # type: ignore
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
def _connect_instance_new(
|
|
328
|
+
def _connect_instance_hub(
|
|
391
329
|
owner: str, # account_handle
|
|
392
330
|
name: str, # instance_name
|
|
393
331
|
client: Client,
|
|
@@ -439,10 +377,11 @@ def _connect_instance_new(
|
|
|
439
377
|
database=instance["db_database"],
|
|
440
378
|
)
|
|
441
379
|
instance["db"] = db_dsn
|
|
380
|
+
check_whether_migrations_in_sync(instance["lamindb_version"])
|
|
442
381
|
return instance, storage # type: ignore
|
|
443
382
|
|
|
444
383
|
|
|
445
|
-
def
|
|
384
|
+
def connect_instance_hub(
|
|
446
385
|
*,
|
|
447
386
|
owner: str, # account_handle
|
|
448
387
|
name: str, # instance_name
|
|
@@ -452,10 +391,10 @@ def connect_instance_new(
|
|
|
452
391
|
|
|
453
392
|
if settings.user.handle != "anonymous" or access_token is not None:
|
|
454
393
|
return call_with_fallback_auth(
|
|
455
|
-
|
|
394
|
+
_connect_instance_hub, owner=owner, name=name, access_token=access_token
|
|
456
395
|
)
|
|
457
396
|
else:
|
|
458
|
-
return call_with_fallback(
|
|
397
|
+
return call_with_fallback(_connect_instance_hub, owner=owner, name=name)
|
|
459
398
|
|
|
460
399
|
|
|
461
400
|
def access_aws(storage_root: str, access_token: str | None = None) -> dict[str, dict]:
|