lamindb_setup 0.71.3__py2.py3-none-any.whl → 0.71.4__py2.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/_connect_instance.py +78 -61
- lamindb_setup/_delete.py +6 -46
- lamindb_setup/_init_instance.py +18 -17
- lamindb_setup/_set_managed_storage.py +4 -0
- lamindb_setup/core/_hub_core.py +5 -3
- lamindb_setup/core/_settings_instance.py +3 -12
- lamindb_setup/core/_settings_storage.py +10 -1
- lamindb_setup/core/hashing.py +23 -20
- {lamindb_setup-0.71.3.dist-info → lamindb_setup-0.71.4.dist-info}/METADATA +1 -1
- {lamindb_setup-0.71.3.dist-info → lamindb_setup-0.71.4.dist-info}/RECORD +13 -13
- {lamindb_setup-0.71.3.dist-info → lamindb_setup-0.71.4.dist-info}/LICENSE +0 -0
- {lamindb_setup-0.71.3.dist-info → lamindb_setup-0.71.4.dist-info}/WHEEL +0 -0
lamindb_setup/__init__.py
CHANGED
|
@@ -55,7 +55,10 @@ def check_db_dsn_equal_up_to_credentials(db_dsn_hub, db_dsn_local):
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
def update_db_using_local(
|
|
58
|
-
hub_instance_result: dict[str, str],
|
|
58
|
+
hub_instance_result: dict[str, str],
|
|
59
|
+
settings_file: Path,
|
|
60
|
+
db: str | None = None,
|
|
61
|
+
raise_permission_error=True,
|
|
59
62
|
) -> str | None:
|
|
60
63
|
db_updated = None
|
|
61
64
|
# check if postgres
|
|
@@ -77,7 +80,11 @@ def update_db_using_local(
|
|
|
77
80
|
db_dsn_local = LaminDsnModel(db=isettings.db)
|
|
78
81
|
else:
|
|
79
82
|
# just take the default hub result and ensure there is actually a user
|
|
80
|
-
if
|
|
83
|
+
if (
|
|
84
|
+
db_dsn_hub.db.user == "none"
|
|
85
|
+
and db_dsn_hub.db.password == "none"
|
|
86
|
+
and raise_permission_error
|
|
87
|
+
):
|
|
81
88
|
raise PermissionError(
|
|
82
89
|
"No database access, please ask your admin to provide you with"
|
|
83
90
|
" a DB URL and pass it via --db <db_url>"
|
|
@@ -101,6 +108,65 @@ def update_db_using_local(
|
|
|
101
108
|
return db_updated
|
|
102
109
|
|
|
103
110
|
|
|
111
|
+
def _connect_instance(
|
|
112
|
+
owner: str,
|
|
113
|
+
name: str,
|
|
114
|
+
*,
|
|
115
|
+
db: str | None = None,
|
|
116
|
+
raise_permission_error: bool = True,
|
|
117
|
+
) -> InstanceSettings:
|
|
118
|
+
settings_file = instance_settings_file(name, owner)
|
|
119
|
+
make_hub_request = True
|
|
120
|
+
if settings_file.exists():
|
|
121
|
+
isettings = load_instance_settings(settings_file)
|
|
122
|
+
# skip hub request for a purely local instance
|
|
123
|
+
make_hub_request = isettings.is_remote
|
|
124
|
+
if make_hub_request:
|
|
125
|
+
# the following will return a string if the instance does not exist
|
|
126
|
+
# on the hub
|
|
127
|
+
hub_result = load_instance_from_hub(owner=owner, name=name)
|
|
128
|
+
# if hub_result is not a string, it means it made a request
|
|
129
|
+
# that successfully returned metadata
|
|
130
|
+
if not isinstance(hub_result, str):
|
|
131
|
+
instance_result, storage_result = hub_result
|
|
132
|
+
db_updated = update_db_using_local(
|
|
133
|
+
instance_result,
|
|
134
|
+
settings_file,
|
|
135
|
+
db=db,
|
|
136
|
+
raise_permission_error=raise_permission_error,
|
|
137
|
+
)
|
|
138
|
+
ssettings = StorageSettings(
|
|
139
|
+
root=storage_result["root"],
|
|
140
|
+
region=storage_result["region"],
|
|
141
|
+
uid=storage_result["lnid"],
|
|
142
|
+
uuid=UUID(storage_result["id"]),
|
|
143
|
+
instance_id=UUID(instance_result["id"]),
|
|
144
|
+
)
|
|
145
|
+
isettings = InstanceSettings(
|
|
146
|
+
id=UUID(instance_result["id"]),
|
|
147
|
+
owner=owner,
|
|
148
|
+
name=name,
|
|
149
|
+
storage=ssettings,
|
|
150
|
+
db=db_updated,
|
|
151
|
+
schema=instance_result["schema_str"],
|
|
152
|
+
git_repo=instance_result["git_repo"],
|
|
153
|
+
keep_artifacts_local=bool(instance_result["keep_artifacts_local"]),
|
|
154
|
+
is_on_hub=True,
|
|
155
|
+
)
|
|
156
|
+
check_whether_migrations_in_sync(instance_result["lamindb_version"])
|
|
157
|
+
else:
|
|
158
|
+
message = INSTANCE_NOT_FOUND_MESSAGE.format(
|
|
159
|
+
owner=owner, name=name, hub_result=hub_result
|
|
160
|
+
)
|
|
161
|
+
if settings_file.exists():
|
|
162
|
+
isettings = load_instance_settings(settings_file)
|
|
163
|
+
if isettings.is_remote:
|
|
164
|
+
raise InstanceNotFoundError(message)
|
|
165
|
+
else:
|
|
166
|
+
raise InstanceNotFoundError(message)
|
|
167
|
+
return isettings
|
|
168
|
+
|
|
169
|
+
|
|
104
170
|
@unlock_cloud_sqlite_upon_exception(ignore_prev_locker=True)
|
|
105
171
|
def connect(
|
|
106
172
|
slug: str,
|
|
@@ -134,71 +200,22 @@ def connect(
|
|
|
134
200
|
elif settings._instance_exists and f"{owner}/{name}" != settings.instance.slug:
|
|
135
201
|
close_instance(mute=True)
|
|
136
202
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
# mimic instance_result from hub
|
|
143
|
-
instance_result = {"id": isettings._id.hex}
|
|
144
|
-
# skip hub request for a purely local instance
|
|
145
|
-
make_hub_request = isettings.is_remote
|
|
146
|
-
|
|
147
|
-
if make_hub_request:
|
|
148
|
-
# the following will return a string if the instance does not exist
|
|
149
|
-
# on the hub
|
|
150
|
-
hub_result = load_instance_from_hub(owner=owner, name=name)
|
|
151
|
-
# if hub_result is not a string, it means it made a request
|
|
152
|
-
# that successfully returned metadata
|
|
153
|
-
if not isinstance(hub_result, str):
|
|
154
|
-
instance_result, storage_result = hub_result
|
|
155
|
-
db_updated = update_db_using_local(
|
|
156
|
-
instance_result, settings_file, db=db
|
|
157
|
-
)
|
|
158
|
-
ssettings = StorageSettings(
|
|
159
|
-
root=storage_result["root"],
|
|
160
|
-
region=storage_result["region"],
|
|
161
|
-
uid=storage_result["lnid"],
|
|
162
|
-
uuid=UUID(storage_result["id"]),
|
|
163
|
-
instance_id=UUID(instance_result["id"]),
|
|
164
|
-
)
|
|
165
|
-
isettings = InstanceSettings(
|
|
166
|
-
id=UUID(instance_result["id"]),
|
|
167
|
-
owner=owner,
|
|
168
|
-
name=name,
|
|
169
|
-
storage=ssettings,
|
|
170
|
-
db=db_updated,
|
|
171
|
-
schema=instance_result["schema_str"],
|
|
172
|
-
git_repo=instance_result["git_repo"],
|
|
173
|
-
keep_artifacts_local=bool(instance_result["keep_artifacts_local"]),
|
|
174
|
-
is_on_hub=True,
|
|
175
|
-
)
|
|
176
|
-
check_whether_migrations_in_sync(instance_result["lamindb_version"])
|
|
203
|
+
try:
|
|
204
|
+
isettings = _connect_instance(owner, name, db=db)
|
|
205
|
+
except InstanceNotFoundError as e:
|
|
206
|
+
if _raise_not_found_error:
|
|
207
|
+
raise e
|
|
177
208
|
else:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if settings_file.exists():
|
|
182
|
-
isettings = load_instance_settings(settings_file)
|
|
183
|
-
if isettings.is_remote:
|
|
184
|
-
if _raise_not_found_error:
|
|
185
|
-
raise InstanceNotFoundError(message)
|
|
186
|
-
return "instance-not-found"
|
|
187
|
-
|
|
188
|
-
else:
|
|
189
|
-
if _raise_not_found_error:
|
|
190
|
-
raise InstanceNotFoundError(message)
|
|
191
|
-
return "instance-not-found"
|
|
192
|
-
|
|
209
|
+
return "instance-not-found"
|
|
210
|
+
if isinstance(isettings, str):
|
|
211
|
+
return isettings
|
|
193
212
|
if storage is not None:
|
|
194
213
|
update_isettings_with_storage(isettings, storage)
|
|
195
214
|
isettings._persist()
|
|
196
215
|
if _test:
|
|
197
216
|
return None
|
|
198
217
|
silence_loggers()
|
|
199
|
-
check, msg = isettings._load_db(
|
|
200
|
-
do_not_lock_for_laminapp_admin=True
|
|
201
|
-
) # this also updates local SQLite
|
|
218
|
+
check, msg = isettings._load_db()
|
|
202
219
|
if not check:
|
|
203
220
|
local_db = (
|
|
204
221
|
isettings._is_cloud_sqlite and isettings._sqlite_file_local.exists()
|
|
@@ -216,7 +233,7 @@ def connect(
|
|
|
216
233
|
f"instance exists with id {isettings._id.hex}, but database is not"
|
|
217
234
|
" loadable: re-initializing"
|
|
218
235
|
)
|
|
219
|
-
return "instance-corrupted-or-deleted"
|
|
236
|
+
return "instance-corrupted-or-deleted"
|
|
220
237
|
# this is for testing purposes only
|
|
221
238
|
if _TEST_FAILED_LOAD:
|
|
222
239
|
raise RuntimeError("Technical testing error.")
|
lamindb_setup/_delete.py
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import shutil
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
from uuid import UUID
|
|
6
6
|
|
|
7
7
|
from lamin_utils import logger
|
|
8
8
|
|
|
9
|
-
from ._connect_instance import
|
|
10
|
-
INSTANCE_NOT_FOUND_MESSAGE,
|
|
11
|
-
InstanceNotFoundError,
|
|
12
|
-
get_owner_name_from_identifier,
|
|
13
|
-
)
|
|
14
|
-
from .core._hub_core import connect_instance as load_instance_from_hub
|
|
9
|
+
from ._connect_instance import _connect_instance, get_owner_name_from_identifier
|
|
15
10
|
from .core._hub_core import delete_instance as delete_instance_on_hub
|
|
16
11
|
from .core._hub_core import get_storage_records_for_instance
|
|
17
12
|
from .core._settings import settings
|
|
18
|
-
from .core._settings_instance import InstanceSettings
|
|
19
|
-
from .core._settings_load import load_instance_settings
|
|
20
13
|
from .core._settings_storage import StorageSettings
|
|
21
|
-
from .core._settings_store import instance_settings_file
|
|
22
14
|
from .core.upath import HOSTED_BUCKETS, check_storage_is_empty
|
|
23
15
|
|
|
24
16
|
if TYPE_CHECKING:
|
|
25
17
|
from pathlib import Path
|
|
26
18
|
|
|
19
|
+
from .core._settings_instance import InstanceSettings
|
|
20
|
+
|
|
27
21
|
|
|
28
22
|
def delete_cache(cache_dir: Path):
|
|
29
23
|
if cache_dir is not None and cache_dir.exists():
|
|
@@ -67,42 +61,8 @@ def delete(slug: str, force: bool = False, require_empty: bool = True) -> int |
|
|
|
67
61
|
force: Whether to skip the confirmation prompt.
|
|
68
62
|
require_empty: Whether to check if the instance is empty before deleting.
|
|
69
63
|
"""
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
isettings = settings.instance
|
|
73
|
-
else:
|
|
74
|
-
settings_file = instance_settings_file(instance_name, instance_owner)
|
|
75
|
-
if not settings_file.exists():
|
|
76
|
-
hub_result = load_instance_from_hub(
|
|
77
|
-
owner=instance_owner, name=instance_name
|
|
78
|
-
)
|
|
79
|
-
if isinstance(hub_result, str):
|
|
80
|
-
message = INSTANCE_NOT_FOUND_MESSAGE.format(
|
|
81
|
-
owner=instance_owner,
|
|
82
|
-
name=instance_name,
|
|
83
|
-
hub_result=hub_result,
|
|
84
|
-
)
|
|
85
|
-
raise InstanceNotFoundError(message)
|
|
86
|
-
instance_result, storage_result = hub_result
|
|
87
|
-
ssettings = StorageSettings(
|
|
88
|
-
root=storage_result["root"],
|
|
89
|
-
region=storage_result["region"],
|
|
90
|
-
uid=storage_result["lnid"],
|
|
91
|
-
uuid=UUID(storage_result["id"]),
|
|
92
|
-
)
|
|
93
|
-
isettings = InstanceSettings(
|
|
94
|
-
id=UUID(instance_result["id"]),
|
|
95
|
-
owner=instance_owner,
|
|
96
|
-
name=instance_name,
|
|
97
|
-
storage=ssettings,
|
|
98
|
-
keep_artifacts_local=bool(instance_result["keep_artifacts_local"]),
|
|
99
|
-
db=instance_result["db"] if "db" in instance_result else None,
|
|
100
|
-
schema=instance_result["schema_str"],
|
|
101
|
-
git_repo=instance_result["git_repo"],
|
|
102
|
-
is_on_hub=True,
|
|
103
|
-
)
|
|
104
|
-
else:
|
|
105
|
-
isettings = load_instance_settings(settings_file)
|
|
64
|
+
owner, name = get_owner_name_from_identifier(slug)
|
|
65
|
+
isettings = _connect_instance(owner, name, raise_permission_error=False)
|
|
106
66
|
if isettings.dialect != "sqlite":
|
|
107
67
|
logger.warning(
|
|
108
68
|
f"delete() does not yet affect your Postgres database at {isettings.db}"
|
lamindb_setup/_init_instance.py
CHANGED
|
@@ -44,15 +44,17 @@ def register_storage_in_instance(ssettings: StorageSettings):
|
|
|
44
44
|
|
|
45
45
|
from .core.hashing import hash_and_encode_as_b62
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
if ssettings._instance_id is not None:
|
|
48
|
+
instance_uid = hash_and_encode_as_b62(ssettings._instance_id.hex)[:12]
|
|
49
|
+
else:
|
|
50
|
+
instance_uid = None
|
|
49
51
|
# how do we ensure that this function is only called passing
|
|
50
52
|
# the managing instance?
|
|
51
53
|
defaults = {
|
|
52
54
|
"root": ssettings.root_as_str,
|
|
53
55
|
"type": ssettings.type,
|
|
54
56
|
"region": ssettings.region,
|
|
55
|
-
"instance_uid":
|
|
57
|
+
"instance_uid": instance_uid,
|
|
56
58
|
"created_by_id": current_user_id(),
|
|
57
59
|
}
|
|
58
60
|
if ssettings._uid is not None:
|
|
@@ -67,20 +69,19 @@ def register_storage_in_instance(ssettings: StorageSettings):
|
|
|
67
69
|
def register_user(usettings):
|
|
68
70
|
from lnschema_core.models import User
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
try
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
pass
|
|
72
|
+
try:
|
|
73
|
+
# need to have try except because of integer primary key migration
|
|
74
|
+
user, created = User.objects.update_or_create(
|
|
75
|
+
uid=usettings.uid,
|
|
76
|
+
defaults={
|
|
77
|
+
"handle": usettings.handle,
|
|
78
|
+
"name": usettings.name,
|
|
79
|
+
},
|
|
80
|
+
)
|
|
81
|
+
# for users with only read access, except via ProgrammingError
|
|
82
|
+
# ProgrammingError: permission denied for table lnschema_core_user
|
|
83
|
+
except (OperationalError, FieldError, ProgrammingError):
|
|
84
|
+
pass
|
|
84
85
|
|
|
85
86
|
|
|
86
87
|
def register_user_and_storage_in_instance(isettings: InstanceSettings, usettings):
|
|
@@ -31,6 +31,10 @@ def set_managed_storage(root: UPathStr, **fs_kwargs):
|
|
|
31
31
|
ssettings = init_storage(
|
|
32
32
|
root=root, instance_id=settings.instance._id, register_hub=True
|
|
33
33
|
)
|
|
34
|
+
if ssettings._instance_id is None:
|
|
35
|
+
raise ValueError(
|
|
36
|
+
f"Cannot manage storage without write access: {ssettings.root}"
|
|
37
|
+
)
|
|
34
38
|
settings.instance._storage = ssettings
|
|
35
39
|
settings.instance._persist() # this also updates the settings object
|
|
36
40
|
register_storage_in_instance(ssettings)
|
lamindb_setup/core/_hub_core.py
CHANGED
|
@@ -284,9 +284,11 @@ def _init_instance(isettings: InstanceSettings, client: Client) -> None:
|
|
|
284
284
|
# as then init_instance is no longer idempotent
|
|
285
285
|
try:
|
|
286
286
|
client.table("instance").insert(fields, returning="minimal").execute()
|
|
287
|
-
except APIError
|
|
288
|
-
logger.warning(
|
|
289
|
-
|
|
287
|
+
except APIError:
|
|
288
|
+
logger.warning(
|
|
289
|
+
f"instance already existed at: https://lamin.ai/{isettings.owner}/{isettings.name}"
|
|
290
|
+
)
|
|
291
|
+
return None
|
|
290
292
|
client.table("storage").update(
|
|
291
293
|
{"instance_id": isettings._id.hex, "is_default": True}
|
|
292
294
|
).eq("id", isettings.storage._uuid.hex).execute() # type: ignore
|
|
@@ -42,7 +42,7 @@ class InstanceSettings:
|
|
|
42
42
|
db: str | None = None, # DB URI
|
|
43
43
|
schema: str | None = None, # comma-separated string of schema names
|
|
44
44
|
git_repo: str | None = None, # a git repo URL
|
|
45
|
-
is_on_hub: bool =
|
|
45
|
+
is_on_hub: bool | None = None, # initialized from hub
|
|
46
46
|
):
|
|
47
47
|
from ._hub_utils import validate_db_arg
|
|
48
48
|
|
|
@@ -406,9 +406,7 @@ class InstanceSettings:
|
|
|
406
406
|
|
|
407
407
|
setup_django(self, init=True)
|
|
408
408
|
|
|
409
|
-
def _load_db(
|
|
410
|
-
self, do_not_lock_for_laminapp_admin: bool = False
|
|
411
|
-
) -> tuple[bool, str]:
|
|
409
|
+
def _load_db(self) -> tuple[bool, str]:
|
|
412
410
|
# Is the database available and initialized as LaminDB?
|
|
413
411
|
# returns a tuple of status code and message
|
|
414
412
|
if self.dialect == "sqlite" and not self._sqlite_file.exists():
|
|
@@ -423,15 +421,8 @@ class InstanceSettings:
|
|
|
423
421
|
|
|
424
422
|
from .django import setup_django
|
|
425
423
|
|
|
426
|
-
# lock in all cases except if do_not_lock_for_laminapp_admin is True and
|
|
427
|
-
# user is `laminapp-admin`
|
|
428
|
-
# value doesn't matter if not a cloud sqlite instance
|
|
429
|
-
lock_cloud_sqlite = self._is_cloud_sqlite and (
|
|
430
|
-
not do_not_lock_for_laminapp_admin
|
|
431
|
-
or settings.user.handle != "laminapp-admin"
|
|
432
|
-
)
|
|
433
424
|
# we need the local sqlite to setup django
|
|
434
|
-
self._update_local_sqlite_file(lock_cloud_sqlite=
|
|
425
|
+
self._update_local_sqlite_file(lock_cloud_sqlite=self._is_cloud_sqlite)
|
|
435
426
|
# setting up django also performs a check for migrations & prints them
|
|
436
427
|
# as warnings
|
|
437
428
|
# this should fail, e.g., if the db is not reachable
|
|
@@ -113,11 +113,20 @@ def init_storage(
|
|
|
113
113
|
)
|
|
114
114
|
# the below might update the uid with one that's already taken on the hub
|
|
115
115
|
if ssettings.type_is_cloud or register_hub:
|
|
116
|
+
from ._hub_core import delete_storage_record
|
|
116
117
|
from ._hub_core import init_storage as init_storage_hub
|
|
117
118
|
|
|
118
119
|
init_storage_hub(ssettings)
|
|
119
120
|
# below comes last only if everything else was successful
|
|
120
|
-
|
|
121
|
+
try:
|
|
122
|
+
mark_storage_root(ssettings.root, ssettings.uid) # type: ignore
|
|
123
|
+
except Exception:
|
|
124
|
+
logger.important(
|
|
125
|
+
f"due to lack of write access, LaminDB won't manage storage location: {ssettings.root}"
|
|
126
|
+
)
|
|
127
|
+
if ssettings._uuid is not None:
|
|
128
|
+
delete_storage_record(ssettings._uuid) # type: ignore
|
|
129
|
+
ssettings._instance_id = None
|
|
121
130
|
return ssettings
|
|
122
131
|
|
|
123
132
|
|
lamindb_setup/core/hashing.py
CHANGED
|
@@ -40,11 +40,11 @@ def hash_set(s: set[str]) -> str:
|
|
|
40
40
|
return to_b64_str(hashlib.md5(bstr).digest())[:20]
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
def hash_md5s_from_dir(
|
|
43
|
+
def hash_md5s_from_dir(hashes: list[str]) -> tuple[str, str]:
|
|
44
44
|
# need to sort below because we don't want the order of parsing the dir to
|
|
45
45
|
# affect the hash
|
|
46
46
|
digests = b"".join(
|
|
47
|
-
hashlib.md5(
|
|
47
|
+
hashlib.md5(hash.encode("utf-8")).digest() for hash in sorted(hashes)
|
|
48
48
|
)
|
|
49
49
|
digest = hashlib.md5(digests).digest()
|
|
50
50
|
return to_b64_str(digest)[:22], "md5-d"
|
|
@@ -59,24 +59,27 @@ def hash_code(file_path: UPathStr):
|
|
|
59
59
|
return hashlib.sha1(blob)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
def hash_file(
|
|
63
|
-
|
|
62
|
+
def hash_file(
|
|
63
|
+
file_path: Path,
|
|
64
|
+
file_size: int | None = None,
|
|
65
|
+
chunk_size: int | None = 50 * 1024 * 1024,
|
|
66
|
+
) -> tuple[str, str]:
|
|
64
67
|
with open(file_path, "rb") as fp:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if
|
|
70
|
-
|
|
68
|
+
if file_size is None:
|
|
69
|
+
fp.seek(0, 2)
|
|
70
|
+
file_size = fp.tell()
|
|
71
|
+
fp.seek(0, 0)
|
|
72
|
+
if chunk_size is None:
|
|
73
|
+
chunk_size = file_size
|
|
74
|
+
first_chunk = fp.read(chunk_size)
|
|
75
|
+
if file_size <= chunk_size:
|
|
76
|
+
digest = hashlib.md5(first_chunk).digest()
|
|
77
|
+
hash_type = "md5"
|
|
78
|
+
else:
|
|
71
79
|
fp.seek(-chunk_size, 2)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
hash_type = "md5"
|
|
78
|
-
else:
|
|
79
|
-
digests = b"".join(hashlib.sha1(chunk).digest() for chunk in chunks)
|
|
80
|
-
digest = hashlib.sha1(digests).digest()
|
|
81
|
-
hash_type = "sha1-fl" # sha1 first last chunk
|
|
80
|
+
last_chunk = fp.read(chunk_size)
|
|
81
|
+
digest = hashlib.sha1(
|
|
82
|
+
hashlib.sha1(first_chunk).digest() + hashlib.sha1(last_chunk).digest()
|
|
83
|
+
).digest()
|
|
84
|
+
hash_type = "sha1-fl"
|
|
82
85
|
return to_b64_str(digest)[:22], hash_type
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
lamindb_setup/__init__.py,sha256=
|
|
1
|
+
lamindb_setup/__init__.py,sha256=w7Zj50IVdvhD0ctVPpTi0Uh4X2FLlm-YplosftlWzEs,1542
|
|
2
2
|
lamindb_setup/_cache.py,sha256=wA7mbysANwe8hPNbjDo9bOmXJ0xIyaS5iyxIpxSWji4,846
|
|
3
3
|
lamindb_setup/_check.py,sha256=28PcG8Kp6OpjSLSi1r2boL2Ryeh6xkaCL87HFbjs6GA,129
|
|
4
4
|
lamindb_setup/_check_setup.py,sha256=cNEL9Q4yPpmEkGKHH8JgullWl1VUZwALJ4RHn9wZypY,2613
|
|
5
5
|
lamindb_setup/_close.py,sha256=1QS9p2SCacgovYn6xqWU4zFvwHN1RgIccvzwJgFvKgU,1186
|
|
6
|
-
lamindb_setup/_connect_instance.py,sha256=
|
|
7
|
-
lamindb_setup/_delete.py,sha256=
|
|
6
|
+
lamindb_setup/_connect_instance.py,sha256=C4WURprypLpvS1oJmfyXHvXCMPc7yOOvKmOabyFr7dE,12728
|
|
7
|
+
lamindb_setup/_delete.py,sha256=gRqtlGWUaYDYL97kI7EyLvgI23DIaAoVyOx6hF6LPNw,5498
|
|
8
8
|
lamindb_setup/_django.py,sha256=EoyWvFzH0i9wxjy4JZhcoXCTckztP_Mrl6FbYQnMmLE,1534
|
|
9
9
|
lamindb_setup/_exportdb.py,sha256=uTIZjKKTB7arzEr1j0O6lONiT2pRBKeOFdLvOV8ZwzE,2120
|
|
10
10
|
lamindb_setup/_importdb.py,sha256=yYYShzUajTsR-cTW4CZ-UNDWZY2uE5PAgNbp-wn8Ogc,1874
|
|
11
|
-
lamindb_setup/_init_instance.py,sha256=
|
|
11
|
+
lamindb_setup/_init_instance.py,sha256=lR-6txbf3Z2O7ki-DMZWFg36QNiUZ_B5lc6JXjScdus,11897
|
|
12
12
|
lamindb_setup/_migrate.py,sha256=4nBTFg5-BK4A2gH-D3_tcFf8EtvMnIo5Mq0e_C6_9-U,8815
|
|
13
13
|
lamindb_setup/_register_instance.py,sha256=Jeu0wyvJVSVQ_n-A_7yn7xOZIP0ncJD92DRABqzPIjA,940
|
|
14
14
|
lamindb_setup/_schema.py,sha256=b3uzhhWpV5mQtDwhMINc2MabGCnGLESy51ito3yl6Wc,679
|
|
15
|
-
lamindb_setup/_set_managed_storage.py,sha256=
|
|
15
|
+
lamindb_setup/_set_managed_storage.py,sha256=mNZrANn-9rwZ0oGWxxg0wS0T0VOQCWyo4nSSyNAE15Q,1419
|
|
16
16
|
lamindb_setup/_setup_user.py,sha256=6Oc7Rke-yRQSZbuntdUAz8QbJ6UuPzYHI9FnYlf_q-A,3670
|
|
17
17
|
lamindb_setup/_silence_loggers.py,sha256=AKF_YcHvX32eGXdsYK8MJlxEaZ-Uo2f6QDRzjKFCtws,1568
|
|
18
18
|
lamindb_setup/core/__init__.py,sha256=dV9S-rQpNK9JcBn4hiEmiLnmNqfpPFJD9pqagMCaIew,416
|
|
@@ -20,24 +20,24 @@ lamindb_setup/core/_aws_storage.py,sha256=nEjeUv4xUVpoV0Lx-zjjmyb9w804bDyaeiM-Oq
|
|
|
20
20
|
lamindb_setup/core/_deprecated.py,sha256=3qxUI1dnDlSeR0BYrv7ucjqRBEojbqotPgpShXs4KF8,2520
|
|
21
21
|
lamindb_setup/core/_docs.py,sha256=3k-YY-oVaJd_9UIY-LfBg_u8raKOCNfkZQPA73KsUhs,276
|
|
22
22
|
lamindb_setup/core/_hub_client.py,sha256=V0qKDsCdRn-tQy2YIk4VgXcpJFmuum6N3gcavAC7gBQ,5504
|
|
23
|
-
lamindb_setup/core/_hub_core.py,sha256=
|
|
23
|
+
lamindb_setup/core/_hub_core.py,sha256=Jxjf6qyae25NlnrHLqArNaCq1ZjWYuE3pEStbx7jCI0,16043
|
|
24
24
|
lamindb_setup/core/_hub_crud.py,sha256=b1XF7AJpM9Q-ttm9nPG-r3OTRWHQaGzAGIyvmb83NTo,4859
|
|
25
25
|
lamindb_setup/core/_hub_utils.py,sha256=b_M1LkdCjiMWm1EOlSb9GuPdLijwVgQDtATTpeZuXI0,1875
|
|
26
26
|
lamindb_setup/core/_settings.py,sha256=jjZ_AxRXB3Y3UP6m04BAw_dhFbJbdg2-nZWmEv2LNZ8,3141
|
|
27
|
-
lamindb_setup/core/_settings_instance.py,sha256=
|
|
27
|
+
lamindb_setup/core/_settings_instance.py,sha256=PtMg-0ADnvH5bsTUPt7mD87qbOqj9pZE4RujWTR3nw8,16191
|
|
28
28
|
lamindb_setup/core/_settings_load.py,sha256=NGgCDpN85j1EqoKlrYFIlZBMlBJm33gx2-wc96CP_ZQ,3922
|
|
29
29
|
lamindb_setup/core/_settings_save.py,sha256=d1A-Ex-7H08mb8l7I0Oe0j0GilrfaDuprh_NMxhQAsQ,2704
|
|
30
|
-
lamindb_setup/core/_settings_storage.py,sha256=
|
|
30
|
+
lamindb_setup/core/_settings_storage.py,sha256=KnSvMABdGNQYzx6TPVTAprahY23LY1pAfxzYulqtWaw,12751
|
|
31
31
|
lamindb_setup/core/_settings_store.py,sha256=dagS5c7wAMRnuZTRfCU4sKaIOyF_HwAP5Fnnn8vphno,2084
|
|
32
32
|
lamindb_setup/core/_settings_user.py,sha256=P2lC4WDRAFfT-Xq3MlXJ-wMKIHCoGNhMTQfRGIAyUNQ,1344
|
|
33
33
|
lamindb_setup/core/_setup_bionty_sources.py,sha256=OgPpZxN2_Wffy-ogEBz_97c_k8d2bD-DDVt89-u9GLY,3002
|
|
34
34
|
lamindb_setup/core/cloud_sqlite_locker.py,sha256=NIBNAGq7TTRrip9OzMdiQKj8QOuwhL9esyM0aehUqBA,6893
|
|
35
35
|
lamindb_setup/core/django.py,sha256=QUQm3zt5QIiD8uv6o9vbSm_bshqiSWzKSkgD3z2eJCg,3542
|
|
36
36
|
lamindb_setup/core/exceptions.py,sha256=eoI7AXgATgDVzgArtN7CUvpaMUC067vsBg5LHCsWzDM,305
|
|
37
|
-
lamindb_setup/core/hashing.py,sha256=
|
|
37
|
+
lamindb_setup/core/hashing.py,sha256=7r96h5JBzuwfOR_gNNqTyWNPKMuiOUfBYwn6sCbZkf8,2269
|
|
38
38
|
lamindb_setup/core/types.py,sha256=bcYnZ0uM_2NXKJCl94Mmc-uYrQlRUUVKG3sK2N-F-N4,532
|
|
39
39
|
lamindb_setup/core/upath.py,sha256=mou3NdF-tRTLW3E4eNDRFdCZrFZUyt-NPOVyC-DLe24,28342
|
|
40
|
-
lamindb_setup-0.71.
|
|
41
|
-
lamindb_setup-0.71.
|
|
42
|
-
lamindb_setup-0.71.
|
|
43
|
-
lamindb_setup-0.71.
|
|
40
|
+
lamindb_setup-0.71.4.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
|
|
41
|
+
lamindb_setup-0.71.4.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
42
|
+
lamindb_setup-0.71.4.dist-info/METADATA,sha256=ge5_4_y1g-3nbwgsX_3xP11x27UrZGdr9O0wghjrD3s,1620
|
|
43
|
+
lamindb_setup-0.71.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|