lamindb_setup 0.77.5__tar.gz → 0.78.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.5 → lamindb_setup-0.78.0}/PKG-INFO +5 -3
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/02-connect-local-instance.ipynb +2 -2
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/03-add-managed-storage.ipynb +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-cache-management.ipynb +23 -47
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-cloud-sync.ipynb +6 -6
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-init-load-local-anonymously.ipynb +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-insufficient-user-info.ipynb +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/__init__.py +1 -2
- lamindb_setup-0.78.0/lamindb_setup/_cache.py +48 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_check_setup.py +23 -10
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_connect_instance.py +11 -13
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_delete.py +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_django.py +0 -2
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_init_instance.py +6 -12
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_migrate.py +3 -3
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_setup_user.py +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_hub_client.py +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_hub_core.py +12 -69
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_hub_utils.py +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings.py +48 -2
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_instance.py +6 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_load.py +14 -2
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_save.py +20 -9
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_storage.py +5 -67
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_user.py +3 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/cloud_sqlite_locker.py +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/django.py +1 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/exceptions.py +0 -2
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/hashing.py +3 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/types.py +1 -3
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/noxfile.py +1 -1
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/pyproject.toml +4 -2
- lamindb_setup-0.78.0/tests/hub-cloud/test_edge_request.py +63 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/test_init_instance.py +2 -2
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-local/test_all.py +34 -58
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-prod/test_switch_and_fallback_env.py +2 -2
- lamindb_setup-0.77.5/lamindb_setup/_cache.py +0 -34
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/.github/workflows/build.yml +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/.github/workflows/doc-changes.yml +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/.gitignore +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/.pre-commit-config.yaml +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/LICENSE +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/README.md +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/changelog.md +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/08-test-multi-session.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-cloud/test_notebooks.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-empty-init.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-import-schema.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/hub-prod/test_notebooks2.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/index.md +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/notebooks.md +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/docs/reference.md +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_check.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_close.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_entry_points.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_exportdb.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_importdb.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_register_instance.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_schema.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_schema_metadata.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_set_managed_storage.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/_silence_loggers.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/__init__.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_aws_credentials.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_aws_storage.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_deprecated.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_docs.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_hub_crud.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_private_django_api.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_store.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/lamindb_setup/core/upath.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/test_connect_instance.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/test_delete_instance.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/test_login.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/test_migrate.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-cloud/test_set_storage.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-local/conftest.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-local/test_update_schema_in_hub.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-prod/conftest.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-prod/test_django.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-prod/test_global_settings.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/hub-prod/test_upath.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/storage/test_entry_point.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/storage/test_hashing.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/storage/test_storage_access.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/storage/test_storage_basis.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.0}/tests/storage/test_storage_stats.py +0 -0
- {lamindb_setup-0.77.5 → lamindb_setup-0.78.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.78.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,14 +12,15 @@ 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
|
-
Requires-Dist: gotrue>=2.1.0
|
|
17
|
+
Requires-Dist: gotrue>=2.1.0,<2.9.0
|
|
17
18
|
Requires-Dist: supabase==2.2.1
|
|
18
19
|
Requires-Dist: psutil
|
|
19
20
|
Requires-Dist: urllib3<2 ; extra == "aws"
|
|
20
21
|
Requires-Dist: aiobotocore[boto3]>=2.5.4,<3.0.0 ; extra == "aws"
|
|
21
22
|
Requires-Dist: s3fs>=2023.12.2,<=2024.6.1 ; extra == "aws"
|
|
23
|
+
Requires-Dist: line_profiler ; extra == "dev"
|
|
22
24
|
Requires-Dist: pyjwt<3.0.0 ; extra == "dev"
|
|
23
25
|
Requires-Dist: psycopg2-binary ; extra == "dev"
|
|
24
26
|
Requires-Dist: python-dotenv ; extra == "dev"
|
|
@@ -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
|
]
|
|
@@ -21,7 +21,6 @@ Instance operations:
|
|
|
21
21
|
:toctree:
|
|
22
22
|
|
|
23
23
|
migrate
|
|
24
|
-
register
|
|
25
24
|
|
|
26
25
|
Modules & settings:
|
|
27
26
|
|
|
@@ -34,7 +33,7 @@ Modules & settings:
|
|
|
34
33
|
|
|
35
34
|
"""
|
|
36
35
|
|
|
37
|
-
__version__ = "0.
|
|
36
|
+
__version__ = "0.78.0" # denote a release candidate for 0.1.0 with 0.1rc1
|
|
38
37
|
|
|
39
38
|
import os as _os
|
|
40
39
|
import sys as _sys
|
|
@@ -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
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import importlib as il
|
|
3
4
|
import os
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
5
6
|
|
|
6
7
|
from lamin_utils import logger
|
|
7
8
|
|
|
@@ -41,9 +42,9 @@ def _get_current_instance_settings() -> InstanceSettings | None:
|
|
|
41
42
|
except Exception as e:
|
|
42
43
|
# user will get more detailed traceback once they run the CLI
|
|
43
44
|
logger.error(
|
|
44
|
-
"Current instance cannot be reached,
|
|
45
|
+
"Current instance cannot be reached, disconnect from it: `lamin disconnect`\n"
|
|
45
46
|
"Alternatively, init or load a connectable instance on the"
|
|
46
|
-
" command line: `lamin
|
|
47
|
+
" command line: `lamin connect <instance>` or `lamin init <...>`"
|
|
47
48
|
)
|
|
48
49
|
raise e
|
|
49
50
|
return isettings
|
|
@@ -52,9 +53,18 @@ def _get_current_instance_settings() -> InstanceSettings | None:
|
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
# we make this a private function because in all the places it's used,
|
|
55
|
-
# users should see it
|
|
56
|
-
def _check_instance_setup(
|
|
56
|
+
# users should not see it
|
|
57
|
+
def _check_instance_setup(
|
|
58
|
+
from_lamindb: bool = False, from_module: str | None = None
|
|
59
|
+
) -> bool:
|
|
60
|
+
reload_module = from_lamindb or from_module is not None
|
|
61
|
+
from ._init_instance import get_schema_module_name, reload_schema_modules
|
|
62
|
+
|
|
57
63
|
if django.IS_SETUP:
|
|
64
|
+
# reload logic here because module might not yet have been imported
|
|
65
|
+
# upon first setup
|
|
66
|
+
if from_module is not None:
|
|
67
|
+
il.reload(il.import_module(from_module))
|
|
58
68
|
return True
|
|
59
69
|
silence_loggers()
|
|
60
70
|
if os.environ.get("LAMINDB_MULTI_INSTANCE") == "true":
|
|
@@ -65,15 +75,18 @@ def _check_instance_setup(from_lamindb: bool = False) -> bool:
|
|
|
65
75
|
return True
|
|
66
76
|
isettings = _get_current_instance_settings()
|
|
67
77
|
if isettings is not None:
|
|
68
|
-
if
|
|
78
|
+
if reload_module and settings.auto_connect:
|
|
69
79
|
if not django.IS_SETUP:
|
|
70
|
-
from ._init_instance import reload_schema_modules
|
|
71
|
-
|
|
72
80
|
django.setup_django(isettings)
|
|
73
|
-
|
|
81
|
+
if from_module is not None:
|
|
82
|
+
# this only reloads `from_module`
|
|
83
|
+
il.reload(il.import_module(from_module))
|
|
84
|
+
else:
|
|
85
|
+
# this bulk reloads all schema modules
|
|
86
|
+
reload_schema_modules(isettings)
|
|
74
87
|
logger.important(f"connected lamindb: {isettings.slug}")
|
|
75
88
|
return django.IS_SETUP
|
|
76
89
|
else:
|
|
77
|
-
if
|
|
90
|
+
if reload_module and settings.auto_connect:
|
|
78
91
|
logger.warning(InstanceNotSetupError.default_message)
|
|
79
92
|
return False
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
+
import sys
|
|
4
5
|
from typing import TYPE_CHECKING
|
|
5
6
|
from uuid import UUID
|
|
6
7
|
|
|
@@ -9,10 +10,8 @@ from lamin_utils import logger
|
|
|
9
10
|
from ._check_setup import _check_instance_setup
|
|
10
11
|
from ._close import close as close_instance
|
|
11
12
|
from ._init_instance import MESSAGE_NO_MULTIPLE_INSTANCE, load_from_isettings
|
|
12
|
-
from ._migrate import check_whether_migrations_in_sync
|
|
13
13
|
from ._silence_loggers import silence_loggers
|
|
14
|
-
from .core._hub_core import
|
|
15
|
-
from .core._hub_core import connect_instance_new as load_instance_from_hub_edge
|
|
14
|
+
from .core._hub_core import connect_instance_hub
|
|
16
15
|
from .core._hub_utils import (
|
|
17
16
|
LaminDsn,
|
|
18
17
|
LaminDsnModel,
|
|
@@ -129,14 +128,9 @@ def _connect_instance(
|
|
|
129
128
|
# on the hub
|
|
130
129
|
# do not call hub if the user is anonymous
|
|
131
130
|
if owner != "anonymous":
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
)
|
|
136
|
-
else:
|
|
137
|
-
hub_result = load_instance_from_hub(
|
|
138
|
-
owner=owner, name=name, access_token=access_token
|
|
139
|
-
)
|
|
131
|
+
hub_result = connect_instance_hub(
|
|
132
|
+
owner=owner, name=name, access_token=access_token
|
|
133
|
+
)
|
|
140
134
|
else:
|
|
141
135
|
hub_result = "anonymous-user"
|
|
142
136
|
# if hub_result is not a string, it means it made a request
|
|
@@ -166,8 +160,11 @@ def _connect_instance(
|
|
|
166
160
|
git_repo=instance_result["git_repo"],
|
|
167
161
|
keep_artifacts_local=bool(instance_result["keep_artifacts_local"]),
|
|
168
162
|
is_on_hub=True,
|
|
163
|
+
api_url=instance_result["api_url"],
|
|
164
|
+
schema_id=None
|
|
165
|
+
if (schema_id := instance_result["schema_id"]) is None
|
|
166
|
+
else UUID(schema_id),
|
|
169
167
|
)
|
|
170
|
-
check_whether_migrations_in_sync(instance_result["lamindb_version"])
|
|
171
168
|
else:
|
|
172
169
|
if hub_result != "anonymous-user":
|
|
173
170
|
message = INSTANCE_NOT_FOUND_MESSAGE.format(
|
|
@@ -263,7 +260,7 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
|
|
|
263
260
|
logger.warning(
|
|
264
261
|
"SQLite file does not exist in the cloud, but exists locally:"
|
|
265
262
|
f" {isettings._sqlite_file_local}\nTo push the file to the cloud,"
|
|
266
|
-
" call: lamin
|
|
263
|
+
" call: lamin disconnect"
|
|
267
264
|
)
|
|
268
265
|
elif _raise_not_found_error:
|
|
269
266
|
raise SystemExit(msg)
|
|
@@ -313,6 +310,7 @@ def load(slug: str) -> str | tuple | None:
|
|
|
313
310
|
This is exactly the same as ``ln.connect()`` except for that
|
|
314
311
|
``ln.connect()`` doesn't change the state of ``auto-connect``.
|
|
315
312
|
"""
|
|
313
|
+
print("Warning: This is deprecated and will be removed.")
|
|
316
314
|
result = connect(slug)
|
|
317
315
|
settings.auto_connect = True
|
|
318
316
|
return result
|
|
@@ -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
|
|
|
@@ -97,8 +97,9 @@ def register_user_and_storage_in_instance(isettings: InstanceSettings, usettings
|
|
|
97
97
|
logger.warning(f"instance seems not set up ({error})")
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
def reload_schema_modules(isettings: InstanceSettings):
|
|
101
|
-
schema_names = ["core"]
|
|
100
|
+
def reload_schema_modules(isettings: InstanceSettings, include_core: bool = True):
|
|
101
|
+
schema_names = ["core"] if include_core else []
|
|
102
|
+
# schema_names += list(isettings.schema)
|
|
102
103
|
schema_module_names = [get_schema_module_name(n) for n in schema_names]
|
|
103
104
|
|
|
104
105
|
for schema_module_name in schema_module_names:
|
|
@@ -114,16 +115,10 @@ def reload_lamindb_itself(isettings) -> bool:
|
|
|
114
115
|
|
|
115
116
|
importlib.reload(lamindb)
|
|
116
117
|
reloaded = True
|
|
117
|
-
if "bionty" in isettings.schema and "bionty" in sys.modules:
|
|
118
|
-
schema_module = importlib.import_module("bionty")
|
|
119
|
-
importlib.reload(schema_module)
|
|
120
|
-
reloaded = True
|
|
121
118
|
return reloaded
|
|
122
119
|
|
|
123
120
|
|
|
124
121
|
def reload_lamindb(isettings: InstanceSettings):
|
|
125
|
-
# only touch lamindb if we're operating from lamindb
|
|
126
|
-
reload_schema_modules(isettings)
|
|
127
122
|
log_message = settings.auto_connect
|
|
128
123
|
if not reload_lamindb_itself(isettings):
|
|
129
124
|
log_message = True
|
|
@@ -214,7 +209,7 @@ def validate_init_args(
|
|
|
214
209
|
MESSAGE_NO_MULTIPLE_INSTANCE = """
|
|
215
210
|
Currently don't support subsequent connection to different databases in the same
|
|
216
211
|
Python session.\n
|
|
217
|
-
Try running on the CLI: lamin set auto-connect false
|
|
212
|
+
Try running on the CLI: lamin settings set auto-connect false
|
|
218
213
|
"""
|
|
219
214
|
|
|
220
215
|
|
|
@@ -314,7 +309,7 @@ def init(
|
|
|
314
309
|
isettings._cloud_sqlite_locker.lock()
|
|
315
310
|
logger.warning(
|
|
316
311
|
"locked instance (to unlock and push changes to the cloud SQLite file,"
|
|
317
|
-
" call: lamin
|
|
312
|
+
" call: lamin disconnect)"
|
|
318
313
|
)
|
|
319
314
|
if register_on_hub and isettings.dialect != "sqlite":
|
|
320
315
|
from ._schema_metadata import update_schema_in_hub
|
|
@@ -352,7 +347,7 @@ def load_from_isettings(
|
|
|
352
347
|
user: UserSettings | None = None,
|
|
353
348
|
write_settings: bool = True,
|
|
354
349
|
) -> None:
|
|
355
|
-
from .core._setup_bionty_sources import
|
|
350
|
+
from .core._setup_bionty_sources import write_bionty_sources
|
|
356
351
|
|
|
357
352
|
user = settings.user if user is None else user
|
|
358
353
|
|
|
@@ -370,7 +365,6 @@ def load_from_isettings(
|
|
|
370
365
|
# yet be registered
|
|
371
366
|
if not isettings._get_settings_file().exists():
|
|
372
367
|
register_user(user)
|
|
373
|
-
load_bionty_sources(isettings)
|
|
374
368
|
isettings._persist(write_to_disk=write_settings)
|
|
375
369
|
reload_lamindb(isettings)
|
|
376
370
|
|
|
@@ -30,7 +30,7 @@ def check_whether_migrations_in_sync(db_version_str: str):
|
|
|
30
30
|
db_version_lower = f"{db_version.major}.{db_version.minor}"
|
|
31
31
|
db_version_upper = f"{db_version.major}.{db_version.minor + 1}"
|
|
32
32
|
logger.warning(
|
|
33
|
-
f"
|
|
33
|
+
f"the database ({db_version_str}) is ahead of your installed lamindb"
|
|
34
34
|
f" package ({installed_version_str})"
|
|
35
35
|
)
|
|
36
36
|
logger.important(
|
|
@@ -42,10 +42,10 @@ def check_whether_migrations_in_sync(db_version_str: str):
|
|
|
42
42
|
or installed_version.minor > db_version.minor
|
|
43
43
|
):
|
|
44
44
|
logger.warning(
|
|
45
|
-
f"
|
|
45
|
+
f"the database ({db_version_str}) is behind your installed lamindb package"
|
|
46
46
|
f" ({installed_version_str})"
|
|
47
47
|
)
|
|
48
|
-
logger.important("
|
|
48
|
+
logger.important("consider migrating your database: lamin migrate deploy")
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
# for tests, see lamin-cli
|