lamindb_setup 1.6.1__tar.gz → 1.7.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 (108) hide show
  1. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/PKG-INFO +2 -2
  2. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/01-init-local-instance.ipynb +20 -2
  3. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/02-connect-local-instance.ipynb +1 -3
  4. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/03-add-managed-storage.ipynb +55 -13
  5. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/05-init-hosted-instance.ipynb +4 -4
  6. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/06-connect-hosted-instance.ipynb +2 -2
  7. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/07-keep-artifacts-local.ipynb +6 -6
  8. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/08-test-multi-session.ipynb +12 -39
  9. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-cache-management.ipynb +140 -16
  10. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-init-load-local-anonymously.ipynb +1 -1
  11. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/__init__.py +5 -3
  12. lamindb_setup-1.7.0/lamindb_setup/_cache.py +87 -0
  13. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_check_setup.py +9 -22
  14. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_connect_instance.py +9 -157
  15. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_init_instance.py +39 -53
  16. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_register_instance.py +1 -1
  17. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_schema_metadata.py +4 -0
  18. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_set_managed_storage.py +6 -4
  19. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/__init__.py +1 -1
  20. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_aws_options.py +3 -3
  21. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_hub_client.py +2 -3
  22. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_hub_core.py +68 -35
  23. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_hub_crud.py +17 -3
  24. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_settings.py +28 -10
  25. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_settings_instance.py +8 -5
  26. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_settings_load.py +23 -14
  27. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_settings_save.py +5 -4
  28. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_settings_storage.py +105 -46
  29. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_settings_store.py +11 -2
  30. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/cloud_sqlite_locker.py +2 -6
  31. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/django.py +7 -2
  32. lamindb_setup-1.7.0/lamindb_setup/core/exceptions.py +1 -0
  33. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/hashing.py +1 -1
  34. lamindb_setup-1.7.0/lamindb_setup/core/types.py +1 -0
  35. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/upath.py +16 -10
  36. lamindb_setup-1.7.0/lamindb_setup/errors.py +70 -0
  37. {lamindb_setup-1.6.1/lamindb_setup/core → lamindb_setup-1.7.0/lamindb_setup}/types.py +6 -3
  38. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/noxfile.py +1 -1
  39. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/pyproject.toml +1 -1
  40. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_connect_instance.py +26 -1
  41. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_init_instance.py +0 -26
  42. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_init_pass_user_no_writes.py +19 -3
  43. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-local/scripts/script-connect-fine-grained-access.py +5 -4
  44. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-local/test_all.py +37 -12
  45. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-prod/conftest.py +1 -1
  46. lamindb_setup-1.6.1/lamindb_setup/_cache.py +0 -52
  47. lamindb_setup-1.6.1/lamindb_setup/core/exceptions.py +0 -10
  48. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/.github/workflows/build.yml +0 -0
  49. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/.github/workflows/doc-changes.yml +0 -0
  50. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/.gitignore +0 -0
  51. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/.pre-commit-config.yaml +0 -0
  52. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/LICENSE +0 -0
  53. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/README.md +0 -0
  54. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/changelog.md +0 -0
  55. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
  56. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-cloud/test_notebooks.py +0 -0
  57. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-cloud-sync.ipynb +0 -0
  58. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
  59. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-empty-init.ipynb +0 -0
  60. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-import-schema.ipynb +0 -0
  61. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-insufficient-user-info.ipynb +0 -0
  62. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
  63. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
  64. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/hub-prod/test_notebooks2.py +0 -0
  65. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/index.md +0 -0
  66. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/notebooks.md +0 -0
  67. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/docs/reference.md +0 -0
  68. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_check.py +0 -0
  69. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_delete.py +0 -0
  70. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_disconnect.py +0 -0
  71. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_django.py +0 -0
  72. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_entry_points.py +0 -0
  73. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_exportdb.py +0 -0
  74. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_importdb.py +0 -0
  75. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_migrate.py +0 -0
  76. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_schema.py +0 -0
  77. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_setup_user.py +0 -0
  78. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/_silence_loggers.py +0 -0
  79. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_aws_storage.py +0 -0
  80. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_deprecated.py +0 -0
  81. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_docs.py +0 -0
  82. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_hub_utils.py +0 -0
  83. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_private_django_api.py +0 -0
  84. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_settings_user.py +0 -0
  85. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
  86. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/lamindb_setup/py.typed +0 -0
  87. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
  88. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
  89. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_delete_instance.py +0 -0
  90. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_edge_request.py +0 -0
  91. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
  92. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_login.py +0 -0
  93. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_migrate.py +0 -0
  94. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-cloud/test_set_storage.py +0 -0
  95. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-local/conftest.py +0 -0
  96. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-local/test_update_schema_in_hub.py +0 -0
  97. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-prod/test_aws_options_manager.py +0 -0
  98. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-prod/test_django.py +0 -0
  99. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-prod/test_global_settings.py +0 -0
  100. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-prod/test_switch_and_fallback_env.py +0 -0
  101. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/hub-prod/test_upath.py +0 -0
  102. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/storage/test_entry_point.py +0 -0
  103. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/storage/test_hashing.py +0 -0
  104. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/storage/test_storage_access.py +0 -0
  105. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/storage/test_storage_basis.py +0 -0
  106. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/storage/test_storage_settings.py +0 -0
  107. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/storage/test_storage_stats.py +0 -0
  108. {lamindb_setup-1.6.1 → lamindb_setup-1.7.0}/tests/storage/test_to_url.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lamindb_setup
3
- Version: 1.6.1
3
+ Version: 1.7.0
4
4
  Summary: Setup & configure LaminDB.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Requires-Python: >=3.10
@@ -9,7 +9,7 @@ Requires-Dist: lamin_utils>=0.3.3
9
9
  Requires-Dist: django>=5.1,<5.2
10
10
  Requires-Dist: dj_database_url>=1.3.0,<3.0.0
11
11
  Requires-Dist: pydantic-settings
12
- Requires-Dist: appdirs<2.0.0
12
+ Requires-Dist: platformdirs<5.0.0
13
13
  Requires-Dist: requests
14
14
  Requires-Dist: universal_pathlib==0.2.6
15
15
  Requires-Dist: botocore<2.0.0
@@ -27,6 +27,15 @@
27
27
  "import lamindb_setup as ln_setup"
28
28
  ]
29
29
  },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": null,
33
+ "metadata": {},
34
+ "outputs": [],
35
+ "source": [
36
+ "assert not ln_setup.settings.is_connected"
37
+ ]
38
+ },
30
39
  {
31
40
  "cell_type": "code",
32
41
  "execution_count": null,
@@ -36,6 +45,15 @@
36
45
  "ln_setup.init(storage=\"./mydata\")"
37
46
  ]
38
47
  },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": null,
51
+ "metadata": {},
52
+ "outputs": [],
53
+ "source": [
54
+ "assert ln_setup.settings.is_connected"
55
+ ]
56
+ },
39
57
  {
40
58
  "cell_type": "code",
41
59
  "execution_count": null,
@@ -92,7 +110,7 @@
92
110
  ],
93
111
  "metadata": {
94
112
  "kernelspec": {
95
- "display_name": "lamindb",
113
+ "display_name": "Python 3 (ipykernel)",
96
114
  "language": "python",
97
115
  "name": "python3"
98
116
  },
@@ -106,7 +124,7 @@
106
124
  "name": "python",
107
125
  "nbconvert_exporter": "python",
108
126
  "pygments_lexer": "ipython3",
109
- "version": "3.12.8"
127
+ "version": "3.10.16"
110
128
  }
111
129
  },
112
130
  "nbformat": 4,
@@ -147,9 +147,7 @@
147
147
  "metadata": {},
148
148
  "outputs": [],
149
149
  "source": [
150
- "assert ln_setup.settings._instance_settings_path.exists()\n",
151
- "ln_setup.delete(\"mydata\", force=True)\n",
152
- "assert not ln_setup.settings._instance_settings_path.exists()"
150
+ "ln_setup.delete(\"mydata\", force=True)"
153
151
  ]
154
152
  }
155
153
  ],
@@ -7,7 +7,7 @@
7
7
  "tags": []
8
8
  },
9
9
  "source": [
10
- "# Add managed storage"
10
+ "# Add managed and referenced storage locations"
11
11
  ]
12
12
  },
13
13
  {
@@ -27,6 +27,24 @@
27
27
  "!docker stop pgtest && docker rm pgtest"
28
28
  ]
29
29
  },
30
+ {
31
+ "cell_type": "markdown",
32
+ "id": "6dcaa297",
33
+ "metadata": {},
34
+ "source": [
35
+ "Create a local instance that's not registered on the hub, so that we can test interplay."
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": null,
41
+ "id": "599eae6a",
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "!lamin init --storage \"./storage-of-another-instance\""
46
+ ]
47
+ },
30
48
  {
31
49
  "cell_type": "code",
32
50
  "execution_count": null,
@@ -65,6 +83,35 @@
65
83
  "ln_setup.init(storage=\"./storage1\", name=\"test-add-managed-storage\", db=pgurl)"
66
84
  ]
67
85
  },
86
+ {
87
+ "cell_type": "markdown",
88
+ "id": "b62e84cb",
89
+ "metadata": {},
90
+ "source": [
91
+ "Test adding referenced storage location."
92
+ ]
93
+ },
94
+ {
95
+ "cell_type": "code",
96
+ "execution_count": null,
97
+ "id": "dbf195e3",
98
+ "metadata": {},
99
+ "outputs": [],
100
+ "source": [
101
+ "import lamindb as ln\n",
102
+ "\n",
103
+ "storage = ln.Storage(root=\"./storage-of-another-instance\").save()\n",
104
+ "assert storage.instance_uid == \"__unknown__\""
105
+ ]
106
+ },
107
+ {
108
+ "cell_type": "markdown",
109
+ "id": "93234f70",
110
+ "metadata": {},
111
+ "source": [
112
+ "Now continue with managed storage locations."
113
+ ]
114
+ },
68
115
  {
69
116
  "cell_type": "code",
70
117
  "execution_count": null,
@@ -134,7 +181,7 @@
134
181
  "assert ln_setup.settings.storage.root_as_str == f\"{Path.cwd()}/storage2\"\n",
135
182
  "assert (\n",
136
183
  " ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
137
- ").read_text() == ln_setup.settings.storage.uid\n",
184
+ ").read_text().splitlines()[0] == ln_setup.settings.storage.uid\n",
138
185
  "assert ln_setup.settings.storage.is_on_hub"
139
186
  ]
140
187
  },
@@ -166,7 +213,7 @@
166
213
  "assert ln_setup.settings.storage.root_as_str == f\"{Path.cwd()}/storage1\"\n",
167
214
  "assert (\n",
168
215
  " ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
169
- ").read_text() == ln_setup.settings.storage.uid\n",
216
+ ").read_text().splitlines()[0] == ln_setup.settings.storage.uid\n",
170
217
  "assert ln_setup.settings.storage.is_on_hub\n",
171
218
  "assert ln_setup.settings.storage.uid == storage1_uid"
172
219
  ]
@@ -199,7 +246,7 @@
199
246
  "assert ln_setup.settings.storage.root_as_str == f\"{Path.cwd()}/storage1\"\n",
200
247
  "assert (\n",
201
248
  " ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
202
- ").read_text() == ln_setup.settings.storage.uid\n",
249
+ ").read_text().splitlines()[0] == ln_setup.settings.storage.uid\n",
203
250
  "assert ln_setup.settings.storage.is_on_hub\n",
204
251
  "assert ln_setup.settings.storage.uid == storage1_uid"
205
252
  ]
@@ -225,7 +272,7 @@
225
272
  "assert ln_setup.settings.storage.root_as_str == f\"{Path.cwd()}/storage2\"\n",
226
273
  "assert (\n",
227
274
  " ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
228
- ").read_text() == ln_setup.settings.storage.uid\n",
275
+ ").read_text().splitlines()[0] == ln_setup.settings.storage.uid\n",
229
276
  "assert ln_setup.settings.storage.is_on_hub\n",
230
277
  "assert ln_setup.settings.storage.uid == storage2_uid"
231
278
  ]
@@ -264,7 +311,7 @@
264
311
  "assert ln_setup.settings.storage.region == \"us-west-1\"\n",
265
312
  "assert (\n",
266
313
  " ln_setup.settings.storage.root / \".lamindb/storage_uid.txt\"\n",
267
- ").read_text() == ln_setup.settings.storage.uid\n",
314
+ ").read_text().splitlines()[0] == ln_setup.settings.storage.uid\n",
268
315
  "# root.fs contains the underlying fsspec filesystem\n",
269
316
  "assert (\n",
270
317
  " ln_setup.settings.storage.root.fs.cache_regions # set by lamindb to True for s3 by default\n",
@@ -443,7 +490,7 @@
443
490
  ],
444
491
  "metadata": {
445
492
  "kernelspec": {
446
- "display_name": "Python 3 (ipykernel)",
493
+ "display_name": "py312",
447
494
  "language": "python",
448
495
  "name": "python3"
449
496
  },
@@ -457,12 +504,7 @@
457
504
  "name": "python",
458
505
  "nbconvert_exporter": "python",
459
506
  "pygments_lexer": "ipython3",
460
- "version": "3.10.16"
461
- },
462
- "vscode": {
463
- "interpreter": {
464
- "hash": "61b4062b24dfb1010f420dad5aa3bd73a4d2af47d0ec44eafec465a35a9d7239"
465
- }
507
+ "version": "3.12.8"
466
508
  }
467
509
  },
468
510
  "nbformat": 4,
@@ -23,7 +23,7 @@
23
23
  "outputs": [],
24
24
  "source": [
25
25
  "import lamindb_setup as ln_setup\n",
26
- "from lamindb_setup.core.upath import create_path, UPath, InstanceNotEmpty\n",
26
+ "from lamindb_setup.core.upath import create_path, UPath, StorageNotEmpty\n",
27
27
  "from lamindb_setup.core._hub_core import (\n",
28
28
  " delete_instance,\n",
29
29
  " call_with_fallback_auth,\n",
@@ -44,7 +44,7 @@
44
44
  "source": [
45
45
  "try:\n",
46
46
  " delete_instance(f\"testuser1/{instance_name}\")\n",
47
- "except InstanceNotEmpty:\n",
47
+ "except StorageNotEmpty:\n",
48
48
  " instance_with_storage = call_with_fallback_auth(\n",
49
49
  " select_instance_by_owner_name,\n",
50
50
  " owner=\"testuser1\",\n",
@@ -137,7 +137,7 @@
137
137
  ],
138
138
  "metadata": {
139
139
  "kernelspec": {
140
- "display_name": "Python 3 (ipykernel)",
140
+ "display_name": "py312",
141
141
  "language": "python",
142
142
  "name": "python3"
143
143
  },
@@ -151,7 +151,7 @@
151
151
  "name": "python",
152
152
  "nbconvert_exporter": "python",
153
153
  "pygments_lexer": "ipython3",
154
- "version": "3.9.17"
154
+ "version": "3.12.8"
155
155
  }
156
156
  },
157
157
  "nbformat": 4,
@@ -19,7 +19,7 @@
19
19
  "from lamindb_setup.core.upath import UPath\n",
20
20
  "from lamindb_setup.core._hub_core import delete_instance\n",
21
21
  "from lamindb_setup.core._hub_client import connect_hub_with_auth\n",
22
- "from lamindb_setup.core.upath import InstanceNotEmpty\n",
22
+ "from lamindb_setup.core.upath import StorageNotEmpty\n",
23
23
  "\n",
24
24
  "instance_name = \"my-hosted\"\n",
25
25
  "assert ln_setup.settings.user.handle == \"testuser1\""
@@ -123,7 +123,7 @@
123
123
  "metadata": {},
124
124
  "outputs": [],
125
125
  "source": [
126
- "with pytest.raises(InstanceNotEmpty):\n",
126
+ "with pytest.raises(StorageNotEmpty):\n",
127
127
  " delete_instance(f\"testuser1/{instance_name}\")"
128
128
  ]
129
129
  },
@@ -23,7 +23,7 @@
23
23
  "from pathlib import Path\n",
24
24
  "\n",
25
25
  "name = f\"keep-artifacts-local-setup-{os.environ['LAMIN_ENV']}\"\n",
26
- "storage = (UPath(\"s3://lamindb-ci\") / name).as_posix()\n",
26
+ "storage = UPath(f\"s3://lamindb-ci/{name}\").as_posix()\n",
27
27
  "\n",
28
28
  "ln_setup.login(\"testuser1\")\n",
29
29
  "ln_setup.init(storage=storage)\n",
@@ -76,7 +76,7 @@
76
76
  ")\n",
77
77
  "assert (\n",
78
78
  " ln_setup.settings.instance.storage_local.root / \".lamindb/storage_uid.txt\"\n",
79
- ").read_text() == ln_setup.settings.instance.storage_local.uid\n",
79
+ ").read_text().splitlines()[0] == ln_setup.settings.instance.storage_local.uid\n",
80
80
  "assert ln_setup.settings.instance.storage_local is not None\n",
81
81
  "# the remote storage location is still in the regular slot\n",
82
82
  "assert ln_setup.settings.instance.storage.root.as_posix() == storage"
@@ -110,7 +110,7 @@
110
110
  ")\n",
111
111
  "assert (\n",
112
112
  " ln_setup.settings.instance.storage_local.root / \".lamindb/storage_uid.txt\"\n",
113
- ").read_text() == ln_setup.settings.instance.storage_local.uid"
113
+ ").read_text().splitlines()[0] == ln_setup.settings.instance.storage_local.uid"
114
114
  ]
115
115
  },
116
116
  {
@@ -177,7 +177,7 @@
177
177
  "metadata": {},
178
178
  "outputs": [],
179
179
  "source": [
180
- "with pytest.raises(ln_setup.core.upath.InstanceNotEmpty):\n",
180
+ "with pytest.raises(ln_setup.errors.StorageNotEmpty):\n",
181
181
  " ln_setup.delete(name, force=True)"
182
182
  ]
183
183
  },
@@ -227,7 +227,7 @@
227
227
  ],
228
228
  "metadata": {
229
229
  "kernelspec": {
230
- "display_name": "lamindb",
230
+ "display_name": "Python 3 (ipykernel)",
231
231
  "language": "python",
232
232
  "name": "python3"
233
233
  },
@@ -241,7 +241,7 @@
241
241
  "name": "python",
242
242
  "nbconvert_exporter": "python",
243
243
  "pygments_lexer": "ipython3",
244
- "version": "3.12.8"
244
+ "version": "3.10.16"
245
245
  }
246
246
  },
247
247
  "nbformat": 4,
@@ -54,6 +54,15 @@
54
54
  "ln_setup.init(storage=\"./testsetup\")"
55
55
  ]
56
56
  },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": null,
60
+ "metadata": {},
61
+ "outputs": [],
62
+ "source": [
63
+ "assert ln_setup.settings.instance.slug == \"testuser1/testsetup\""
64
+ ]
65
+ },
57
66
  {
58
67
  "cell_type": "code",
59
68
  "execution_count": null,
@@ -111,43 +120,7 @@
111
120
  "cell_type": "markdown",
112
121
  "metadata": {},
113
122
  "source": [
114
- "Let us try to init another instance in the same Python session:"
115
- ]
116
- },
117
- {
118
- "cell_type": "code",
119
- "execution_count": null,
120
- "metadata": {},
121
- "outputs": [],
122
- "source": [
123
- "from lamindb_setup._init_instance import CannotSwitchDefaultInstance\n",
124
- "\n",
125
- "with pytest.raises(CannotSwitchDefaultInstance):\n",
126
- " ln_setup.init(storage=\"./testsetup2\")\n",
127
- "with pytest.raises(CannotSwitchDefaultInstance):\n",
128
- " ln_setup.connect(\"testsetup\")\n",
129
- "with pytest.raises(RuntimeError):\n",
130
- " ln_setup.migrate.create()\n",
131
- "with pytest.raises(RuntimeError):\n",
132
- " ln_setup.migrate.deploy()\n",
133
- "\n",
134
- "assert ln_setup.settings.instance.slug == \"testuser1/testsetup\""
135
- ]
136
- },
137
- {
138
- "cell_type": "markdown",
139
- "metadata": {},
140
- "source": [
141
- "Reset `django` and connect to another instance:"
142
- ]
143
- },
144
- {
145
- "cell_type": "code",
146
- "execution_count": null,
147
- "metadata": {},
148
- "outputs": [],
149
- "source": [
150
- "ln_setup.core.django.reset_django()"
123
+ "Connect to another instance in the same process:"
151
124
  ]
152
125
  },
153
126
  {
@@ -182,7 +155,7 @@
182
155
  ],
183
156
  "metadata": {
184
157
  "kernelspec": {
185
- "display_name": "lamindb",
158
+ "display_name": "Python 3 (ipykernel)",
186
159
  "language": "python",
187
160
  "name": "python3"
188
161
  },
@@ -196,7 +169,7 @@
196
169
  "name": "python",
197
170
  "nbconvert_exporter": "python",
198
171
  "pygments_lexer": "ipython3",
199
- "version": "3.12.8"
172
+ "version": "3.10.16"
200
173
  }
201
174
  },
202
175
  "nbformat": 4,
@@ -16,9 +16,20 @@
16
16
  "outputs": [],
17
17
  "source": [
18
18
  "import os\n",
19
+ "from dotenv import dotenv_values\n",
20
+ "from platformdirs import user_config_dir\n",
21
+ "\n",
22
+ "# otherwise writing to system_settings_file() fails\n",
23
+ "os.environ[\"XDG_CONFIG_DIRS\"] = user_config_dir()\n",
24
+ "\n",
25
+ "import pytest\n",
19
26
  "import lamindb_setup as ln_setup\n",
20
27
  "from lamindb_setup._cache import set_cache_dir\n",
21
- "from lamindb_setup.core._settings_store import system_storage_settings_file\n",
28
+ "from lamindb_setup.core._settings_store import (\n",
29
+ " platform_user_storage_settings_file,\n",
30
+ " system_settings_file,\n",
31
+ ")\n",
32
+ "from lamindb_setup.core._settings_load import load_cache_path_from_settings\n",
22
33
  "\n",
23
34
  "ln_setup.login(\"testuser2\")"
24
35
  ]
@@ -30,8 +41,8 @@
30
41
  "metadata": {},
31
42
  "outputs": [],
32
43
  "source": [
33
- "if system_storage_settings_file().exists():\n",
34
- " system_storage_settings_file().unlink()"
44
+ "if platform_user_storage_settings_file().exists():\n",
45
+ " platform_user_storage_settings_file().unlink()"
35
46
  ]
36
47
  },
37
48
  {
@@ -44,6 +55,16 @@
44
55
  "ln_setup.init(storage=\"s3://lamindb-ci/test-cache\", name=\"test-cache\")"
45
56
  ]
46
57
  },
58
+ {
59
+ "cell_type": "code",
60
+ "execution_count": null,
61
+ "id": "1f984eac",
62
+ "metadata": {},
63
+ "outputs": [],
64
+ "source": [
65
+ "print(ln_setup.settings)"
66
+ ]
67
+ },
47
68
  {
48
69
  "cell_type": "markdown",
49
70
  "id": "fc410abd",
@@ -59,7 +80,54 @@
59
80
  "metadata": {},
60
81
  "outputs": [],
61
82
  "source": [
62
- "assert not system_storage_settings_file().exists()"
83
+ "assert not platform_user_storage_settings_file().exists()"
84
+ ]
85
+ },
86
+ {
87
+ "cell_type": "code",
88
+ "execution_count": null,
89
+ "id": "0fe69c33",
90
+ "metadata": {},
91
+ "outputs": [],
92
+ "source": [
93
+ "initial_cache_dir = ln_setup.settings.cache_dir\n",
94
+ "\n",
95
+ "system_cache_dir = initial_cache_dir.parent / \"Cache_system\"\n",
96
+ "system_cache_dir.mkdir(parents=True, exist_ok=True)"
97
+ ]
98
+ },
99
+ {
100
+ "cell_type": "markdown",
101
+ "id": "90126758",
102
+ "metadata": {},
103
+ "source": [
104
+ "You can specify system-wide cache dir via system settings file, it has the lowest priority."
105
+ ]
106
+ },
107
+ {
108
+ "cell_type": "code",
109
+ "execution_count": null,
110
+ "id": "58fe268f",
111
+ "metadata": {},
112
+ "outputs": [],
113
+ "source": [
114
+ "system_settings = system_settings_file()\n",
115
+ "system_settings.parent.mkdir(parents=True, exist_ok=True)\n",
116
+ "\n",
117
+ "with open(system_settings, \"w\") as f:\n",
118
+ " f.write(f\"lamindb_cache_path={system_cache_dir.as_posix()}\")"
119
+ ]
120
+ },
121
+ {
122
+ "cell_type": "code",
123
+ "execution_count": null,
124
+ "id": "58de6e01",
125
+ "metadata": {},
126
+ "outputs": [],
127
+ "source": [
128
+ "ln_setup.settings._cache_dir = None\n",
129
+ "\n",
130
+ "assert ln_setup.settings.cache_dir == system_cache_dir"
63
131
  ]
64
132
  },
65
133
  {
@@ -69,8 +137,19 @@
69
137
  "metadata": {},
70
138
  "outputs": [],
71
139
  "source": [
72
- "old_cache_dir = ln_setup.settings.cache_dir\n",
73
- "new_cache_dir = old_cache_dir.parent / \"Cache1\""
140
+ "new_cache_dir = initial_cache_dir.parent / \"Cache1\""
141
+ ]
142
+ },
143
+ {
144
+ "cell_type": "code",
145
+ "execution_count": null,
146
+ "id": "f809a95f",
147
+ "metadata": {},
148
+ "outputs": [],
149
+ "source": [
150
+ "with pytest.raises(ValueError) as error:\n",
151
+ " set_cache_dir(\"./\")\n",
152
+ "assert error.exconly() == \"ValueError: A path to the cache dir should be absolute.\""
74
153
  ]
75
154
  },
76
155
  {
@@ -80,7 +159,11 @@
80
159
  "metadata": {},
81
160
  "outputs": [],
82
161
  "source": [
83
- "set_cache_dir(new_cache_dir)"
162
+ "set_cache_dir(new_cache_dir)\n",
163
+ "\n",
164
+ "ln_setup.settings._cache_dir = (\n",
165
+ " None # just reset to check that the cache dir is loaded correctly\n",
166
+ ")"
84
167
  ]
85
168
  },
86
169
  {
@@ -90,7 +173,25 @@
90
173
  "metadata": {},
91
174
  "outputs": [],
92
175
  "source": [
93
- "assert system_storage_settings_file().exists()"
176
+ "platform_user_storage_settings = platform_user_storage_settings_file()\n",
177
+ "\n",
178
+ "assert platform_user_storage_settings.exists()\n",
179
+ "\n",
180
+ "lamindb_cache_path = dotenv_values(platform_user_storage_settings)[\"lamindb_cache_path\"]\n",
181
+ "\n",
182
+ "assert lamindb_cache_path == new_cache_dir.as_posix(), lamindb_cache_path"
183
+ ]
184
+ },
185
+ {
186
+ "cell_type": "code",
187
+ "execution_count": null,
188
+ "id": "cb75539e",
189
+ "metadata": {},
190
+ "outputs": [],
191
+ "source": [
192
+ "loaded_cache_path = load_cache_path_from_settings()\n",
193
+ "\n",
194
+ "assert loaded_cache_path == new_cache_dir, loaded_cache_path"
94
195
  ]
95
196
  },
96
197
  {
@@ -100,7 +201,7 @@
100
201
  "metadata": {},
101
202
  "outputs": [],
102
203
  "source": [
103
- "assert ln_setup.settings.cache_dir == new_cache_dir"
204
+ "assert ln_setup.settings.cache_dir == new_cache_dir, ln_setup.settings.cache_dir"
104
205
  ]
105
206
  },
106
207
  {
@@ -138,7 +239,8 @@
138
239
  "metadata": {},
139
240
  "outputs": [],
140
241
  "source": [
141
- "!lamin cache clear"
242
+ "exit_status = os.system(\"lamin cache clear\")\n",
243
+ "assert exit_status == 0"
142
244
  ]
143
245
  },
144
246
  {
@@ -148,7 +250,8 @@
148
250
  "metadata": {},
149
251
  "outputs": [],
150
252
  "source": [
151
- "assert not any(new_cache_dir.iterdir())"
253
+ "cache_content = list(new_cache_dir.iterdir())\n",
254
+ "assert len(cache_content) == 0, cache_content"
152
255
  ]
153
256
  },
154
257
  {
@@ -176,7 +279,7 @@
176
279
  "metadata": {},
177
280
  "outputs": [],
178
281
  "source": [
179
- "assert ln_setup.settings.cache_dir == old_cache_dir"
282
+ "assert ln_setup.settings.cache_dir == system_cache_dir"
180
283
  ]
181
284
  },
182
285
  {
@@ -196,12 +299,33 @@
196
299
  "metadata": {},
197
300
  "outputs": [],
198
301
  "source": [
199
- "assert ln_setup.settings.cache_dir == old_cache_dir"
302
+ "assert ln_setup.settings.cache_dir == system_cache_dir"
303
+ ]
304
+ },
305
+ {
306
+ "cell_type": "code",
307
+ "execution_count": null,
308
+ "id": "1e08abf2",
309
+ "metadata": {},
310
+ "outputs": [],
311
+ "source": [
312
+ "system_settings.unlink()"
313
+ ]
314
+ },
315
+ {
316
+ "cell_type": "code",
317
+ "execution_count": null,
318
+ "id": "6e86fc4a",
319
+ "metadata": {},
320
+ "outputs": [],
321
+ "source": [
322
+ "ln_setup.settings._cache_dir = None\n",
323
+ "assert ln_setup.settings.cache_dir == initial_cache_dir"
200
324
  ]
201
325
  },
202
326
  {
203
327
  "cell_type": "markdown",
204
- "id": "a4de1b2b",
328
+ "id": "57c74240",
205
329
  "metadata": {},
206
330
  "source": [
207
331
  "Setting the cache dir through CLI doesn't affect the currently loaded settings because it is done in another process and the settings only check the cache dir in `settings.env` on init."
@@ -252,7 +376,7 @@
252
376
  "metadata": {},
253
377
  "outputs": [],
254
378
  "source": [
255
- "system_storage_settings_file().unlink()\n",
379
+ "platform_user_storage_settings_file().unlink()\n",
256
380
  "ln_setup.delete(\"test-cache\", force=True)"
257
381
  ]
258
382
  }
@@ -273,7 +397,7 @@
273
397
  "name": "python",
274
398
  "nbconvert_exporter": "python",
275
399
  "pygments_lexer": "ipython3",
276
- "version": "3.9.17"
400
+ "version": "3.10.16"
277
401
  }
278
402
  },
279
403
  "nbformat": 4,
@@ -82,7 +82,7 @@
82
82
  "metadata": {},
83
83
  "outputs": [],
84
84
  "source": [
85
- "ln_setup.load(\"test-anonymous-init\")\n",
85
+ "ln_setup.connect(\"test-anonymous-init\")\n",
86
86
  "assert ln_setup.settings.instance.name == \"test-anonymous-init\"\n",
87
87
  "assert ln_setup.settings.instance.owner == \"anonymous\""
88
88
  ]
@@ -30,18 +30,20 @@ Modules & settings:
30
30
  settings
31
31
  core
32
32
  django
33
+ errors
34
+ types
33
35
 
34
36
  """
35
37
 
36
- __version__ = "1.6.1" # denote a release candidate for 0.1.0 with 0.1rc1
38
+ __version__ = "1.7.0" # denote a release candidate for 0.1.0 with 0.1rc1
37
39
 
38
40
  import os
39
41
 
40
42
  from packaging import version as packaging_version
41
43
 
42
- from . import core
44
+ from . import core, errors, types
43
45
  from ._check_setup import _check_instance_setup
44
- from ._connect_instance import connect, load
46
+ from ._connect_instance import connect
45
47
  from ._delete import delete
46
48
  from ._disconnect import disconnect
47
49
  from ._django import django