lamindb_setup 1.8.2__tar.gz → 1.9.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.
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/PKG-INFO +1 -1
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/07-keep-artifacts-local.ipynb +2 -2
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/__init__.py +1 -1
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_check_setup.py +3 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_migrate.py +9 -2
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_aws_options.py +18 -10
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_hub_client.py +5 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_hub_core.py +6 -4
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_settings.py +19 -6
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_settings_instance.py +21 -5
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_settings_user.py +1 -1
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/django.py +7 -2
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/upath.py +6 -2
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-local/scripts/script-connect-fine-grained-access.py +11 -2
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-local/test_all.py +1 -1
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/.github/workflows/build.yml +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/.github/workflows/doc-changes.yml +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/.gitignore +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/.pre-commit-config.yaml +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/LICENSE +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/README.md +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/changelog.md +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/02-connect-local-instance.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/03-add-managed-storage.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/08-test-multi-session.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-cloud/test_notebooks.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-cache-management.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-cloud-sync.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-empty-init.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-import-schema.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-init-load-local-anonymously.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-insufficient-user-info.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/hub-prod/test_notebooks2.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/index.md +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/notebooks.md +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/docs/reference.md +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_cache.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_check.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_connect_instance.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_delete.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_disconnect.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_django.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_entry_points.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_exportdb.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_importdb.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_init_instance.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_register_instance.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_schema.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_schema_metadata.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_set_managed_storage.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_setup_user.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/_silence_loggers.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/__init__.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_aws_storage.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_deprecated.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_docs.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_hub_crud.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_hub_utils.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_private_django_api.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_settings_load.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_settings_save.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_settings_storage.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_settings_store.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/cloud_sqlite_locker.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/exceptions.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/hashing.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/core/types.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/errors.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/py.typed +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/lamindb_setup/types.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/noxfile.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/pyproject.toml +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_connect_instance.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_delete_instance.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_edge_request.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_init_instance.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_login.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_migrate.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-cloud/test_set_storage.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-local/conftest.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-local/test_update_schema_in_hub.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-prod/conftest.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-prod/test_aws_options_manager.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-prod/test_django.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-prod/test_global_settings.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-prod/test_switch_and_fallback_env.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/hub-prod/test_upath.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/storage/test_entry_point.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/storage/test_hashing.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/storage/test_storage_access.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/storage/test_storage_basis.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/storage/test_storage_settings.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/storage/test_storage_stats.py +0 -0
- {lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/tests/storage/test_to_url.py +0 -0
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
" ln_setup.settings.instance.local_storage\n",
|
|
49
49
|
"assert (\n",
|
|
50
50
|
" error.exconly()\n",
|
|
51
|
-
" == \"ValueError: `keep_artifacts_local` is
|
|
51
|
+
" == \"ValueError: `keep_artifacts_local` is False, switch via: ln.setup.settings.instance.keep_artifacts_local = True\"\n",
|
|
52
52
|
")"
|
|
53
53
|
]
|
|
54
54
|
},
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"metadata": {},
|
|
59
59
|
"outputs": [],
|
|
60
60
|
"source": [
|
|
61
|
-
"ln_setup.settings.instance.
|
|
61
|
+
"ln_setup.settings.instance.keep_artifacts_local = True\n",
|
|
62
62
|
"with pytest.raises(ValueError) as error:\n",
|
|
63
63
|
" ln_setup.settings.instance.local_storage\n",
|
|
64
64
|
"assert error.exconly().startswith(\n",
|
|
@@ -147,6 +147,9 @@ def _check_instance_setup(from_module: str | None = None) -> bool:
|
|
|
147
147
|
else:
|
|
148
148
|
django_lamin.setup_django(isettings)
|
|
149
149
|
logger.important(f"connected lamindb: {isettings.slug}")
|
|
150
|
+
settings._instance_settings = (
|
|
151
|
+
isettings # update of local storage location
|
|
152
|
+
)
|
|
150
153
|
return django_lamin.IS_SETUP
|
|
151
154
|
else:
|
|
152
155
|
if from_module is not None and settings.auto_connect:
|
|
@@ -86,7 +86,7 @@ class migrate:
|
|
|
86
86
|
|
|
87
87
|
@classmethod
|
|
88
88
|
@disable_auto_connect
|
|
89
|
-
def deploy(cls) -> None:
|
|
89
|
+
def deploy(cls, package_name: str | None = None, number: int | None = None) -> None:
|
|
90
90
|
"""Deploy a migration."""
|
|
91
91
|
from ._schema_metadata import update_schema_in_hub
|
|
92
92
|
|
|
@@ -116,7 +116,14 @@ class migrate:
|
|
|
116
116
|
import lamindb
|
|
117
117
|
|
|
118
118
|
# this sets up django and deploys the migrations
|
|
119
|
-
|
|
119
|
+
if package_name is not None and number is not None:
|
|
120
|
+
setup_django(
|
|
121
|
+
settings.instance,
|
|
122
|
+
deploy_migrations=True,
|
|
123
|
+
appname_number=(package_name, number),
|
|
124
|
+
)
|
|
125
|
+
else:
|
|
126
|
+
setup_django(settings.instance, deploy_migrations=True)
|
|
120
127
|
# this populates the hub
|
|
121
128
|
if settings.instance.is_on_hub:
|
|
122
129
|
logger.important(f"updating lamindb version in hub: {lamindb.__version__}")
|
|
@@ -22,7 +22,7 @@ else:
|
|
|
22
22
|
HOSTED_BUCKETS = ("s3://lamin-hosted-test",) # type: ignore
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def _keep_trailing_slash(path_str: str):
|
|
25
|
+
def _keep_trailing_slash(path_str: str) -> str:
|
|
26
26
|
return path_str if path_str[-1] == "/" else path_str + "/"
|
|
27
27
|
|
|
28
28
|
|
|
@@ -54,6 +54,7 @@ class AWSOptionsManager:
|
|
|
54
54
|
|
|
55
55
|
def __init__(self):
|
|
56
56
|
self._credentials_cache = {}
|
|
57
|
+
self._parameters_cache = {} # this is not refreshed
|
|
57
58
|
|
|
58
59
|
from s3fs import S3FileSystem
|
|
59
60
|
|
|
@@ -106,7 +107,9 @@ class AWSOptionsManager:
|
|
|
106
107
|
def _get_cached_credentials(self, root: str) -> dict:
|
|
107
108
|
return self._credentials_cache[root]["credentials"]
|
|
108
109
|
|
|
109
|
-
def _path_inject_options(
|
|
110
|
+
def _path_inject_options(
|
|
111
|
+
self, path: UPath, credentials: dict, extra_parameters: dict | None = None
|
|
112
|
+
) -> UPath:
|
|
110
113
|
if credentials == {}:
|
|
111
114
|
# credentials were specified manually for the path
|
|
112
115
|
if "anon" in path.storage_options:
|
|
@@ -137,6 +140,9 @@ class AWSOptionsManager:
|
|
|
137
140
|
"version_aware", False
|
|
138
141
|
)
|
|
139
142
|
|
|
143
|
+
if extra_parameters:
|
|
144
|
+
connection_options.update(extra_parameters)
|
|
145
|
+
|
|
140
146
|
return UPath(path, **connection_options)
|
|
141
147
|
|
|
142
148
|
def enrich_path(self, path: UPath, access_token: str | None = None) -> UPath:
|
|
@@ -158,7 +164,7 @@ class AWSOptionsManager:
|
|
|
158
164
|
if root is not None:
|
|
159
165
|
set_cache = False
|
|
160
166
|
credentials = self._get_cached_credentials(root)
|
|
161
|
-
|
|
167
|
+
extra_parameters = self._parameters_cache.get(root)
|
|
162
168
|
if access_token is not None:
|
|
163
169
|
set_cache = True
|
|
164
170
|
elif credentials != {}:
|
|
@@ -172,17 +178,15 @@ class AWSOptionsManager:
|
|
|
172
178
|
from ._hub_core import access_aws
|
|
173
179
|
from ._settings import settings
|
|
174
180
|
|
|
175
|
-
|
|
176
|
-
storage_root_info = access_aws(path_str, access_token=access_token)
|
|
177
|
-
else:
|
|
178
|
-
storage_root_info = {"credentials": {}, "accessibility": {}}
|
|
179
|
-
|
|
181
|
+
storage_root_info = access_aws(path_str, access_token=access_token)
|
|
180
182
|
accessibility = storage_root_info["accessibility"]
|
|
181
183
|
is_managed = accessibility.get("is_managed", False)
|
|
182
184
|
if is_managed:
|
|
183
185
|
credentials = storage_root_info["credentials"]
|
|
186
|
+
extra_parameters = accessibility["extra_parameters"]
|
|
184
187
|
else:
|
|
185
188
|
credentials = {}
|
|
189
|
+
extra_parameters = None
|
|
186
190
|
|
|
187
191
|
if access_token is None:
|
|
188
192
|
if "storage_root" in accessibility:
|
|
@@ -198,9 +202,13 @@ class AWSOptionsManager:
|
|
|
198
202
|
# write the bucket for everything else
|
|
199
203
|
root = path.drive
|
|
200
204
|
root = "s3://" + root
|
|
201
|
-
self._set_cached_credentials(_keep_trailing_slash(root), credentials)
|
|
202
205
|
|
|
203
|
-
|
|
206
|
+
root = _keep_trailing_slash(root)
|
|
207
|
+
assert isinstance(root, str)
|
|
208
|
+
self._set_cached_credentials(root, credentials)
|
|
209
|
+
self._parameters_cache[root] = extra_parameters
|
|
210
|
+
|
|
211
|
+
return self._path_inject_options(path, credentials, extra_parameters)
|
|
204
212
|
|
|
205
213
|
|
|
206
214
|
_aws_options_manager: AWSOptionsManager | None = None
|
|
@@ -124,6 +124,11 @@ def get_access_token(
|
|
|
124
124
|
}
|
|
125
125
|
)
|
|
126
126
|
return auth_response.session.access_token
|
|
127
|
+
except Exception as e:
|
|
128
|
+
# we need to log the problem here because the exception is usually caught outside
|
|
129
|
+
# in call_with_fallback_auth
|
|
130
|
+
logger.warning(f"failed to update your lamindb access token: {e}")
|
|
131
|
+
raise e
|
|
127
132
|
finally:
|
|
128
133
|
hub.auth.sign_out(options={"scope": "local"})
|
|
129
134
|
|
|
@@ -460,9 +460,9 @@ def access_aws(storage_root: str, access_token: str | None = None) -> dict[str,
|
|
|
460
460
|
storage_root_info = call_with_fallback_auth(
|
|
461
461
|
_access_aws, storage_root=storage_root, access_token=access_token
|
|
462
462
|
)
|
|
463
|
-
return storage_root_info
|
|
464
463
|
else:
|
|
465
|
-
|
|
464
|
+
storage_root_info = call_with_fallback(_access_aws, storage_root=storage_root)
|
|
465
|
+
return storage_root_info
|
|
466
466
|
|
|
467
467
|
|
|
468
468
|
def _access_aws(*, storage_root: str, client: Client) -> dict[str, dict]:
|
|
@@ -487,6 +487,8 @@ def _access_aws(*, storage_root: str, client: Client) -> dict[str, dict]:
|
|
|
487
487
|
accessibility = storage_root_info["accessibility"]
|
|
488
488
|
accessibility["storage_root"] = loaded_accessibility["storageRoot"]
|
|
489
489
|
accessibility["is_managed"] = loaded_accessibility["isManaged"]
|
|
490
|
+
accessibility["extra_parameters"] = loaded_accessibility.get("extraParameters")
|
|
491
|
+
|
|
490
492
|
return storage_root_info
|
|
491
493
|
|
|
492
494
|
|
|
@@ -497,8 +499,8 @@ def access_db(
|
|
|
497
499
|
instance_slug: str
|
|
498
500
|
instance_api_url: str | None
|
|
499
501
|
if (
|
|
500
|
-
"
|
|
501
|
-
and (env_db_token := os.environ["
|
|
502
|
+
"LAMIN_DB_TOKEN" in os.environ
|
|
503
|
+
and (env_db_token := os.environ["LAMIN_DB_TOKEN"]) != ""
|
|
502
504
|
):
|
|
503
505
|
return env_db_token
|
|
504
506
|
|
|
@@ -60,6 +60,9 @@ class SetupSettings:
|
|
|
60
60
|
|
|
61
61
|
_cache_dir: Path | None = None
|
|
62
62
|
|
|
63
|
+
_branch = None # do not have types here
|
|
64
|
+
_space = None # do not have types here
|
|
65
|
+
|
|
63
66
|
@property
|
|
64
67
|
def _instance_settings_path(self) -> Path:
|
|
65
68
|
return current_instance_settings_file()
|
|
@@ -112,12 +115,16 @@ class SetupSettings:
|
|
|
112
115
|
return idlike, name
|
|
113
116
|
|
|
114
117
|
@property
|
|
118
|
+
# TODO: refactor so that it returns a BranchMock object
|
|
119
|
+
# and we never need a DB request
|
|
115
120
|
def branch(self) -> Branch:
|
|
116
121
|
"""Default branch."""
|
|
117
|
-
|
|
122
|
+
if self._branch is None:
|
|
123
|
+
from lamindb import Branch
|
|
118
124
|
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
idlike, _ = self._read_branch_idlike_name()
|
|
126
|
+
self._branch = Branch.get(idlike)
|
|
127
|
+
return self._branch
|
|
121
128
|
|
|
122
129
|
@branch.setter
|
|
123
130
|
def branch(self, value: str | Branch) -> None:
|
|
@@ -136,6 +143,7 @@ class SetupSettings:
|
|
|
136
143
|
# we are sure that the current instance is setup because
|
|
137
144
|
# it will error on lamindb import otherwise
|
|
138
145
|
self._branch_path.write_text(f"{branch_record.uid}\n{branch_record.name}")
|
|
146
|
+
self._branch = branch_record
|
|
139
147
|
|
|
140
148
|
@property
|
|
141
149
|
def _space_path(self) -> Path:
|
|
@@ -156,12 +164,16 @@ class SetupSettings:
|
|
|
156
164
|
return idlike, name
|
|
157
165
|
|
|
158
166
|
@property
|
|
167
|
+
# TODO: refactor so that it returns a BranchMock object
|
|
168
|
+
# and we never need a DB request
|
|
159
169
|
def space(self) -> Space:
|
|
160
170
|
"""Default space."""
|
|
161
|
-
|
|
171
|
+
if self._space is None:
|
|
172
|
+
from lamindb import Space
|
|
162
173
|
|
|
163
|
-
|
|
164
|
-
|
|
174
|
+
idlike, _ = self._read_space_idlike_name()
|
|
175
|
+
self._space = Space.get(idlike)
|
|
176
|
+
return self._space
|
|
165
177
|
|
|
166
178
|
@space.setter
|
|
167
179
|
def space(self, value: str | Space) -> None:
|
|
@@ -180,6 +192,7 @@ class SetupSettings:
|
|
|
180
192
|
# we are sure that the current instance is setup because
|
|
181
193
|
# it will error on lamindb import otherwise
|
|
182
194
|
self._space_path.write_text(f"{space_record.uid}\n{space_record.name}")
|
|
195
|
+
self._space = space_record
|
|
183
196
|
|
|
184
197
|
@property
|
|
185
198
|
def is_connected(self) -> bool:
|
|
@@ -104,8 +104,20 @@ class InstanceSettings:
|
|
|
104
104
|
for attr in attrs:
|
|
105
105
|
value = getattr(self, attr)
|
|
106
106
|
if attr == "storage":
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
if self.keep_artifacts_local:
|
|
108
|
+
import lamindb as ln
|
|
109
|
+
|
|
110
|
+
self._local_storage = ln.setup.settings.instance._local_storage
|
|
111
|
+
if self._local_storage is not None:
|
|
112
|
+
value_local = self.local_storage
|
|
113
|
+
representation += f"\n - local storage: {value_local.root_as_str} ({value_local.region})"
|
|
114
|
+
representation += (
|
|
115
|
+
f"\n - cloud storage: {value.root_as_str} ({value.region})"
|
|
116
|
+
)
|
|
117
|
+
else:
|
|
118
|
+
representation += (
|
|
119
|
+
f"\n - storage: {value.root_as_str} ({value.region})"
|
|
120
|
+
)
|
|
109
121
|
elif attr == "db":
|
|
110
122
|
if self.dialect != "sqlite":
|
|
111
123
|
model = LaminDsnModel(db=value)
|
|
@@ -174,9 +186,10 @@ class InstanceSettings:
|
|
|
174
186
|
)
|
|
175
187
|
legacy_filepath.rename(marker_path)
|
|
176
188
|
else:
|
|
177
|
-
|
|
189
|
+
logger.warning(
|
|
178
190
|
f"local storage location '{root_path}' is corrupted, cannot find marker file with storage uid"
|
|
179
191
|
)
|
|
192
|
+
continue
|
|
180
193
|
try:
|
|
181
194
|
uid = marker_path.read_text().splitlines()[0]
|
|
182
195
|
except PermissionError:
|
|
@@ -190,8 +203,9 @@ class InstanceSettings:
|
|
|
190
203
|
if len(found) > 1:
|
|
191
204
|
found_display = "\n - ".join([f"{record.root}" for record in found])
|
|
192
205
|
logger.important(f"found locations:\n - {found_display}")
|
|
206
|
+
record = found[0]
|
|
193
207
|
logger.important(f"defaulting to local storage: {record.root}")
|
|
194
|
-
return StorageSettings(record.root)
|
|
208
|
+
return StorageSettings(record.root, region=record.region)
|
|
195
209
|
elif not mute_warning:
|
|
196
210
|
start = LOCAL_STORAGE_MESSAGE[0].lower()
|
|
197
211
|
logger.warning(f"{start}{LOCAL_STORAGE_MESSAGE[1:]}")
|
|
@@ -229,7 +243,9 @@ class InstanceSettings:
|
|
|
229
243
|
Guide: :doc:`faq/keep-artifacts-local`
|
|
230
244
|
"""
|
|
231
245
|
if not self.keep_artifacts_local:
|
|
232
|
-
raise ValueError(
|
|
246
|
+
raise ValueError(
|
|
247
|
+
"`keep_artifacts_local` is False, switch via: ln.setup.settings.instance.keep_artifacts_local = True"
|
|
248
|
+
)
|
|
233
249
|
if self._local_storage is None:
|
|
234
250
|
self._local_storage = self._search_local_root()
|
|
235
251
|
if self._local_storage is None:
|
|
@@ -39,7 +39,7 @@ class UserSettings:
|
|
|
39
39
|
def __repr__(self) -> str:
|
|
40
40
|
"""Rich string representation."""
|
|
41
41
|
representation = "Current user:"
|
|
42
|
-
attrs = ["handle", "
|
|
42
|
+
attrs = ["handle", "uid"]
|
|
43
43
|
for attr in attrs:
|
|
44
44
|
value = getattr(self, attr)
|
|
45
45
|
representation += f"\n - {attr}: {value}"
|
|
@@ -148,6 +148,7 @@ def setup_django(
|
|
|
148
148
|
configure_only: bool = False,
|
|
149
149
|
init: bool = False,
|
|
150
150
|
view_schema: bool = False,
|
|
151
|
+
appname_number: tuple[str, int] | None = None,
|
|
151
152
|
):
|
|
152
153
|
if IS_RUN_FROM_IPYTHON:
|
|
153
154
|
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
|
|
@@ -235,7 +236,11 @@ def setup_django(
|
|
|
235
236
|
return None
|
|
236
237
|
|
|
237
238
|
if deploy_migrations:
|
|
238
|
-
|
|
239
|
+
if appname_number is None:
|
|
240
|
+
call_command("migrate", verbosity=2)
|
|
241
|
+
else:
|
|
242
|
+
app_name, app_number = appname_number
|
|
243
|
+
call_command("migrate", app_name, app_number, verbosity=2)
|
|
239
244
|
isettings._update_cloud_sqlite_file(unlock_cloud_sqlite=False)
|
|
240
245
|
elif init:
|
|
241
246
|
global IS_MIGRATING
|
|
@@ -247,7 +252,7 @@ def setup_django(
|
|
|
247
252
|
IS_SETUP = True
|
|
248
253
|
|
|
249
254
|
if isettings.keep_artifacts_local:
|
|
250
|
-
isettings._search_local_root()
|
|
255
|
+
isettings._local_storage = isettings._search_local_root()
|
|
251
256
|
|
|
252
257
|
|
|
253
258
|
# THIS IS NOT SAFE
|
|
@@ -393,8 +393,10 @@ def synchronize_to(
|
|
|
393
393
|
"""Sync to a local destination path."""
|
|
394
394
|
destination = destination.resolve()
|
|
395
395
|
protocol = origin.protocol
|
|
396
|
+
stat_kwargs = {"expand_info": True} if protocol == "hf" else {}
|
|
397
|
+
origin_str = str(origin)
|
|
396
398
|
try:
|
|
397
|
-
cloud_info = origin.stat()
|
|
399
|
+
cloud_info = origin.fs.stat(origin_str, **stat_kwargs)
|
|
398
400
|
exists = True
|
|
399
401
|
is_dir = cloud_info["type"] == "directory"
|
|
400
402
|
except FileNotFoundError:
|
|
@@ -441,7 +443,9 @@ def synchronize_to(
|
|
|
441
443
|
if is_dir:
|
|
442
444
|
cloud_stats = {
|
|
443
445
|
file: get_modified(stat)
|
|
444
|
-
for file, stat in origin.fs.find(
|
|
446
|
+
for file, stat in origin.fs.find(
|
|
447
|
+
origin_str, detail=True, **stat_kwargs
|
|
448
|
+
).items()
|
|
445
449
|
}
|
|
446
450
|
for cloud_path in cloud_stats:
|
|
447
451
|
file_key = PurePosixPath(cloud_path).relative_to(origin.path).as_posix()
|
|
@@ -13,6 +13,15 @@ ln_setup.connect("instance_test__access_v2")
|
|
|
13
13
|
|
|
14
14
|
isettings = ln_setup.settings.instance
|
|
15
15
|
|
|
16
|
+
# check extra parameters for s3 managed buckets
|
|
17
|
+
# this is populated by create_instance imported from laminhub
|
|
18
|
+
assert (
|
|
19
|
+
isettings.storage.root.storage_options["s3_additional_kwargs"][
|
|
20
|
+
"ServerSideEncryption"
|
|
21
|
+
]
|
|
22
|
+
== "AES256"
|
|
23
|
+
)
|
|
24
|
+
|
|
16
25
|
assert isettings._fine_grained_access
|
|
17
26
|
assert isettings._db_permissions == "jwt"
|
|
18
27
|
assert isettings._api_url is not None
|
|
@@ -52,5 +61,5 @@ with pytest.raises(RuntimeError):
|
|
|
52
61
|
# check with providing access_token explicitly
|
|
53
62
|
access_db(isettings, ln_setup.settings.user.access_token)
|
|
54
63
|
# check specifying an env token via an env variable
|
|
55
|
-
os.environ["
|
|
56
|
-
assert access_db(isettings) == os.environ["
|
|
64
|
+
os.environ["LAMIN_DB_TOKEN"] = "test_db_token"
|
|
65
|
+
assert access_db(isettings) == os.environ["LAMIN_DB_TOKEN"]
|
|
@@ -182,7 +182,7 @@ def create_myinstance(create_testadmin1_session): # -> Dict
|
|
|
182
182
|
def create_instance_fine_grained_access(create_testadmin1_session):
|
|
183
183
|
client, _ = create_testadmin1_session
|
|
184
184
|
|
|
185
|
-
instance = create_instance("instance_test", client=client)
|
|
185
|
+
instance = create_instance("instance_test", client=client, connect=False)
|
|
186
186
|
|
|
187
187
|
yield instance
|
|
188
188
|
|
|
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.8.2 → lamindb_setup-1.9.0}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lamindb_setup-1.8.2 → lamindb_setup-1.9.0}/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
|
|
File without changes
|
|
File without changes
|