lamindb_setup 0.77.6__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.
Files changed (101) hide show
  1. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/PKG-INFO +3 -2
  2. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/02-connect-local-instance.ipynb +2 -2
  3. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/03-add-managed-storage.ipynb +1 -1
  4. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-cache-management.ipynb +23 -47
  5. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-cloud-sync.ipynb +6 -6
  6. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-init-load-local-anonymously.ipynb +1 -1
  7. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-insufficient-user-info.ipynb +1 -1
  8. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/__init__.py +1 -1
  9. lamindb_setup-0.78.0/lamindb_setup/_cache.py +48 -0
  10. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_check_setup.py +3 -3
  11. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_connect_instance.py +7 -3
  12. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_delete.py +1 -1
  13. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_django.py +0 -2
  14. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_init_instance.py +1 -1
  15. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_setup_user.py +1 -1
  16. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_hub_core.py +5 -66
  17. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_hub_utils.py +1 -1
  18. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings.py +39 -0
  19. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_instance.py +6 -1
  20. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_load.py +14 -2
  21. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_save.py +20 -9
  22. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_storage.py +5 -67
  23. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_user.py +1 -1
  24. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/cloud_sqlite_locker.py +1 -1
  25. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/exceptions.py +0 -2
  26. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/hashing.py +3 -1
  27. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/types.py +1 -3
  28. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/noxfile.py +2 -2
  29. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/pyproject.toml +2 -1
  30. lamindb_setup-0.78.0/tests/hub-cloud/test_edge_request.py +63 -0
  31. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/test_init_instance.py +2 -2
  32. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-local/test_all.py +34 -58
  33. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-prod/test_switch_and_fallback_env.py +2 -2
  34. lamindb_setup-0.77.6/lamindb_setup/_cache.py +0 -34
  35. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/.github/workflows/build.yml +0 -0
  36. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/.github/workflows/doc-changes.yml +0 -0
  37. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/.gitignore +0 -0
  38. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/.pre-commit-config.yaml +0 -0
  39. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/LICENSE +0 -0
  40. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/README.md +0 -0
  41. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/changelog.md +0 -0
  42. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
  43. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
  44. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
  45. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
  46. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
  47. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/08-test-multi-session.ipynb +0 -0
  48. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-cloud/test_notebooks.py +0 -0
  49. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
  50. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-empty-init.ipynb +0 -0
  51. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-import-schema.ipynb +0 -0
  52. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
  53. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
  54. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/hub-prod/test_notebooks2.py +0 -0
  55. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/index.md +0 -0
  56. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/notebooks.md +0 -0
  57. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/docs/reference.md +0 -0
  58. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_check.py +0 -0
  59. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_close.py +0 -0
  60. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_entry_points.py +0 -0
  61. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_exportdb.py +0 -0
  62. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_importdb.py +0 -0
  63. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_migrate.py +0 -0
  64. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_register_instance.py +0 -0
  65. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_schema.py +0 -0
  66. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_schema_metadata.py +0 -0
  67. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_set_managed_storage.py +0 -0
  68. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/_silence_loggers.py +0 -0
  69. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/__init__.py +0 -0
  70. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_aws_credentials.py +0 -0
  71. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_aws_storage.py +0 -0
  72. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_deprecated.py +0 -0
  73. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_docs.py +0 -0
  74. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_hub_client.py +0 -0
  75. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_hub_crud.py +0 -0
  76. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_private_django_api.py +0 -0
  77. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_settings_store.py +0 -0
  78. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
  79. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/django.py +0 -0
  80. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/lamindb_setup/core/upath.py +0 -0
  81. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
  82. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
  83. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/test_connect_instance.py +0 -0
  84. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/test_delete_instance.py +0 -0
  85. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
  86. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
  87. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/test_login.py +0 -0
  88. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/test_migrate.py +0 -0
  89. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-cloud/test_set_storage.py +0 -0
  90. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-local/conftest.py +0 -0
  91. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-local/test_update_schema_in_hub.py +0 -0
  92. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-prod/conftest.py +0 -0
  93. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-prod/test_django.py +0 -0
  94. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-prod/test_global_settings.py +0 -0
  95. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/hub-prod/test_upath.py +0 -0
  96. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/storage/test_entry_point.py +0 -0
  97. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/storage/test_hashing.py +0 -0
  98. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/storage/test_storage_access.py +0 -0
  99. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/storage/test_storage_basis.py +0 -0
  100. {lamindb_setup-0.77.6 → lamindb_setup-0.78.0}/tests/storage/test_storage_stats.py +0 -0
  101. {lamindb_setup-0.77.6 → 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.77.6
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,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.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
@@ -19,10 +19,10 @@
19
19
  },
20
20
  "outputs": [],
21
21
  "source": [
22
- "!lamin load --unload\n",
22
+ "!lamin disconnect\n",
23
23
  "!lamin delete --force mydata\n",
24
24
  "!lamin init --storage mydata\n",
25
- "!lamin load --unload"
25
+ "!lamin disconnect"
26
26
  ]
27
27
  },
28
28
  {
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "outputs": [],
23
23
  "source": [
24
- "!lamin load --unload\n",
24
+ "!lamin disconnect\n",
25
25
  "!lamin login testuser1\n",
26
26
  "!lamin delete --force test-add-managed-storage\n",
27
27
  "!docker stop pgtest && docker rm pgtest"
@@ -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
- "save_cache_dir = ln_setup.settings.storage.cache_dir\n",
71
- "set_cache_dir = save_cache_dir.parent / \"Cache1\""
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
- "ln_setup.settings.storage.cache_dir = set_cache_dir"
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": "df1a1396",
99
+ "id": "c1958c5b",
98
100
  "metadata": {},
99
101
  "outputs": [],
100
102
  "source": [
101
- "assert ln_setup.settings.storage.cache_dir != save_cache_dir"
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 set_cache_dir.exists()"
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 set_cache_dir in ln_setup.settings.instance._sqlite_file_local.parents"
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(set_cache_dir.iterdir())"
151
+ "assert not any(new_cache_dir.iterdir())"
160
152
  ]
161
153
  },
162
154
  {
163
155
  "cell_type": "markdown",
164
- "id": "14ffa755",
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
- "# ln_setup.connect(\"test-cache\") # this isn't possible"
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": "4f1c8dbe",
165
+ "id": "95aec7fd",
184
166
  "metadata": {},
185
167
  "outputs": [],
186
168
  "source": [
187
- "# assert ln_setup.settings.storage.cache_dir == set_cache_dir"
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": "95aec7fd",
175
+ "id": "f1923e4d",
202
176
  "metadata": {},
203
177
  "outputs": [],
204
178
  "source": [
205
- "# ln_setup.settings.storage.cache_dir = None"
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
- "# assert ln_setup.settings.storage.cache_dir == save_cache_dir"
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
- "# assert ln_setup.settings.storage.cache_dir != set_cache_dir"
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
- "!lamin cache"
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
- "!lamin cache set \"null\""
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.10.13"
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 load {instance_name}\n",
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.storage.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.storage.cache_dir / \"dir_cache/key\""
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.storage.cache_dir / \"dir_cache/key\"\n",
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, exist_ok=False needed due to truncate=not exist_ok in upath\n",
316
- "cloud_file.touch(exist_ok=False) \n",
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
  ]
@@ -63,7 +63,7 @@
63
63
  "metadata": {},
64
64
  "outputs": [],
65
65
  "source": [
66
- "!lamin load --unload\n",
66
+ "!lamin disconnect\n",
67
67
  "!lamin init --storage ./test-anonymous-init --schema bionty"
68
68
  ]
69
69
  },
@@ -13,7 +13,7 @@
13
13
  "metadata": {},
14
14
  "outputs": [],
15
15
  "source": [
16
- "!lamin load --unload"
16
+ "!lamin disconnect"
17
17
  ]
18
18
  },
19
19
  {
@@ -33,7 +33,7 @@ Modules & settings:
33
33
 
34
34
  """
35
35
 
36
- __version__ = "0.77.6" # denote a release candidate for 0.1.0 with 0.1rc1
36
+ __version__ = "0.78.0" # denote a release candidate for 0.1.0 with 0.1rc1
37
37
 
38
38
  import os as _os
39
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
@@ -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, Optional
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, unload it: `lamin load --unload`\n"
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 load <instance>` or `lamin init <...>`"
47
+ " command line: `lamin connect <instance>` or `lamin init <...>`"
48
48
  )
49
49
  raise e
50
50
  return isettings
@@ -11,7 +11,7 @@ from ._check_setup import _check_instance_setup
11
11
  from ._close import close as close_instance
12
12
  from ._init_instance import MESSAGE_NO_MULTIPLE_INSTANCE, load_from_isettings
13
13
  from ._silence_loggers import silence_loggers
14
- from .core._hub_core import connect_instance as connect_instance_from_hub
14
+ from .core._hub_core import connect_instance_hub
15
15
  from .core._hub_utils import (
16
16
  LaminDsn,
17
17
  LaminDsnModel,
@@ -128,7 +128,7 @@ def _connect_instance(
128
128
  # on the hub
129
129
  # do not call hub if the user is anonymous
130
130
  if owner != "anonymous":
131
- hub_result = connect_instance_from_hub(
131
+ hub_result = connect_instance_hub(
132
132
  owner=owner, name=name, access_token=access_token
133
133
  )
134
134
  else:
@@ -160,6 +160,10 @@ def _connect_instance(
160
160
  git_repo=instance_result["git_repo"],
161
161
  keep_artifacts_local=bool(instance_result["keep_artifacts_local"]),
162
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),
163
167
  )
164
168
  else:
165
169
  if hub_result != "anonymous-user":
@@ -256,7 +260,7 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
256
260
  logger.warning(
257
261
  "SQLite file does not exist in the cloud, but exists locally:"
258
262
  f" {isettings._sqlite_file_local}\nTo push the file to the cloud,"
259
- " call: lamin load --unload"
263
+ " call: lamin disconnect"
260
264
  )
261
265
  elif _raise_not_found_error:
262
266
  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 = isettings.storage.cache_dir / root
27
+ cache_dir = settings.cache_dir / root.path
28
28
  if cache_dir.exists():
29
29
  shutil.rmtree(cache_dir)
30
30
 
@@ -1,7 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Optional
4
-
5
3
  from .core._settings import settings
6
4
  from .core.django import setup_django
7
5
 
@@ -309,7 +309,7 @@ def init(
309
309
  isettings._cloud_sqlite_locker.lock()
310
310
  logger.warning(
311
311
  "locked instance (to unlock and push changes to the cloud SQLite file,"
312
- " call: lamin load --unload)"
312
+ " call: lamin disconnect)"
313
313
  )
314
314
  if register_on_hub and isettings.dialect != "sqlite":
315
315
  from ._schema_metadata import update_schema_in_hub
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
- from typing import TYPE_CHECKING, Optional, Union
4
+ from typing import TYPE_CHECKING
5
5
 
6
6
  from lamin_utils import logger
7
7
 
@@ -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 connect_instance(
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 connect_instance_new(
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
- _connect_instance_new, owner=owner, name=name, access_token=access_token
394
+ _connect_instance_hub, owner=owner, name=name, access_token=access_token
456
395
  )
457
396
  else:
458
- return call_with_fallback(_connect_instance_new, owner=owner, name=name)
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]:
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, ClassVar, Optional
3
+ from typing import Any, ClassVar
4
4
  from urllib.parse import urlparse, urlunparse
5
5
 
6
6
  from pydantic import BaseModel, Field, GetCoreSchemaHandler
@@ -3,17 +3,37 @@ from __future__ import annotations
3
3
  import os
4
4
  from typing import TYPE_CHECKING
5
5
 
6
+ from appdirs import AppDirs
7
+
6
8
  from ._settings_load import (
7
9
  load_instance_settings,
8
10
  load_or_create_user_settings,
11
+ load_system_storage_settings,
9
12
  )
10
13
  from ._settings_store import current_instance_settings_file, settings_dir
14
+ from .upath import LocalPathClasses, UPath
11
15
 
12
16
  if TYPE_CHECKING:
13
17
  from pathlib import Path
14
18
 
15
19
  from lamindb_setup.core import InstanceSettings, StorageSettings, UserSettings
16
20
 
21
+ from .types import UPathStr
22
+
23
+
24
+ DEFAULT_CACHE_DIR = UPath(AppDirs("lamindb", "laminlabs").user_cache_dir)
25
+
26
+
27
+ def _process_cache_path(cache_path: UPathStr | None):
28
+ if cache_path is None or cache_path == "null":
29
+ return None
30
+ cache_dir = UPath(cache_path)
31
+ if not isinstance(cache_dir, LocalPathClasses):
32
+ raise ValueError("cache dir should be a local path.")
33
+ if cache_dir.exists() and not cache_dir.is_dir():
34
+ raise ValueError("cache dir should be a directory.")
35
+ return cache_dir
36
+
17
37
 
18
38
  class SetupSettings:
19
39
  """Setup settings."""
@@ -29,6 +49,8 @@ class SetupSettings:
29
49
  _auto_connect_path: Path = settings_dir / "auto_connect"
30
50
  _private_django_api_path: Path = settings_dir / "private_django_api"
31
51
 
52
+ _cache_dir: Path | None = None
53
+
32
54
  @property
33
55
  def _instance_settings_path(self) -> Path:
34
56
  return current_instance_settings_file()
@@ -123,11 +145,28 @@ class SetupSettings:
123
145
  except SystemExit:
124
146
  return False
125
147
 
148
+ @property
149
+ def cache_dir(self) -> UPath:
150
+ """Cache root, a local directory to cache cloud files."""
151
+ if "LAMIN_CACHE_DIR" in os.environ:
152
+ cache_dir = UPath(os.environ["LAMIN_CACHE_DIR"])
153
+ elif self._cache_dir is None:
154
+ cache_path = load_system_storage_settings().get("lamindb_cache_path", None)
155
+ cache_dir = _process_cache_path(cache_path)
156
+ if cache_dir is None:
157
+ cache_dir = DEFAULT_CACHE_DIR
158
+ self._cache_dir = cache_dir
159
+ else:
160
+ cache_dir = self._cache_dir
161
+ cache_dir.mkdir(parents=True, exist_ok=True)
162
+ return cache_dir
163
+
126
164
  def __repr__(self) -> str:
127
165
  """Rich string representation."""
128
166
  repr = self.user.__repr__()
129
167
  repr += f"\nAuto-connect in Python: {self.auto_connect}\n"
130
168
  repr += f"Private Django API: {self.private_django_api}\n"
169
+ repr += f"Cache directory: {self.cache_dir}\n"
131
170
  if self._instance_exists:
132
171
  repr += self.instance.__repr__()
133
172
  else:
@@ -56,6 +56,8 @@ class InstanceSettings:
56
56
  schema: str | None = None, # comma-separated string of schema names
57
57
  git_repo: str | None = None, # a git repo URL
58
58
  is_on_hub: bool | None = None, # initialized from hub
59
+ api_url: str | None = None,
60
+ schema_id: UUID | None = None,
59
61
  _locker_user: UserSettings | None = None, # user to lock for if cloud sqlite
60
62
  ):
61
63
  from ._hub_utils import validate_db_arg
@@ -73,6 +75,9 @@ class InstanceSettings:
73
75
  self._keep_artifacts_local = keep_artifacts_local
74
76
  self._storage_local: StorageSettings | None = None
75
77
  self._is_on_hub = is_on_hub
78
+ # private, needed for writing instance settings
79
+ self._api_url = api_url
80
+ self._schema_id = schema_id
76
81
  # if None then settings.user is used
77
82
  self._locker_user = _locker_user
78
83
 
@@ -306,7 +311,7 @@ class InstanceSettings:
306
311
  if self._is_cloud_sqlite:
307
312
  logger.warning(
308
313
  "updating local SQLite & locking cloud SQLite (sync back & unlock:"
309
- " lamin load --unload)"
314
+ " lamin disconnect)"
310
315
  )
311
316
  if lock_cloud_sqlite:
312
317
  self._cloud_sqlite_locker.lock()