kraph 8.0.0__tar.gz → 8.1.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.
- {kraph-8.0.0 → kraph-8.1.0}/PKG-INFO +1 -1
- kraph-8.1.0/kraph/_tested.json +1 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/io/obstore.py +6 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/io/upload.py +46 -3
- {kraph-8.0.0 → kraph-8.1.0}/kraph/structures.py +2 -1
- kraph-8.0.0/kraph/_tested.json +0 -1
- {kraph-8.0.0 → kraph-8.1.0}/.gitignore +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/README.md +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/__init__.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/api/__init__.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/api/project.json +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/api/schema.graphql +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/api/schema.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/client.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/connect.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/contrib/fakts/__init__.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/datalayer.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/errors.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/io/__init__.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/io/download.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/kraph.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/links/__init__.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/links/errors.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/links/upload.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/middleware/__init__.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/middleware/base.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/middleware/upload.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/pairs.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/py.typed +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/rath.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/refs.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/scalars.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/kraph/traits.py +0 -0
- {kraph-8.0.0 → kraph-8.1.0}/pyproject.toml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version": "7.8.0"}
|
|
@@ -105,6 +105,7 @@ def create_s3_store(
|
|
|
105
105
|
*,
|
|
106
106
|
proxy: str | None = None,
|
|
107
107
|
certificates: list[str] | None = None,
|
|
108
|
+
checksum_algorithm: str | None = None,
|
|
108
109
|
) -> S3Store:
|
|
109
110
|
"""Create an obstore S3 client from an kraph grant and endpoint.
|
|
110
111
|
|
|
@@ -156,6 +157,11 @@ def create_s3_store(
|
|
|
156
157
|
if prefix:
|
|
157
158
|
store_kwargs["prefix"] = prefix
|
|
158
159
|
|
|
160
|
+
if checksum_algorithm:
|
|
161
|
+
# Every request and part carries it: with the server's part size as `chunk_size`,
|
|
162
|
+
# the object store's composite of a big file's parts is the file's digest.
|
|
163
|
+
store_kwargs["checksum_algorithm"] = checksum_algorithm
|
|
164
|
+
|
|
159
165
|
return S3Store(
|
|
160
166
|
grant.bucket,
|
|
161
167
|
**store_kwargs,
|
|
@@ -5,8 +5,10 @@ Requesting the grant and finishing the upload are the middleware's
|
|
|
5
5
|
says, through a store whose credentials renew themselves while it runs.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import io
|
|
8
9
|
import logging
|
|
9
|
-
|
|
10
|
+
import os
|
|
11
|
+
from typing import TYPE_CHECKING, cast
|
|
10
12
|
|
|
11
13
|
import obstore
|
|
12
14
|
|
|
@@ -21,6 +23,35 @@ if TYPE_CHECKING:
|
|
|
21
23
|
logger = logging.getLogger(__name__)
|
|
22
24
|
|
|
23
25
|
|
|
26
|
+
#: Sent with every request and part of a big-file upload, so the object store verifies it.
|
|
27
|
+
BIGFILE_CHECKSUM = "SHA256"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def part_size_for(size: int) -> int:
|
|
31
|
+
"""The part size the server's digest of a ``size``-byte file is cut at (``arkitekt_datalayer.digest``).
|
|
32
|
+
|
|
33
|
+
8 MiB, doubled until the parts fit S3's 10,000. Computed here, not read off the grant, so
|
|
34
|
+
an upload to a hub that does not advertise it still has its digest verified on arrival.
|
|
35
|
+
"""
|
|
36
|
+
part = 8 * 1024 * 1024
|
|
37
|
+
while size > part * 10_000:
|
|
38
|
+
part *= 2
|
|
39
|
+
return part
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _remaining_bytes(value: object) -> int:
|
|
43
|
+
"""How many bytes a write will send: a buffer's length, a path's size, or a file object's rest, left where it was."""
|
|
44
|
+
if isinstance(value, (bytes, bytearray, memoryview)):
|
|
45
|
+
return len(value)
|
|
46
|
+
if isinstance(value, (str, os.PathLike)):
|
|
47
|
+
return os.path.getsize(value)
|
|
48
|
+
stream = cast("io.IOBase", value)
|
|
49
|
+
position = stream.tell()
|
|
50
|
+
end = stream.seek(0, io.SEEK_END)
|
|
51
|
+
stream.seek(position)
|
|
52
|
+
return end - position
|
|
53
|
+
|
|
54
|
+
|
|
24
55
|
def upload_bigfile(
|
|
25
56
|
file: BigFile, credentials: "BigFileUploadGrant", datalayer: "DataLayer"
|
|
26
57
|
) -> str:
|
|
@@ -30,9 +61,15 @@ def upload_bigfile(
|
|
|
30
61
|
credentials,
|
|
31
62
|
proxy=datalayer.proxy,
|
|
32
63
|
certificates=datalayer.certificates,
|
|
64
|
+
checksum_algorithm=BIGFILE_CHECKSUM,
|
|
33
65
|
)
|
|
34
66
|
try:
|
|
35
|
-
obstore.put(
|
|
67
|
+
obstore.put(
|
|
68
|
+
store,
|
|
69
|
+
credentials.key,
|
|
70
|
+
file.value,
|
|
71
|
+
chunk_size=part_size_for(_remaining_bytes(file.value)),
|
|
72
|
+
)
|
|
36
73
|
except Exception as e:
|
|
37
74
|
raise UploadError(
|
|
38
75
|
f"Error while uploading to s3://{credentials.bucket}/{credentials.key} on {datalayer.endpoint_url}"
|
|
@@ -53,9 +90,15 @@ async def aupload_bigfile(
|
|
|
53
90
|
credentials,
|
|
54
91
|
proxy=datalayer.proxy,
|
|
55
92
|
certificates=datalayer.certificates,
|
|
93
|
+
checksum_algorithm=BIGFILE_CHECKSUM,
|
|
56
94
|
)
|
|
57
95
|
try:
|
|
58
|
-
await obstore.put_async(
|
|
96
|
+
await obstore.put_async(
|
|
97
|
+
store,
|
|
98
|
+
credentials.key,
|
|
99
|
+
file.value,
|
|
100
|
+
chunk_size=part_size_for(_remaining_bytes(file.value)),
|
|
101
|
+
)
|
|
59
102
|
except Exception as e:
|
|
60
103
|
raise UploadError(
|
|
61
104
|
f"Error while uploading to s3://{credentials.bucket}/{credentials.key} on {endpoint_url}"
|
|
@@ -19,6 +19,7 @@ resolves to — visible now in the expander itself rather than in a separate map
|
|
|
19
19
|
table-query surface.
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
+
from arkitekt_spec.actions import AssignWidgetInput
|
|
22
23
|
from arkitekt_spec.declare.structures.declare import structure
|
|
23
24
|
from arkitekt_spec.declare.widgets import SearchWidget
|
|
24
25
|
|
|
@@ -58,7 +59,7 @@ from kraph.api.schema import (
|
|
|
58
59
|
from kraph.kraph import Kraph
|
|
59
60
|
|
|
60
61
|
|
|
61
|
-
def _search(query: object) ->
|
|
62
|
+
def _search(query: object) -> AssignWidgetInput:
|
|
62
63
|
"""The widget that picks one of these out of the deployment."""
|
|
63
64
|
return SearchWidget(query=query.Meta.document, ward="kraph") # type: ignore[attr-defined]
|
|
64
65
|
|
kraph-8.0.0/kraph/_tested.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version": "7.7.2"}
|
|
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
|