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.
Files changed (101) hide show
  1. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/PKG-INFO +3 -2
  2. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/02-connect-local-instance.ipynb +2 -25
  3. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/03-add-managed-storage.ipynb +1 -1
  4. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/08-test-multi-session.ipynb +7 -3
  5. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-cache-management.ipynb +23 -47
  6. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-cloud-sync.ipynb +6 -6
  7. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-init-load-local-anonymously.ipynb +1 -1
  8. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-insufficient-user-info.ipynb +1 -1
  9. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/__init__.py +1 -1
  10. lamindb_setup-0.79.0/lamindb_setup/_cache.py +48 -0
  11. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_check_setup.py +3 -3
  12. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_connect_instance.py +15 -5
  13. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_delete.py +1 -1
  14. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_django.py +0 -2
  15. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_init_instance.py +22 -10
  16. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_setup_user.py +1 -1
  17. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_hub_core.py +5 -66
  18. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_hub_utils.py +1 -1
  19. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings.py +39 -0
  20. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_instance.py +6 -1
  21. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_load.py +14 -2
  22. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_save.py +20 -9
  23. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_storage.py +7 -69
  24. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_user.py +1 -1
  25. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/cloud_sqlite_locker.py +1 -1
  26. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/django.py +11 -1
  27. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/exceptions.py +0 -2
  28. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/hashing.py +3 -1
  29. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/types.py +1 -3
  30. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/noxfile.py +2 -2
  31. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/pyproject.toml +2 -1
  32. lamindb_setup-0.79.0/tests/hub-cloud/test_edge_request.py +63 -0
  33. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_init_instance.py +8 -2
  34. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-local/test_all.py +34 -58
  35. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/test_switch_and_fallback_env.py +2 -2
  36. lamindb_setup-0.77.6/lamindb_setup/_cache.py +0 -34
  37. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/.github/workflows/build.yml +0 -0
  38. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/.github/workflows/doc-changes.yml +0 -0
  39. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/.gitignore +0 -0
  40. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/.pre-commit-config.yaml +0 -0
  41. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/LICENSE +0 -0
  42. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/README.md +0 -0
  43. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/changelog.md +0 -0
  44. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
  45. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
  46. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
  47. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
  48. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
  49. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-cloud/test_notebooks.py +0 -0
  50. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
  51. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-empty-init.ipynb +0 -0
  52. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-import-schema.ipynb +0 -0
  53. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
  54. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
  55. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/hub-prod/test_notebooks2.py +0 -0
  56. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/index.md +0 -0
  57. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/notebooks.md +0 -0
  58. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/docs/reference.md +0 -0
  59. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_check.py +0 -0
  60. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_close.py +0 -0
  61. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_entry_points.py +0 -0
  62. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_exportdb.py +0 -0
  63. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_importdb.py +0 -0
  64. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_migrate.py +0 -0
  65. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_register_instance.py +0 -0
  66. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_schema.py +0 -0
  67. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_schema_metadata.py +0 -0
  68. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_set_managed_storage.py +0 -0
  69. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/_silence_loggers.py +0 -0
  70. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/__init__.py +0 -0
  71. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_aws_credentials.py +0 -0
  72. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_aws_storage.py +0 -0
  73. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_deprecated.py +0 -0
  74. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_docs.py +0 -0
  75. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_hub_client.py +0 -0
  76. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_hub_crud.py +0 -0
  77. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_private_django_api.py +0 -0
  78. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_settings_store.py +0 -0
  79. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
  80. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/lamindb_setup/core/upath.py +0 -0
  81. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
  82. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
  83. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_connect_instance.py +0 -0
  84. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_delete_instance.py +0 -0
  85. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
  86. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
  87. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_login.py +0 -0
  88. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_migrate.py +0 -0
  89. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-cloud/test_set_storage.py +0 -0
  90. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-local/conftest.py +0 -0
  91. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-local/test_update_schema_in_hub.py +0 -0
  92. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/conftest.py +0 -0
  93. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/test_django.py +0 -0
  94. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/test_global_settings.py +0 -0
  95. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/hub-prod/test_upath.py +0 -0
  96. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_entry_point.py +0 -0
  97. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_hashing.py +0 -0
  98. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_storage_access.py +0 -0
  99. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_storage_basis.py +0 -0
  100. {lamindb_setup-0.77.6 → lamindb_setup-0.79.0}/tests/storage/test_storage_stats.py +0 -0
  101. {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.77.6
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.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
  {
@@ -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",
@@ -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"
@@ -113,14 +113,18 @@
113
113
  "metadata": {},
114
114
  "outputs": [],
115
115
  "source": [
116
- "with pytest.raises(RuntimeError):\n",
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(RuntimeError):\n",
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
- "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.79.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
@@ -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 MESSAGE_NO_MULTIPLE_INSTANCE, load_from_isettings
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 connect_instance as connect_instance_from_hub
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 = connect_instance_from_hub(
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 RuntimeError(MESSAGE_NO_MULTIPLE_INSTANCE)
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 load --unload"
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 = 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
 
@@ -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
- raise ImportError(
38
- f"Python package for '{schema_name}' is not installed.\nIf your package is on PyPI, run `pip install {schema_name}`"
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
- MESSAGE_NO_MULTIPLE_INSTANCE = """
210
- Currently don't support subsequent connection to different databases in the same
211
- Python session.\n
212
- Try running on the CLI: lamin settings set auto-connect false
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 RuntimeError(MESSAGE_NO_MULTIPLE_INSTANCE)
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 load --unload)"
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
@@ -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