lamindb_setup 1.8.3__py3-none-any.whl → 1.9.0__py3-none-any.whl
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/__init__.py +1 -1
- lamindb_setup/_migrate.py +9 -2
- lamindb_setup/core/_aws_options.py +17 -5
- lamindb_setup/core/_hub_client.py +5 -0
- lamindb_setup/core/_hub_core.py +2 -0
- lamindb_setup/core/_settings.py +19 -6
- lamindb_setup/core/_settings_instance.py +2 -1
- lamindb_setup/core/django.py +6 -1
- lamindb_setup/core/upath.py +6 -2
- {lamindb_setup-1.8.3.dist-info → lamindb_setup-1.9.0.dist-info}/METADATA +1 -1
- {lamindb_setup-1.8.3.dist-info → lamindb_setup-1.9.0.dist-info}/RECORD +13 -13
- {lamindb_setup-1.8.3.dist-info → lamindb_setup-1.9.0.dist-info}/LICENSE +0 -0
- {lamindb_setup-1.8.3.dist-info → lamindb_setup-1.9.0.dist-info}/WHEEL +0 -0
lamindb_setup/__init__.py
CHANGED
lamindb_setup/_migrate.py
CHANGED
|
@@ -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 != {}:
|
|
@@ -177,8 +183,10 @@ class AWSOptionsManager:
|
|
|
177
183
|
is_managed = accessibility.get("is_managed", False)
|
|
178
184
|
if is_managed:
|
|
179
185
|
credentials = storage_root_info["credentials"]
|
|
186
|
+
extra_parameters = accessibility["extra_parameters"]
|
|
180
187
|
else:
|
|
181
188
|
credentials = {}
|
|
189
|
+
extra_parameters = None
|
|
182
190
|
|
|
183
191
|
if access_token is None:
|
|
184
192
|
if "storage_root" in accessibility:
|
|
@@ -194,9 +202,13 @@ class AWSOptionsManager:
|
|
|
194
202
|
# write the bucket for everything else
|
|
195
203
|
root = path.drive
|
|
196
204
|
root = "s3://" + root
|
|
197
|
-
self._set_cached_credentials(_keep_trailing_slash(root), credentials)
|
|
198
205
|
|
|
199
|
-
|
|
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)
|
|
200
212
|
|
|
201
213
|
|
|
202
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
|
|
lamindb_setup/core/_hub_core.py
CHANGED
|
@@ -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
|
|
lamindb_setup/core/_settings.py
CHANGED
|
@@ -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:
|
|
@@ -186,9 +186,10 @@ class InstanceSettings:
|
|
|
186
186
|
)
|
|
187
187
|
legacy_filepath.rename(marker_path)
|
|
188
188
|
else:
|
|
189
|
-
|
|
189
|
+
logger.warning(
|
|
190
190
|
f"local storage location '{root_path}' is corrupted, cannot find marker file with storage uid"
|
|
191
191
|
)
|
|
192
|
+
continue
|
|
192
193
|
try:
|
|
193
194
|
uid = marker_path.read_text().splitlines()[0]
|
|
194
195
|
except PermissionError:
|
lamindb_setup/core/django.py
CHANGED
|
@@ -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
|
lamindb_setup/core/upath.py
CHANGED
|
@@ -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()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
lamindb_setup/__init__.py,sha256=
|
|
1
|
+
lamindb_setup/__init__.py,sha256=Jbjaf2q8Kw_0mAn3bdeDDIxcH4BcJFFFj2AmGWVOlsc,2782
|
|
2
2
|
lamindb_setup/_cache.py,sha256=5o749NuW6zi6uP4rmBtwxg7ifWpAHXVngzC0tEgXLgo,2776
|
|
3
3
|
lamindb_setup/_check.py,sha256=28PcG8Kp6OpjSLSi1r2boL2Ryeh6xkaCL87HFbjs6GA,129
|
|
4
4
|
lamindb_setup/_check_setup.py,sha256=eeg7Vr7tUaTDObxq1X7J3TDPQZeitb_Uy6dxqa9xfzs,5707
|
|
@@ -10,7 +10,7 @@ lamindb_setup/_entry_points.py,sha256=sKwXPX9xjOotoAjvgkU5LBwjjHLWVkh0ZGdiSsrch9
|
|
|
10
10
|
lamindb_setup/_exportdb.py,sha256=QLjoH4dEwqa01A12naKaDPglCCzl2_VLKWFfJRE_uSg,2113
|
|
11
11
|
lamindb_setup/_importdb.py,sha256=fKv9ev5OOj_-bmzC8XZ1GxOcjIjI486yrHSHDWQrJeI,1874
|
|
12
12
|
lamindb_setup/_init_instance.py,sha256=jNNE7ZWIl1V28YqfdbaiyZ_One6K2vv0RMubxdvvb74,15320
|
|
13
|
-
lamindb_setup/_migrate.py,sha256=
|
|
13
|
+
lamindb_setup/_migrate.py,sha256=lkbEa_4qLxrQYSrLWKbXYQW32Yb1MBUa2hdfxCHnKUA,10047
|
|
14
14
|
lamindb_setup/_register_instance.py,sha256=zmk7UrOF6qED_zTEaTM8GbZurMSP1SwddkRy7rpYmUY,1215
|
|
15
15
|
lamindb_setup/_schema.py,sha256=b3uzhhWpV5mQtDwhMINc2MabGCnGLESy51ito3yl6Wc,679
|
|
16
16
|
lamindb_setup/_schema_metadata.py,sha256=yMSuLZc-7iWUV7tETNuKmcDeMW0wtUr5ypKxsKC-m7k,14898
|
|
@@ -21,17 +21,17 @@ lamindb_setup/errors.py,sha256=H1UM-bii0U2vPyjprOBgZK4ijZJgzgCViyGWPd8v5yU,1493
|
|
|
21
21
|
lamindb_setup/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
lamindb_setup/types.py,sha256=XlXLb4nmbc68uBj5Hp3xpDRezYGJIBZv6jAAqqN0p10,614
|
|
23
23
|
lamindb_setup/core/__init__.py,sha256=5M4A6CVHBO_T5Rr9MeLaPW3WTk4-y00cgRYEgUJVU5U,410
|
|
24
|
-
lamindb_setup/core/_aws_options.py,sha256=
|
|
24
|
+
lamindb_setup/core/_aws_options.py,sha256=UbwnaEX2KcZBDOa2W2NbH62cNrKJQ78Hrn7zcszhQvU,8092
|
|
25
25
|
lamindb_setup/core/_aws_storage.py,sha256=nEjeUv4xUVpoV0Lx-zjjmyb9w804bDyaeiM-OqbfwM0,1799
|
|
26
26
|
lamindb_setup/core/_deprecated.py,sha256=HN7iUBdEgahw5e4NHCd1VJooUfieNb6GRzS5x8jU-q8,2549
|
|
27
27
|
lamindb_setup/core/_docs.py,sha256=3k-YY-oVaJd_9UIY-LfBg_u8raKOCNfkZQPA73KsUhs,276
|
|
28
|
-
lamindb_setup/core/_hub_client.py,sha256=
|
|
29
|
-
lamindb_setup/core/_hub_core.py,sha256=
|
|
28
|
+
lamindb_setup/core/_hub_client.py,sha256=Pl3sEG2rasdJp4Rh5HNY0VsPVls-nfY0OxD5QzrYF9A,8678
|
|
29
|
+
lamindb_setup/core/_hub_core.py,sha256=eOz7JcdpUz50BYkuOJDkdqnnBgXbamB-erLl1mAut0c,24006
|
|
30
30
|
lamindb_setup/core/_hub_crud.py,sha256=Jz0d8wFKM1Pv9B9byyUJPlCIMkIzk56Jd-c3Awpm9Xw,5730
|
|
31
31
|
lamindb_setup/core/_hub_utils.py,sha256=6dyDGyzYFgVfR_lE3VN3CP1jGp98gxPtr-T91PAP05U,2687
|
|
32
32
|
lamindb_setup/core/_private_django_api.py,sha256=By63l3vIEtK1pq246FhHq3tslxsaTJGKm5VakYluWp4,2656
|
|
33
|
-
lamindb_setup/core/_settings.py,sha256=
|
|
34
|
-
lamindb_setup/core/_settings_instance.py,sha256=
|
|
33
|
+
lamindb_setup/core/_settings.py,sha256=tCYkTwNRnxmgApmN5m9cjoBn4NBB5ZafS0cUVA1ipNM,13464
|
|
34
|
+
lamindb_setup/core/_settings_instance.py,sha256=kkTbtOrezfZ97rXkyX8JvxVQxy2H6DSenmaAy9XoOS8,21900
|
|
35
35
|
lamindb_setup/core/_settings_load.py,sha256=JWd0_hBy04xjKo-tH4y8C9RkaywjrmoT0PsKzVme0n4,5176
|
|
36
36
|
lamindb_setup/core/_settings_save.py,sha256=XZx-vow7BT6y3JpRBB2UOJp2vwc7jOGea4wSgOPqjPU,3262
|
|
37
37
|
lamindb_setup/core/_settings_storage.py,sha256=S9AvKLzJX0M_RsYcBKZB_P84CYtTY0hyeffYE3UqrQA,15478
|
|
@@ -39,12 +39,12 @@ lamindb_setup/core/_settings_store.py,sha256=QmeWIGdIyq7UmjfHiEB_0xRD8hY-8-ZR2Wn
|
|
|
39
39
|
lamindb_setup/core/_settings_user.py,sha256=gFfyMf-738onbh1Mf4wsmLlenQJPtjQfpUgKnOlqc2o,1453
|
|
40
40
|
lamindb_setup/core/_setup_bionty_sources.py,sha256=ox3X-SHiHa2lNPSWjwZhINypbLacX6kGwH6hVVrSFZc,1505
|
|
41
41
|
lamindb_setup/core/cloud_sqlite_locker.py,sha256=H_CTUCjURFXwD1cCtV_Jn0_60iztZTkaesLLXIBgIxc,7204
|
|
42
|
-
lamindb_setup/core/django.py,sha256=
|
|
42
|
+
lamindb_setup/core/django.py,sha256=jDwNJ3ZtkYezzNTGEW9NQZRwspc0akWQnCFWTgu3c1Q,9889
|
|
43
43
|
lamindb_setup/core/exceptions.py,sha256=qjMzqy_uzPA7mCOdnoWnS_fdA6OWbdZGftz-YYplrY0,84
|
|
44
44
|
lamindb_setup/core/hashing.py,sha256=Y8Uc5uSGTfU6L2R_gb5w8DdHhGRog7RnkK-e9FEMjPY,3680
|
|
45
45
|
lamindb_setup/core/types.py,sha256=T7NwspfRHgIIpYsXDcApks8jkOlGeGRW-YbVLB7jNIo,67
|
|
46
|
-
lamindb_setup/core/upath.py,sha256=
|
|
47
|
-
lamindb_setup-1.
|
|
48
|
-
lamindb_setup-1.
|
|
49
|
-
lamindb_setup-1.
|
|
50
|
-
lamindb_setup-1.
|
|
46
|
+
lamindb_setup/core/upath.py,sha256=reRwNJUOdeZ5n9m7Xi7RoNjmw0kqMPq_BkLPq6_fg-g,35468
|
|
47
|
+
lamindb_setup-1.9.0.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
|
|
48
|
+
lamindb_setup-1.9.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
|
49
|
+
lamindb_setup-1.9.0.dist-info/METADATA,sha256=OmqlVQmuG8Iu_h9rPsfCgdfSo_6jH2aZJwq5jl6haH4,1797
|
|
50
|
+
lamindb_setup-1.9.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|