lamindb_setup 0.77.3__tar.gz → 0.77.4__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 (97) hide show
  1. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/PKG-INFO +1 -1
  2. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/__init__.py +1 -1
  3. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_delete.py +141 -139
  4. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/.github/workflows/build.yml +0 -0
  5. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/.github/workflows/doc-changes.yml +0 -0
  6. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/.gitignore +0 -0
  7. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/.pre-commit-config.yaml +0 -0
  8. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/LICENSE +0 -0
  9. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/README.md +0 -0
  10. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/changelog.md +0 -0
  11. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
  12. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/02-connect-local-instance.ipynb +0 -0
  13. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/03-add-managed-storage.ipynb +0 -0
  14. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
  15. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
  16. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
  17. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
  18. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/08-test-multi-session.ipynb +0 -0
  19. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-cloud/test_notebooks.py +0 -0
  20. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-cache-management.ipynb +0 -0
  21. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-cloud-sync.ipynb +0 -0
  22. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
  23. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-empty-init.ipynb +0 -0
  24. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-import-schema.ipynb +0 -0
  25. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-init-load-local-anonymously.ipynb +0 -0
  26. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-insufficient-user-info.ipynb +0 -0
  27. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
  28. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
  29. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/hub-prod/test_notebooks2.py +0 -0
  30. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/index.md +0 -0
  31. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/notebooks.md +0 -0
  32. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/docs/reference.md +0 -0
  33. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_cache.py +0 -0
  34. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_check.py +0 -0
  35. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_check_setup.py +0 -0
  36. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_close.py +0 -0
  37. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_connect_instance.py +0 -0
  38. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_django.py +0 -0
  39. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_entry_points.py +0 -0
  40. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_exportdb.py +0 -0
  41. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_importdb.py +0 -0
  42. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_init_instance.py +0 -0
  43. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_migrate.py +0 -0
  44. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_register_instance.py +0 -0
  45. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_schema.py +0 -0
  46. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_schema_metadata.py +0 -0
  47. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_set_managed_storage.py +0 -0
  48. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_setup_user.py +0 -0
  49. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/_silence_loggers.py +0 -0
  50. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/__init__.py +0 -0
  51. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_aws_credentials.py +0 -0
  52. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_aws_storage.py +0 -0
  53. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_deprecated.py +0 -0
  54. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_docs.py +0 -0
  55. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_hub_client.py +0 -0
  56. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_hub_core.py +0 -0
  57. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_hub_crud.py +0 -0
  58. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_hub_utils.py +0 -0
  59. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_private_django_api.py +0 -0
  60. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_settings.py +0 -0
  61. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_settings_instance.py +0 -0
  62. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_settings_load.py +0 -0
  63. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_settings_save.py +0 -0
  64. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_settings_storage.py +0 -0
  65. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_settings_store.py +0 -0
  66. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_settings_user.py +0 -0
  67. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
  68. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/cloud_sqlite_locker.py +0 -0
  69. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/django.py +0 -0
  70. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/exceptions.py +0 -0
  71. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/hashing.py +0 -0
  72. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/types.py +0 -0
  73. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/lamindb_setup/core/upath.py +0 -0
  74. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/noxfile.py +0 -0
  75. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/pyproject.toml +0 -0
  76. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
  77. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-cloud/test_connect_instance.py +0 -0
  78. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-cloud/test_delete_instance.py +0 -0
  79. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
  80. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-cloud/test_init_instance.py +0 -0
  81. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-cloud/test_login.py +0 -0
  82. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-cloud/test_migrate.py +0 -0
  83. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-cloud/test_set_storage.py +0 -0
  84. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-local/conftest.py +0 -0
  85. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-local/test_all.py +0 -0
  86. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-local/test_update_schema_in_hub.py +0 -0
  87. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-prod/conftest.py +0 -0
  88. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-prod/test_django.py +0 -0
  89. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-prod/test_global_settings.py +0 -0
  90. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-prod/test_switch_and_fallback_env.py +0 -0
  91. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/hub-prod/test_upath.py +0 -0
  92. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/storage/test_entry_point.py +0 -0
  93. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/storage/test_hashing.py +0 -0
  94. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/storage/test_storage_access.py +0 -0
  95. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/storage/test_storage_basis.py +0 -0
  96. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/storage/test_storage_stats.py +0 -0
  97. {lamindb_setup-0.77.3 → lamindb_setup-0.77.4}/tests/storage/test_to_url.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamindb_setup
3
- Version: 0.77.3
3
+ Version: 0.77.4
4
4
  Summary: Setup & configure LaminDB.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Description-Content-Type: text/markdown
@@ -34,7 +34,7 @@ Modules & settings:
34
34
 
35
35
  """
36
36
 
37
- __version__ = "0.77.3" # denote a release candidate for 0.1.0 with 0.1rc1
37
+ __version__ = "0.77.4" # denote a release candidate for 0.1.0 with 0.1rc1
38
38
 
39
39
  import os as _os
40
40
  import sys as _sys
@@ -1,139 +1,141 @@
1
- from __future__ import annotations
2
-
3
- import shutil
4
- from typing import TYPE_CHECKING
5
- from uuid import UUID
6
-
7
- from lamin_utils import logger
8
-
9
- from ._connect_instance import _connect_instance, get_owner_name_from_identifier
10
- from .core._aws_credentials import HOSTED_BUCKETS
11
- from .core._hub_core import delete_instance as delete_instance_on_hub
12
- from .core._hub_core import get_storage_records_for_instance
13
- from .core._settings import settings
14
- from .core._settings_storage import StorageSettings
15
- from .core.upath import check_storage_is_empty
16
-
17
- if TYPE_CHECKING:
18
- from pathlib import Path
19
-
20
- from .core._settings_instance import InstanceSettings
21
-
22
-
23
- def delete_cache(isettings: InstanceSettings):
24
- # avoid init of root
25
- cache_dir = isettings.storage.cache_dir / isettings.storage._root_init
26
- if cache_dir.exists():
27
- shutil.rmtree(cache_dir)
28
-
29
-
30
- def delete_exclusion_dir(isettings: InstanceSettings) -> None:
31
- exclusion_dir = isettings.storage.root / f".lamindb/_exclusion/{isettings._id.hex}"
32
- if exclusion_dir.exists():
33
- exclusion_dir.rmdir()
34
-
35
-
36
- def delete_by_isettings(isettings: InstanceSettings) -> None:
37
- settings_file = isettings._get_settings_file()
38
- if settings_file.exists():
39
- settings_file.unlink()
40
- delete_cache(isettings)
41
- if isettings.dialect == "sqlite":
42
- try:
43
- if isettings._sqlite_file.exists():
44
- isettings._sqlite_file.unlink()
45
- except PermissionError:
46
- logger.warning(
47
- "Did not have permission to delete SQLite file:"
48
- f" {isettings._sqlite_file}"
49
- )
50
- pass
51
- # unset the global instance settings
52
- if settings._instance_exists and isettings.slug == settings.instance.slug:
53
- if settings._instance_settings_path.exists():
54
- settings._instance_settings_path.unlink()
55
- settings._instance_settings = None
56
-
57
-
58
- def delete(slug: str, force: bool = False, require_empty: bool = True) -> int | None:
59
- """Delete a LaminDB instance.
60
-
61
- Args:
62
- slug: The instance slug `account_handle/instance_name` or URL.
63
- If the instance is owned by you, it suffices to pass the instance name.
64
- force: Whether to skip the confirmation prompt.
65
- require_empty: Whether to check if the instance is empty before deleting.
66
- """
67
- owner, name = get_owner_name_from_identifier(slug)
68
- isettings = _connect_instance(owner, name, raise_permission_error=False)
69
- if isettings.dialect != "sqlite":
70
- logger.warning(
71
- f"delete() does not yet affect your Postgres database at {isettings.db}"
72
- )
73
- if isettings.is_on_hub and settings.user.handle == "anonymous":
74
- logger.warning(
75
- "won't delete the hub component of this instance because you're not logged in"
76
- )
77
- if not force:
78
- valid_responses = ["y", "yes"]
79
- user_input = (
80
- input(f"Are you sure you want to delete instance {isettings.slug}? (y/n) ")
81
- .strip()
82
- .lower()
83
- )
84
- if user_input not in valid_responses:
85
- return -1
86
-
87
- # the actual deletion process begins here
88
- if isettings.dialect == "sqlite" and isettings.is_remote:
89
- # delete the exlusion dir first because it's hard to count its objects
90
- delete_exclusion_dir(isettings)
91
- if isettings.storage.type_is_cloud and isettings.storage.root_as_str.startswith(
92
- HOSTED_BUCKETS
93
- ):
94
- if not require_empty:
95
- logger.warning(
96
- "hosted storage always has to be empty, ignoring `require_empty`"
97
- )
98
- require_empty = True
99
- # first the default storage
100
- n_objects = check_storage_is_empty(
101
- isettings.storage.root,
102
- raise_error=require_empty,
103
- account_for_sqlite_file=isettings.dialect == "sqlite",
104
- )
105
- if isettings.storage._mark_storage_root.exists():
106
- isettings.storage._mark_storage_root.unlink(
107
- missing_ok=True # this is totally weird, but needed on Py3.11
108
- )
109
- # now everything that's on the hub
110
- if settings.user.handle != "anonymous":
111
- storage_records = get_storage_records_for_instance(isettings._id)
112
- for storage_record in storage_records:
113
- if storage_record["root"] == isettings.storage.root_as_str:
114
- continue
115
- ssettings = StorageSettings(storage_record["root"]) # type: ignore
116
- check_storage_is_empty(
117
- ssettings.root, # type: ignore
118
- raise_error=require_empty,
119
- )
120
- if ssettings._mark_storage_root.exists():
121
- ssettings._mark_storage_root.unlink(
122
- missing_ok=True # this is totally weird, but needed on Py3.11
123
- )
124
- logger.info(f"deleting instance {isettings.slug}")
125
- # below we can skip check_storage_is_empty() because we already called
126
- # it above
127
- if settings.user.handle != "anonymous" and isettings.is_on_hub:
128
- # start with deleting things on the hub
129
- # this will error if the user doesn't have permission
130
- delete_instance_on_hub(isettings._id, require_empty=False)
131
- delete_by_isettings(isettings)
132
- # if .lndb file was delete, then we might count -1
133
- if n_objects <= 0 and isettings.storage.type == "local":
134
- # dir is only empty after sqlite file was delete via delete_by_isettings
135
- if (isettings.storage.root / ".lamindb").exists():
136
- (isettings.storage.root / ".lamindb").rmdir()
137
- if isettings.storage.root.exists():
138
- isettings.storage.root.rmdir()
139
- return None
1
+ from __future__ import annotations
2
+
3
+ import shutil
4
+ from typing import TYPE_CHECKING
5
+ from uuid import UUID
6
+
7
+ from lamin_utils import logger
8
+
9
+ from ._connect_instance import _connect_instance, get_owner_name_from_identifier
10
+ from .core._aws_credentials import HOSTED_BUCKETS
11
+ from .core._hub_core import delete_instance as delete_instance_on_hub
12
+ from .core._hub_core import get_storage_records_for_instance
13
+ from .core._settings import settings
14
+ from .core._settings_storage import StorageSettings
15
+ from .core.upath import LocalPathClasses, check_storage_is_empty
16
+
17
+ if TYPE_CHECKING:
18
+ from pathlib import Path
19
+
20
+ from .core._settings_instance import InstanceSettings
21
+
22
+
23
+ def delete_cache(isettings: InstanceSettings):
24
+ # avoid init of root
25
+ root = isettings.storage._root_init
26
+ if not isinstance(root, LocalPathClasses):
27
+ cache_dir = isettings.storage.cache_dir / root
28
+ if cache_dir.exists():
29
+ shutil.rmtree(cache_dir)
30
+
31
+
32
+ def delete_exclusion_dir(isettings: InstanceSettings) -> None:
33
+ exclusion_dir = isettings.storage.root / f".lamindb/_exclusion/{isettings._id.hex}"
34
+ if exclusion_dir.exists():
35
+ exclusion_dir.rmdir()
36
+
37
+
38
+ def delete_by_isettings(isettings: InstanceSettings) -> None:
39
+ settings_file = isettings._get_settings_file()
40
+ if settings_file.exists():
41
+ settings_file.unlink()
42
+ delete_cache(isettings)
43
+ if isettings.dialect == "sqlite":
44
+ try:
45
+ if isettings._sqlite_file.exists():
46
+ isettings._sqlite_file.unlink()
47
+ except PermissionError:
48
+ logger.warning(
49
+ "Did not have permission to delete SQLite file:"
50
+ f" {isettings._sqlite_file}"
51
+ )
52
+ pass
53
+ # unset the global instance settings
54
+ if settings._instance_exists and isettings.slug == settings.instance.slug:
55
+ if settings._instance_settings_path.exists():
56
+ settings._instance_settings_path.unlink()
57
+ settings._instance_settings = None
58
+
59
+
60
+ def delete(slug: str, force: bool = False, require_empty: bool = True) -> int | None:
61
+ """Delete a LaminDB instance.
62
+
63
+ Args:
64
+ slug: The instance slug `account_handle/instance_name` or URL.
65
+ If the instance is owned by you, it suffices to pass the instance name.
66
+ force: Whether to skip the confirmation prompt.
67
+ require_empty: Whether to check if the instance is empty before deleting.
68
+ """
69
+ owner, name = get_owner_name_from_identifier(slug)
70
+ isettings = _connect_instance(owner, name, raise_permission_error=False)
71
+ if isettings.dialect != "sqlite":
72
+ logger.warning(
73
+ f"delete() does not yet affect your Postgres database at {isettings.db}"
74
+ )
75
+ if isettings.is_on_hub and settings.user.handle == "anonymous":
76
+ logger.warning(
77
+ "won't delete the hub component of this instance because you're not logged in"
78
+ )
79
+ if not force:
80
+ valid_responses = ["y", "yes"]
81
+ user_input = (
82
+ input(f"Are you sure you want to delete instance {isettings.slug}? (y/n) ")
83
+ .strip()
84
+ .lower()
85
+ )
86
+ if user_input not in valid_responses:
87
+ return -1
88
+
89
+ # the actual deletion process begins here
90
+ if isettings.dialect == "sqlite" and isettings.is_remote:
91
+ # delete the exlusion dir first because it's hard to count its objects
92
+ delete_exclusion_dir(isettings)
93
+ if isettings.storage.type_is_cloud and isettings.storage.root_as_str.startswith(
94
+ HOSTED_BUCKETS
95
+ ):
96
+ if not require_empty:
97
+ logger.warning(
98
+ "hosted storage always has to be empty, ignoring `require_empty`"
99
+ )
100
+ require_empty = True
101
+ # first the default storage
102
+ n_objects = check_storage_is_empty(
103
+ isettings.storage.root,
104
+ raise_error=require_empty,
105
+ account_for_sqlite_file=isettings.dialect == "sqlite",
106
+ )
107
+ if isettings.storage._mark_storage_root.exists():
108
+ isettings.storage._mark_storage_root.unlink(
109
+ missing_ok=True # this is totally weird, but needed on Py3.11
110
+ )
111
+ # now everything that's on the hub
112
+ if settings.user.handle != "anonymous":
113
+ storage_records = get_storage_records_for_instance(isettings._id)
114
+ for storage_record in storage_records:
115
+ if storage_record["root"] == isettings.storage.root_as_str:
116
+ continue
117
+ ssettings = StorageSettings(storage_record["root"]) # type: ignore
118
+ check_storage_is_empty(
119
+ ssettings.root, # type: ignore
120
+ raise_error=require_empty,
121
+ )
122
+ if ssettings._mark_storage_root.exists():
123
+ ssettings._mark_storage_root.unlink(
124
+ missing_ok=True # this is totally weird, but needed on Py3.11
125
+ )
126
+ logger.info(f"deleting instance {isettings.slug}")
127
+ # below we can skip check_storage_is_empty() because we already called
128
+ # it above
129
+ if settings.user.handle != "anonymous" and isettings.is_on_hub:
130
+ # start with deleting things on the hub
131
+ # this will error if the user doesn't have permission
132
+ delete_instance_on_hub(isettings._id, require_empty=False)
133
+ delete_by_isettings(isettings)
134
+ # if .lndb file was delete, then we might count -1
135
+ if n_objects <= 0 and isettings.storage.type == "local":
136
+ # dir is only empty after sqlite file was delete via delete_by_isettings
137
+ if (isettings.storage.root / ".lamindb").exists():
138
+ (isettings.storage.root / ".lamindb").rmdir()
139
+ if isettings.storage.root.exists():
140
+ isettings.storage.root.rmdir()
141
+ return None
File without changes
File without changes