lamindb_setup 1.0a5__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/.github/workflows/build.yml +6 -4
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/PKG-INFO +2 -2
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/__init__.py +3 -20
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_cache.py +9 -5
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_check_setup.py +17 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_connect_instance.py +63 -36
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_entry_points.py +1 -4
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_migrate.py +14 -11
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/django.py +3 -4
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/hashing.py +1 -1
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/upath.py +1 -1
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/pyproject.toml +4 -1
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_connect_instance.py +8 -6
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-local/test_all.py +6 -3
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-prod/test_upath.py +1 -1
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/.github/workflows/doc-changes.yml +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/.gitignore +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/.pre-commit-config.yaml +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/LICENSE +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/README.md +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/changelog.md +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/02-connect-local-instance.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/03-add-managed-storage.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/08-test-multi-session.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-cloud/test_notebooks.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-cache-management.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-cloud-sync.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-empty-init.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-import-schema.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-init-load-local-anonymously.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-insufficient-user-info.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test_notebooks2.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/index.md +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/notebooks.md +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/reference.md +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_check.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_close.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_delete.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_django.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_exportdb.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_importdb.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_init_instance.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_register_instance.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_schema.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_schema_metadata.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_set_managed_storage.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_setup_user.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/_silence_loggers.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/__init__.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_aws_credentials.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_aws_storage.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_deprecated.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_docs.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_hub_client.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_hub_core.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_hub_crud.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_hub_utils.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_private_django_api.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_settings.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_settings_instance.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_settings_load.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_settings_save.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_settings_storage.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_settings_store.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_settings_user.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/cloud_sqlite_locker.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/exceptions.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/lamindb_setup/core/types.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/noxfile.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_delete_instance.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_edge_request.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_init_instance.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_login.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_migrate.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_set_storage.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-local/conftest.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-local/test_update_schema_in_hub.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-prod/conftest.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-prod/test_aws_credentials_manager.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-prod/test_django.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-prod/test_global_settings.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-prod/test_switch_and_fallback_env.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/storage/test_entry_point.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/storage/test_hashing.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/storage/test_storage_access.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/storage/test_storage_basis.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/storage/test_storage_stats.py +0 -0
- {lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/storage/test_to_url.py +0 -0
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
# tests only on production hub
|
|
13
13
|
hub-prod:
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
|
-
timeout-minutes:
|
|
15
|
+
timeout-minutes: 12
|
|
16
16
|
steps:
|
|
17
17
|
- uses: actions/checkout@v3
|
|
18
18
|
- uses: actions/setup-python@v4
|
|
@@ -44,7 +44,7 @@ jobs:
|
|
|
44
44
|
python-version: "3.11"
|
|
45
45
|
- lamin_env: "staging"
|
|
46
46
|
python-version: "3.10" # test on 3.9
|
|
47
|
-
timeout-minutes:
|
|
47
|
+
timeout-minutes: 12
|
|
48
48
|
steps:
|
|
49
49
|
- uses: aws-actions/configure-aws-credentials@v4
|
|
50
50
|
with:
|
|
@@ -94,7 +94,7 @@ jobs:
|
|
|
94
94
|
# test user access to storage
|
|
95
95
|
storage:
|
|
96
96
|
runs-on: ubuntu-latest
|
|
97
|
-
timeout-minutes:
|
|
97
|
+
timeout-minutes: 12
|
|
98
98
|
steps:
|
|
99
99
|
- uses: actions/checkout@v4
|
|
100
100
|
- uses: actions/setup-python@v4
|
|
@@ -119,7 +119,7 @@ jobs:
|
|
|
119
119
|
# test low-level hub functionality
|
|
120
120
|
hub-local:
|
|
121
121
|
runs-on: ubuntu-latest
|
|
122
|
-
timeout-minutes:
|
|
122
|
+
timeout-minutes: 12
|
|
123
123
|
steps:
|
|
124
124
|
- uses: aws-actions/configure-aws-credentials@v4
|
|
125
125
|
with:
|
|
@@ -152,6 +152,8 @@ jobs:
|
|
|
152
152
|
path: /var/lib/docker
|
|
153
153
|
key: cache-supabase
|
|
154
154
|
- uses: supabase/setup-cli@v1
|
|
155
|
+
with:
|
|
156
|
+
version: "2.6.8"
|
|
155
157
|
- run: nox -s hub_local
|
|
156
158
|
env:
|
|
157
159
|
LAMIN_ENV: "local"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: lamindb_setup
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: Setup & configure LaminDB.
|
|
5
5
|
Author-email: Lamin Labs <open-source@lamin.ai>
|
|
6
|
-
Requires-Python: >=3.
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: lamin_utils>=0.3.3
|
|
9
9
|
Requires-Dist: django>=5,<5.2
|
|
@@ -33,10 +33,9 @@ Modules & settings:
|
|
|
33
33
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
|
-
__version__ = "1.
|
|
36
|
+
__version__ = "1.0.2" # denote a release candidate for 0.1.0 with 0.1rc1
|
|
37
37
|
|
|
38
|
-
import os
|
|
39
|
-
import sys as _sys
|
|
38
|
+
import os
|
|
40
39
|
|
|
41
40
|
from . import core
|
|
42
41
|
from ._check_setup import _check_instance_setup
|
|
@@ -76,27 +75,11 @@ def _is_CI_environment() -> bool:
|
|
|
76
75
|
"SEMAPHORE", # Semaphore CI
|
|
77
76
|
"BUILD_ID", # Generic build environments
|
|
78
77
|
]
|
|
79
|
-
return any(env_var in
|
|
78
|
+
return any(env_var in os.environ for env_var in ci_env_vars)
|
|
80
79
|
|
|
81
80
|
|
|
82
81
|
_TESTING = _is_CI_environment()
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
# hide the supabase error in a thread on windows
|
|
86
|
-
if _os.name == "nt":
|
|
87
|
-
if _sys.version_info.minor > 7:
|
|
88
|
-
import threading
|
|
89
|
-
|
|
90
|
-
_original_excepthook = threading.excepthook
|
|
91
|
-
|
|
92
|
-
def _except_hook(args):
|
|
93
|
-
is_overflow = args.exc_type is OverflowError
|
|
94
|
-
for_timeout = str(args.exc_value) == "timeout value is too large"
|
|
95
|
-
if not (is_overflow and for_timeout):
|
|
96
|
-
_original_excepthook(args)
|
|
97
|
-
|
|
98
|
-
threading.excepthook = _except_hook
|
|
99
|
-
|
|
100
83
|
# provide a way for other packages to run custom code on import
|
|
101
84
|
_call_registered_entry_points("lamindb_setup.on_import")
|
|
102
85
|
|
|
@@ -10,11 +10,15 @@ from .core._settings_save import save_system_storage_settings
|
|
|
10
10
|
def clear_cache_dir():
|
|
11
11
|
from lamindb_setup import close, settings
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
try:
|
|
14
|
+
if settings.instance._is_cloud_sqlite:
|
|
15
|
+
logger.warning(
|
|
16
|
+
"Closing the current instance to update the cloud sqlite database."
|
|
17
|
+
)
|
|
18
|
+
close()
|
|
19
|
+
except SystemExit as e:
|
|
20
|
+
if str(e) != "No instance is loaded! Call `lamin init` or `lamin connect`":
|
|
21
|
+
raise e
|
|
18
22
|
|
|
19
23
|
cache_dir = settings.cache_dir
|
|
20
24
|
shutil.rmtree(cache_dir)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import functools
|
|
3
4
|
import importlib as il
|
|
4
5
|
import os
|
|
5
6
|
from typing import TYPE_CHECKING
|
|
@@ -13,6 +14,8 @@ from .core._settings_store import current_instance_settings_file
|
|
|
13
14
|
from .core.exceptions import DefaultMessageException
|
|
14
15
|
|
|
15
16
|
if TYPE_CHECKING:
|
|
17
|
+
from collections.abc import Callable
|
|
18
|
+
|
|
16
19
|
from .core._settings_instance import InstanceSettings
|
|
17
20
|
|
|
18
21
|
|
|
@@ -30,6 +33,20 @@ CURRENT_ISETTINGS: InstanceSettings | None = None
|
|
|
30
33
|
IS_LOADING: bool = False
|
|
31
34
|
|
|
32
35
|
|
|
36
|
+
# decorator to disable auto-connect when importing a module such as lamindb
|
|
37
|
+
def _loading(func: Callable):
|
|
38
|
+
@functools.wraps(func)
|
|
39
|
+
def wrapper(*args, **kwargs):
|
|
40
|
+
global IS_LOADING
|
|
41
|
+
IS_LOADING = True
|
|
42
|
+
try:
|
|
43
|
+
return func(*args, **kwargs)
|
|
44
|
+
finally:
|
|
45
|
+
IS_LOADING = False
|
|
46
|
+
|
|
47
|
+
return wrapper
|
|
48
|
+
|
|
49
|
+
|
|
33
50
|
def _get_current_instance_settings() -> InstanceSettings | None:
|
|
34
51
|
global CURRENT_ISETTINGS
|
|
35
52
|
|
|
@@ -7,7 +7,7 @@ from uuid import UUID
|
|
|
7
7
|
|
|
8
8
|
from lamin_utils import logger
|
|
9
9
|
|
|
10
|
-
from ._check_setup import _check_instance_setup
|
|
10
|
+
from ._check_setup import _check_instance_setup, _get_current_instance_settings
|
|
11
11
|
from ._close import close as close_instance
|
|
12
12
|
from ._init_instance import (
|
|
13
13
|
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE,
|
|
@@ -186,12 +186,12 @@ def _connect_instance(
|
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
@unlock_cloud_sqlite_upon_exception(ignore_prev_locker=True)
|
|
189
|
-
def connect(
|
|
190
|
-
"""Connect to instance.
|
|
189
|
+
def connect(instance: str | None = None, **kwargs) -> str | tuple | None:
|
|
190
|
+
"""Connect to an instance.
|
|
191
191
|
|
|
192
192
|
Args:
|
|
193
|
-
|
|
194
|
-
If
|
|
193
|
+
instance: `None` or an instance identifier (URL, slug `account/name`, or `name` if the instance is local or in your account).
|
|
194
|
+
If `None`, it will connect to the instance that was connected via the CLI.
|
|
195
195
|
"""
|
|
196
196
|
# validate kwargs
|
|
197
197
|
valid_kwargs = {
|
|
@@ -220,39 +220,46 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
|
|
|
220
220
|
access_token = _user.access_token
|
|
221
221
|
|
|
222
222
|
try:
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
if instance is None:
|
|
224
|
+
isettings_or_none = _get_current_instance_settings()
|
|
225
|
+
if isettings_or_none is None:
|
|
226
|
+
raise SystemExit(
|
|
227
|
+
"No instance was connected through the CLI, pass a value to `instance` or connect via the CLI."
|
|
228
|
+
)
|
|
229
|
+
isettings = isettings_or_none
|
|
230
|
+
else:
|
|
231
|
+
owner, name = get_owner_name_from_identifier(instance)
|
|
232
|
+
if _check_instance_setup() and not _test:
|
|
233
|
+
if (
|
|
234
|
+
settings._instance_exists
|
|
235
|
+
and f"{owner}/{name}" == settings.instance.slug
|
|
236
|
+
):
|
|
237
|
+
logger.important(f"connected lamindb: {settings.instance.slug}")
|
|
238
|
+
return None
|
|
239
|
+
else:
|
|
240
|
+
raise CannotSwitchDefaultInstance(
|
|
241
|
+
MESSAGE_CANNOT_SWITCH_DEFAULT_INSTANCE
|
|
242
|
+
)
|
|
243
|
+
elif (
|
|
244
|
+
_write_settings
|
|
245
|
+
and settings._instance_exists
|
|
246
|
+
and f"{owner}/{name}" != settings.instance.slug
|
|
229
247
|
):
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
248
|
+
close_instance(mute=True)
|
|
249
|
+
|
|
250
|
+
try:
|
|
251
|
+
isettings = _connect_instance(
|
|
252
|
+
owner, name, db=_db, access_token=access_token
|
|
235
253
|
)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
try:
|
|
244
|
-
isettings = _connect_instance(
|
|
245
|
-
owner, name, db=_db, access_token=access_token
|
|
246
|
-
)
|
|
247
|
-
except InstanceNotFoundError as e:
|
|
248
|
-
if _raise_not_found_error:
|
|
249
|
-
raise e
|
|
250
|
-
else:
|
|
251
|
-
return "instance-not-found"
|
|
252
|
-
if isinstance(isettings, str):
|
|
253
|
-
return isettings
|
|
254
|
+
except InstanceNotFoundError as e:
|
|
255
|
+
if _raise_not_found_error:
|
|
256
|
+
raise e
|
|
257
|
+
else:
|
|
258
|
+
return "instance-not-found"
|
|
259
|
+
if isinstance(isettings, str):
|
|
260
|
+
return isettings
|
|
254
261
|
# at this point we have checked already that isettings is not a string
|
|
255
|
-
# _user is passed to lock cloud
|
|
262
|
+
# _user is passed to lock cloud sqlite for this user in isettings._load_db()
|
|
256
263
|
# has no effect if _user is None or if not cloud sqlite instance
|
|
257
264
|
isettings._locker_user = _user
|
|
258
265
|
isettings._persist(write_to_disk=_write_settings)
|
|
@@ -304,6 +311,7 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
|
|
|
304
311
|
load_from_isettings(isettings, user=_user, write_settings=_write_settings)
|
|
305
312
|
if _reload_lamindb:
|
|
306
313
|
importlib.reload(importlib.import_module("lamindb"))
|
|
314
|
+
logger.important(f"connected lamindb: {isettings.slug}")
|
|
307
315
|
except Exception as e:
|
|
308
316
|
if isettings is not None:
|
|
309
317
|
if _write_settings:
|
|
@@ -331,6 +339,25 @@ def migrate_lnschema_core(
|
|
|
331
339
|
"""Migrate lnschema_core tables to lamindb tables."""
|
|
332
340
|
from urllib.parse import urlparse
|
|
333
341
|
|
|
342
|
+
if isettings.is_on_hub:
|
|
343
|
+
from lamindb_setup.core._hub_client import call_with_fallback_auth
|
|
344
|
+
from lamindb_setup.core._hub_crud import (
|
|
345
|
+
select_collaborator,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
# double check that user is an admin, otherwise will fail below
|
|
349
|
+
# due to insufficient SQL permissions with cryptic error
|
|
350
|
+
collaborator = call_with_fallback_auth(
|
|
351
|
+
select_collaborator,
|
|
352
|
+
instance_id=settings.instance._id,
|
|
353
|
+
account_id=settings.user._uuid,
|
|
354
|
+
)
|
|
355
|
+
if collaborator is None or collaborator["role"] != "admin":
|
|
356
|
+
raise SystemExit(
|
|
357
|
+
"❌ Only admins can deploy migrations, please ensure that you're an"
|
|
358
|
+
f" admin: https://lamin.ai/{settings.instance.slug}/settings"
|
|
359
|
+
)
|
|
360
|
+
|
|
334
361
|
parsed_uri = urlparse(isettings.db)
|
|
335
362
|
db_type = parsed_uri.scheme
|
|
336
363
|
|
|
@@ -381,7 +408,7 @@ def migrate_lnschema_core(
|
|
|
381
408
|
else:
|
|
382
409
|
try:
|
|
383
410
|
response = input(
|
|
384
|
-
f"Do you want to migrate to lamindb 0
|
|
411
|
+
f"Do you want to migrate to lamindb 1.0 (integrate lnschema_core into lamindb)? (y/n) -- Will rename {tables_to_rename}"
|
|
385
412
|
)
|
|
386
413
|
if response != "y":
|
|
387
414
|
print("Aborted.")
|
|
@@ -5,10 +5,7 @@ from importlib.metadata import entry_points
|
|
|
5
5
|
|
|
6
6
|
def call_registered_entry_points(group, **kwargs):
|
|
7
7
|
"""load and call entry points registered under group."""
|
|
8
|
-
|
|
9
|
-
eps = entry_points(group=group)
|
|
10
|
-
else:
|
|
11
|
-
eps = entry_points().get(group, [])
|
|
8
|
+
eps = entry_points(group=group)
|
|
12
9
|
|
|
13
10
|
for ep in eps:
|
|
14
11
|
func = ep.load()
|
|
@@ -5,7 +5,7 @@ from django.db.migrations.loader import MigrationLoader
|
|
|
5
5
|
from lamin_utils import logger
|
|
6
6
|
from packaging import version
|
|
7
7
|
|
|
8
|
-
from . import
|
|
8
|
+
from ._check_setup import _check_instance_setup, _loading
|
|
9
9
|
from .core._settings import settings
|
|
10
10
|
from .core.django import setup_django
|
|
11
11
|
|
|
@@ -23,9 +23,9 @@ def check_whether_migrations_in_sync(db_version_str: str):
|
|
|
23
23
|
return None
|
|
24
24
|
installed_version = version.parse(installed_version_str)
|
|
25
25
|
db_version = version.parse(db_version_str)
|
|
26
|
-
if (
|
|
27
|
-
installed_version.major
|
|
28
|
-
|
|
26
|
+
if installed_version.major < db_version.major or (
|
|
27
|
+
installed_version.major == db_version.major
|
|
28
|
+
and installed_version.minor < db_version.minor
|
|
29
29
|
):
|
|
30
30
|
db_version_lower = f"{db_version.major}.{db_version.minor}"
|
|
31
31
|
db_version_upper = f"{db_version.major}.{db_version.minor + 1}"
|
|
@@ -37,9 +37,9 @@ def check_whether_migrations_in_sync(db_version_str: str):
|
|
|
37
37
|
"please update lamindb: pip install"
|
|
38
38
|
f' "lamindb>={db_version_lower},<{db_version_upper}"'
|
|
39
39
|
)
|
|
40
|
-
elif (
|
|
41
|
-
installed_version.major
|
|
42
|
-
|
|
40
|
+
elif installed_version.major > db_version.major or (
|
|
41
|
+
installed_version.major == db_version.major
|
|
42
|
+
and installed_version.minor > db_version.minor
|
|
43
43
|
):
|
|
44
44
|
logger.warning(
|
|
45
45
|
f"the database ({db_version_str}) is behind your installed lamindb package"
|
|
@@ -62,20 +62,20 @@ class migrate:
|
|
|
62
62
|
"""
|
|
63
63
|
|
|
64
64
|
@classmethod
|
|
65
|
+
@_loading
|
|
65
66
|
def create(cls) -> None:
|
|
66
67
|
"""Create a migration."""
|
|
67
|
-
if
|
|
68
|
+
if _check_instance_setup():
|
|
68
69
|
raise RuntimeError("Restart Python session to create migration or use CLI!")
|
|
69
|
-
_check_setup.IS_LOADING = True
|
|
70
70
|
setup_django(settings.instance, create_migrations=True)
|
|
71
|
-
_check_setup.IS_LOADING = False
|
|
72
71
|
|
|
73
72
|
@classmethod
|
|
73
|
+
@_loading
|
|
74
74
|
def deploy(cls) -> None:
|
|
75
75
|
"""Deploy a migration."""
|
|
76
76
|
from ._schema_metadata import update_schema_in_hub
|
|
77
77
|
|
|
78
|
-
if
|
|
78
|
+
if _check_instance_setup():
|
|
79
79
|
raise RuntimeError("Restart Python session to migrate or use CLI!")
|
|
80
80
|
from lamindb_setup.core._hub_client import call_with_fallback_auth
|
|
81
81
|
from lamindb_setup.core._hub_crud import (
|
|
@@ -115,6 +115,7 @@ class migrate:
|
|
|
115
115
|
)
|
|
116
116
|
|
|
117
117
|
@classmethod
|
|
118
|
+
@_loading
|
|
118
119
|
def check(cls) -> bool:
|
|
119
120
|
"""Check whether Registry definitions are in sync with migrations."""
|
|
120
121
|
from django.core.management import call_command
|
|
@@ -131,6 +132,7 @@ class migrate:
|
|
|
131
132
|
return True
|
|
132
133
|
|
|
133
134
|
@classmethod
|
|
135
|
+
@_loading
|
|
134
136
|
def squash(
|
|
135
137
|
cls, package_name, migration_nr, start_migration_nr: str | None = None
|
|
136
138
|
) -> None:
|
|
@@ -146,6 +148,7 @@ class migrate:
|
|
|
146
148
|
call_command("squashmigrations", package_name, migration_nr)
|
|
147
149
|
|
|
148
150
|
@classmethod
|
|
151
|
+
@_loading
|
|
149
152
|
def show(cls) -> None:
|
|
150
153
|
"""Show migrations."""
|
|
151
154
|
from django.core.management import call_command
|
|
@@ -54,7 +54,8 @@ def setup_django(
|
|
|
54
54
|
|
|
55
55
|
module_names = ["core"] + list(isettings.modules)
|
|
56
56
|
raise_import_error = True if init else False
|
|
57
|
-
installed_apps = [
|
|
57
|
+
installed_apps = ["django.contrib.contenttypes"]
|
|
58
|
+
installed_apps += [
|
|
58
59
|
package_name
|
|
59
60
|
for name in module_names
|
|
60
61
|
if (
|
|
@@ -113,9 +114,7 @@ def setup_django(
|
|
|
113
114
|
elif init:
|
|
114
115
|
global IS_MIGRATING
|
|
115
116
|
IS_MIGRATING = True
|
|
116
|
-
call_command(
|
|
117
|
-
"migrate", verbosity=2
|
|
118
|
-
) # may change back to verbosity 0 in the future
|
|
117
|
+
call_command("migrate", verbosity=0)
|
|
119
118
|
IS_MIGRATING = False
|
|
120
119
|
|
|
121
120
|
global IS_SETUP
|
|
@@ -119,7 +119,7 @@ def hash_dir(path: Path):
|
|
|
119
119
|
hashes_sizes = pool.map(hash_size, files)
|
|
120
120
|
else:
|
|
121
121
|
hashes_sizes = map(hash_size, files)
|
|
122
|
-
hashes, sizes = zip(*hashes_sizes)
|
|
122
|
+
hashes, sizes = zip(*hashes_sizes, strict=False)
|
|
123
123
|
|
|
124
124
|
hash, hash_type = hash_from_hashes_list(hashes), "md5-d"
|
|
125
125
|
n_files = len(hashes)
|
|
@@ -549,7 +549,7 @@ def compute_file_tree(
|
|
|
549
549
|
pointers = [tee] * (len(contents) - 1) + [last]
|
|
550
550
|
n_files_per_dir_and_type = defaultdict(lambda: 0) # type: ignore
|
|
551
551
|
# TODO: pass strict=False to zip with python > 3.9
|
|
552
|
-
for pointer, child_path in zip(pointers, contents): # type: ignore
|
|
552
|
+
for pointer, child_path in zip(pointers, contents, strict=False): # type: ignore
|
|
553
553
|
if child_path.is_dir():
|
|
554
554
|
if include_dirs and child_path not in include_dirs:
|
|
555
555
|
continue
|
|
@@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lamindb_setup"
|
|
7
|
-
requires-python = ">=3.
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
8
|
authors = [{name = "Lamin Labs", email = "open-source@lamin.ai"}]
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
dynamic = ["version", "description"]
|
|
@@ -71,6 +71,9 @@ lint.select = [
|
|
|
71
71
|
"PTH" # Use pathlib
|
|
72
72
|
]
|
|
73
73
|
lint.ignore = [
|
|
74
|
+
# this needs to be refactored as we dropped 3.9
|
|
75
|
+
# todo: refactor types and remove this
|
|
76
|
+
"UP007",
|
|
74
77
|
# Do not catch blind exception: `Exception`
|
|
75
78
|
"BLE001",
|
|
76
79
|
# Errors from function calls in argument defaults. These are fine when the result is immutable.
|
|
@@ -10,12 +10,14 @@ from lamindb_setup.core._hub_crud import update_instance
|
|
|
10
10
|
from laminhub_rest.core.instance.collaborator import InstanceCollaboratorHandler
|
|
11
11
|
from postgrest.exceptions import APIError
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
|
|
14
|
+
def test_connect_pass_none():
|
|
15
|
+
with pytest.raises(SystemExit) as err:
|
|
16
|
+
ln_setup.connect(_test=True)
|
|
17
|
+
assert (
|
|
18
|
+
err.exconly()
|
|
19
|
+
== "SystemExit: No instance was connected through the CLI, pass a value to `instance` or connect via the CLI."
|
|
20
|
+
)
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
# do not call hub if the owner is set to anonymous
|
|
@@ -325,7 +325,10 @@ def test_connect_instance_hub_corrupted_or_expired_credentials(
|
|
|
325
325
|
create_myinstance, create_testadmin1_session
|
|
326
326
|
):
|
|
327
327
|
# assume token & password are corrupted or expired
|
|
328
|
-
|
|
328
|
+
# make realisticly looking token that passes
|
|
329
|
+
# supafunc is_valid_jwt but is actually not a real token
|
|
330
|
+
invalid_token = "header1.payload1.signature1"
|
|
331
|
+
ln_setup.settings.user.access_token = invalid_token
|
|
329
332
|
correct_password = ln_setup.settings.user.password
|
|
330
333
|
ln_setup.settings.user.password = "corrupted_password"
|
|
331
334
|
with pytest.raises(FunctionsHttpError):
|
|
@@ -336,7 +339,7 @@ def test_connect_instance_hub_corrupted_or_expired_credentials(
|
|
|
336
339
|
# now, let's assume only the token is expired or corrupted
|
|
337
340
|
# re-creating the auth client triggers a re-generated token because it
|
|
338
341
|
# excepts the error assuming the token is expired
|
|
339
|
-
ln_setup.settings.user.access_token =
|
|
342
|
+
ln_setup.settings.user.access_token = invalid_token
|
|
340
343
|
ln_setup.settings.user.password = correct_password
|
|
341
344
|
connect_instance_hub(
|
|
342
345
|
owner="testadmin1",
|
|
@@ -344,7 +347,7 @@ def test_connect_instance_hub_corrupted_or_expired_credentials(
|
|
|
344
347
|
)
|
|
345
348
|
# check access_token renewal
|
|
346
349
|
access_token = ln_setup.settings.user.access_token
|
|
347
|
-
assert access_token !=
|
|
350
|
+
assert access_token != invalid_token
|
|
348
351
|
# check that the access_token was written to the settings
|
|
349
352
|
ln_setup.settings._user_settings = None
|
|
350
353
|
assert ln_setup.settings.user.access_token == access_token
|
|
@@ -32,7 +32,7 @@ def test_progress_callback_size():
|
|
|
32
32
|
pcb.set_size(10)
|
|
33
33
|
|
|
34
34
|
cwd = str(Path.cwd())
|
|
35
|
-
paths = zip([cwd, cwd], [cwd, cwd])
|
|
35
|
+
paths = zip([cwd, cwd], [cwd, cwd], strict=False)
|
|
36
36
|
# adjust size for directories in path list
|
|
37
37
|
assert pcb.wrap(paths) == [(cwd, cwd), (cwd, cwd)]
|
|
38
38
|
assert pcb.size == 8
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/docs/hub-prod/test-init-load-local-anonymously.ipynb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lamindb_setup-1.0a5 → lamindb_setup-1.0.2}/tests/hub-cloud/test_init_pass_user_no_writes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|