kraph 7.2.1__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-7.2.1 → kraph-8.1.0}/PKG-INFO +8 -8
- {kraph-7.2.1 → kraph-8.1.0}/README.md +6 -6
- kraph-8.1.0/kraph/__init__.py +6 -0
- kraph-8.1.0/kraph/_tested.json +1 -0
- kraph-8.1.0/kraph/connect.py +46 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/io/obstore.py +6 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/io/upload.py +46 -3
- {kraph-7.2.1 → kraph-8.1.0}/kraph/kraph.py +38 -1
- kraph-7.2.1/kraph/arkitekt.py → kraph-8.1.0/kraph/structures.py +24 -118
- {kraph-7.2.1 → kraph-8.1.0}/pyproject.toml +11 -17
- kraph-7.2.1/kraph/__init__.py +0 -5
- kraph-7.2.1/kraph/_tested.json +0 -1
- {kraph-7.2.1 → kraph-8.1.0}/.gitignore +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/api/__init__.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/api/project.json +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/api/schema.graphql +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/api/schema.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/client.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/contrib/fakts/__init__.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/datalayer.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/errors.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/io/__init__.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/io/download.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/links/__init__.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/links/errors.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/links/upload.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/middleware/__init__.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/middleware/base.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/middleware/upload.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/pairs.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/py.typed +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/rath.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/refs.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/scalars.py +0 -0
- {kraph-7.2.1 → kraph-8.1.0}/kraph/traits.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: kraph
|
|
3
|
-
Version:
|
|
3
|
+
Version: 8.1.0
|
|
4
4
|
Summary: the arkitekt knowledge graph
|
|
5
5
|
Author-email: jhnnsrs <jhnnsrs@gmail.com>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
7
7
|
Requires-Python: <4.0,>=3.11
|
|
8
|
-
Requires-Dist: arkitekt-spec>=
|
|
8
|
+
Requires-Dist: arkitekt-spec>=14
|
|
9
9
|
Requires-Dist: dokker>=2.8
|
|
10
10
|
Requires-Dist: fakts>=6.1
|
|
11
11
|
Requires-Dist: obstore>=0.11.0
|
|
@@ -46,16 +46,16 @@ the client, so follow-ups from a result go through the same client.
|
|
|
46
46
|
|
|
47
47
|
### In an arkitekt app
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Ask for `kraph: Kraph`; the client is injected by annotation.
|
|
50
50
|
Graphs, categories, structures, metrics, terms and more travel between actions by id
|
|
51
51
|
(`@kraph/graph`, `@kraph/entitycategory`, `@kraph/structure`, `@kraph/term`, …), so an action can
|
|
52
52
|
take and return them directly:
|
|
53
53
|
|
|
54
54
|
```python
|
|
55
55
|
from arkitekt import App, run
|
|
56
|
-
from kraph import Kraph
|
|
56
|
+
from kraph import Kraph
|
|
57
57
|
|
|
58
|
-
app = App("neuron-claims", "0.1.0"
|
|
58
|
+
app = App("neuron-claims", "0.1.0")
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
@app.action
|
|
@@ -77,10 +77,10 @@ if __name__ == "__main__":
|
|
|
77
77
|
### From a script
|
|
78
78
|
|
|
79
79
|
```python
|
|
80
|
-
from arkitekt import
|
|
81
|
-
from kraph import
|
|
80
|
+
from arkitekt import connect
|
|
81
|
+
from kraph import Kraph
|
|
82
82
|
|
|
83
|
-
with
|
|
83
|
+
with connect(Kraph) as kraph:
|
|
84
84
|
graph = kraph.create_graph(name="Neurons", backfill=False)
|
|
85
85
|
kraph.create_entity_category(
|
|
86
86
|
key="Neuron",
|
|
@@ -31,16 +31,16 @@ the client, so follow-ups from a result go through the same client.
|
|
|
31
31
|
|
|
32
32
|
### In an arkitekt app
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Ask for `kraph: Kraph`; the client is injected by annotation.
|
|
35
35
|
Graphs, categories, structures, metrics, terms and more travel between actions by id
|
|
36
36
|
(`@kraph/graph`, `@kraph/entitycategory`, `@kraph/structure`, `@kraph/term`, …), so an action can
|
|
37
37
|
take and return them directly:
|
|
38
38
|
|
|
39
39
|
```python
|
|
40
40
|
from arkitekt import App, run
|
|
41
|
-
from kraph import Kraph
|
|
41
|
+
from kraph import Kraph
|
|
42
42
|
|
|
43
|
-
app = App("neuron-claims", "0.1.0"
|
|
43
|
+
app = App("neuron-claims", "0.1.0")
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
@app.action
|
|
@@ -62,10 +62,10 @@ if __name__ == "__main__":
|
|
|
62
62
|
### From a script
|
|
63
63
|
|
|
64
64
|
```python
|
|
65
|
-
from arkitekt import
|
|
66
|
-
from kraph import
|
|
65
|
+
from arkitekt import connect
|
|
66
|
+
from kraph import Kraph
|
|
67
67
|
|
|
68
|
-
with
|
|
68
|
+
with connect(Kraph) as kraph:
|
|
69
69
|
graph = kraph.create_graph(name="Neurons", backfill=False)
|
|
70
70
|
kraph.create_entity_category(
|
|
71
71
|
key="Neuron",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version": "7.8.0"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""How ``Kraph`` reaches a resolved deployment: its links and upload middleware."""
|
|
2
|
+
|
|
3
|
+
from arkitekt_spec.declare.wiring import Alias, TokenLoader
|
|
4
|
+
from fakts.contrib.rath.auth import FaktsAuthLink
|
|
5
|
+
from rath.links import compose
|
|
6
|
+
from rath.links.aiohttp import AIOHttpLink
|
|
7
|
+
from rath.links.dictinglink import DictingLink
|
|
8
|
+
from rath.links.graphql_ws import GraphQLWSLink
|
|
9
|
+
from rath.links.shrink import ShrinkingLink
|
|
10
|
+
from rath.links.split import SplitLink
|
|
11
|
+
|
|
12
|
+
from graphql import OperationType
|
|
13
|
+
from kraph.datalayer import DataLayer
|
|
14
|
+
from kraph.links.upload import UploadLink
|
|
15
|
+
from kraph.middleware.upload import UploadMiddleware
|
|
16
|
+
from kraph.rath import KraphRath
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def kraph_rath(kraph: Alias, datalayer: DataLayer, tokens: TokenLoader) -> KraphRath:
|
|
20
|
+
"""The rath over http and ws, uploading files to ``datalayer`` first."""
|
|
21
|
+
return KraphRath(
|
|
22
|
+
# Files in a request (a model's weights) go to the datalayer first, as every service's do.
|
|
23
|
+
middlewares=[UploadMiddleware(datalayer=datalayer)],
|
|
24
|
+
link=compose(
|
|
25
|
+
ShrinkingLink(),
|
|
26
|
+
DictingLink(),
|
|
27
|
+
FaktsAuthLink(token_loader=tokens),
|
|
28
|
+
UploadLink(datalayer=datalayer),
|
|
29
|
+
SplitLink(
|
|
30
|
+
left=AIOHttpLink(
|
|
31
|
+
endpoint_url=kraph.to_http_path("graphql"),
|
|
32
|
+
proxy=kraph.proxy,
|
|
33
|
+
ssl_context=kraph.ssl_context(),
|
|
34
|
+
),
|
|
35
|
+
right=GraphQLWSLink(
|
|
36
|
+
ws_endpoint_url=kraph.to_ws_path("graphql"),
|
|
37
|
+
proxy=kraph.proxy,
|
|
38
|
+
ssl_context=kraph.ssl_context(),
|
|
39
|
+
),
|
|
40
|
+
split=lambda o: o.node.operation != OperationType.SUBSCRIPTION,
|
|
41
|
+
),
|
|
42
|
+
),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
__all__ = ["kraph_rath"]
|
|
@@ -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}"
|
|
@@ -16,9 +16,13 @@ nullable field in this schema already defaults to null, so omitting and sending
|
|
|
16
16
|
same thing.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
+
import os
|
|
19
20
|
from collections.abc import AsyncGenerator, Generator
|
|
20
|
-
from typing import Any
|
|
21
|
+
from typing import Annotated, Any, Self
|
|
21
22
|
|
|
23
|
+
from arkitekt_spec.declare.client import client
|
|
24
|
+
from arkitekt_spec.declare.tested import tested_against
|
|
25
|
+
from arkitekt_spec.declare.wiring import Alias, Require, TokenLoader
|
|
22
26
|
from koil import unkoil, unkoil_gen
|
|
23
27
|
from koil.composition import Composition
|
|
24
28
|
from rath.origin import origin_context
|
|
@@ -29,7 +33,22 @@ from kraph.api.schema import KraphApi
|
|
|
29
33
|
from kraph.datalayer import DataLayer
|
|
30
34
|
from kraph.rath import KraphRath
|
|
31
35
|
|
|
36
|
+
TESTED = tested_against("kraph")
|
|
37
|
+
"""The kraph server this release wants: the one its release job tested it against."""
|
|
32
38
|
|
|
39
|
+
_API = os.path.join(os.path.dirname(__file__), "api")
|
|
40
|
+
KRAPH = Require(
|
|
41
|
+
"live.arkitekt.kraph",
|
|
42
|
+
"Where the knowledge graph relating entities lives",
|
|
43
|
+
version=TESTED,
|
|
44
|
+
)
|
|
45
|
+
S3 = Require("live.arkitekt.s3", "Where the graph's files are stored", optional=True)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@client(
|
|
49
|
+
schema=os.path.join(_API, "schema.graphql"),
|
|
50
|
+
turms=os.path.join(_API, "project.json"),
|
|
51
|
+
)
|
|
33
52
|
class Kraph(Composition, KraphApi):
|
|
34
53
|
"""The kraph client.
|
|
35
54
|
|
|
@@ -43,6 +62,24 @@ class Kraph(Composition, KraphApi):
|
|
|
43
62
|
rath: KraphRath
|
|
44
63
|
datalayer: DataLayer
|
|
45
64
|
|
|
65
|
+
@classmethod
|
|
66
|
+
def from_fakts(
|
|
67
|
+
cls,
|
|
68
|
+
kraph: Annotated[Alias, KRAPH],
|
|
69
|
+
datalayer: Annotated[Alias | None, S3],
|
|
70
|
+
tokens: TokenLoader,
|
|
71
|
+
) -> Self:
|
|
72
|
+
"""Kraph over the resolved deployment.
|
|
73
|
+
|
|
74
|
+
Without a store the client still works; only uploads do not.
|
|
75
|
+
"""
|
|
76
|
+
from kraph.connect import kraph_rath
|
|
77
|
+
|
|
78
|
+
store = (
|
|
79
|
+
DataLayer.from_alias(datalayer) if datalayer is not None else DataLayer()
|
|
80
|
+
)
|
|
81
|
+
return cls(rath=kraph_rath(kraph, store, tokens), datalayer=store)
|
|
82
|
+
|
|
46
83
|
@staticmethod
|
|
47
84
|
def _serialize(
|
|
48
85
|
operation: type[TOperation], variables: dict[str, Any]
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"""The kraph
|
|
1
|
+
"""The types kraph sends by id: each expanded by the ``Kraph`` client.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
ask for the ``Kraph`` it returns. Each type is declared once -- the class, the
|
|
5
|
-
identifier it travels under, the widget a user picks one with, and how to fetch it
|
|
6
|
-
back. An app takes all of it in with ``App(services=[kraph_service])``.
|
|
3
|
+
Imported by ``kraph/__init__``, so each class is marked whenever kraph is.
|
|
7
4
|
|
|
8
5
|
The ``@kraph/…`` identifier strings are a wire contract: other arkitekt services
|
|
9
6
|
resolve against them, so renaming one is a coordinated cross-service change, not a
|
|
@@ -11,7 +8,7 @@ local refactor. Two of them therefore keep their old spelling while pointing at
|
|
|
11
8
|
renamed type — ``@kraph/structurecategory`` now names a :class:`StructureKind`, and
|
|
12
9
|
``@kraph/metriccategory`` a :class:`MetricKind`.
|
|
13
10
|
|
|
14
|
-
One
|
|
11
|
+
One identifier changed meaning and could not keep its type. ``@kraph/entity`` used
|
|
15
12
|
to expand through ``get_node(id)``, but the view-grain readers (``node``/``entity``)
|
|
16
13
|
now require a graph as well as an id, and an expander is handed only the id.
|
|
17
14
|
``instance(id:)`` is the graph-free addressable claim, so that is what the identifier
|
|
@@ -22,22 +19,10 @@ resolves to — visible now in the expander itself rather than in a separate map
|
|
|
22
19
|
table-query surface.
|
|
23
20
|
"""
|
|
24
21
|
|
|
25
|
-
import
|
|
26
|
-
from
|
|
27
|
-
|
|
28
|
-
from arkitekt_spec.declare.app import AppRegistry
|
|
29
|
-
from arkitekt_spec.declare.tested import tested_against
|
|
22
|
+
from arkitekt_spec.actions import AssignWidgetInput
|
|
23
|
+
from arkitekt_spec.declare.structures.declare import structure
|
|
30
24
|
from arkitekt_spec.declare.widgets import SearchWidget
|
|
31
|
-
|
|
32
|
-
from fakts.contrib.rath.auth import FaktsAuthLink
|
|
33
|
-
from rath.links import compose
|
|
34
|
-
from rath.links.aiohttp import AIOHttpLink
|
|
35
|
-
from rath.links.dictinglink import DictingLink
|
|
36
|
-
from rath.links.graphql_ws import GraphQLWSLink
|
|
37
|
-
from rath.links.shrink import ShrinkingLink
|
|
38
|
-
from rath.links.split import SplitLink
|
|
39
|
-
|
|
40
|
-
from graphql import OperationType
|
|
25
|
+
|
|
41
26
|
from kraph.api.schema import (
|
|
42
27
|
EntityCategory,
|
|
43
28
|
Graph,
|
|
@@ -71,83 +56,10 @@ from kraph.api.schema import (
|
|
|
71
56
|
StructureRelationCategory,
|
|
72
57
|
Term,
|
|
73
58
|
)
|
|
74
|
-
from kraph.datalayer import DataLayer
|
|
75
59
|
from kraph.kraph import Kraph
|
|
76
|
-
from kraph.links.upload import UploadLink
|
|
77
|
-
from kraph.middleware.upload import UploadMiddleware
|
|
78
|
-
from kraph.rath import KraphRath
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def build_relative_path(*path: str) -> str:
|
|
82
|
-
"""Build a path relative to this file, for the files shipped beside it."""
|
|
83
|
-
return os.path.join(os.path.dirname(__file__), *path)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
registry = AppRegistry()
|
|
87
|
-
"""What kraph brings to an app: its service, and the types it can send by id."""
|
|
88
|
-
|
|
89
60
|
|
|
90
|
-
TESTED = tested_against("kraph")
|
|
91
|
-
"""The kraph server this release wants: the one its release job tested it against."""
|
|
92
61
|
|
|
93
|
-
|
|
94
|
-
@registry.service(
|
|
95
|
-
schema=build_relative_path("api", "schema.graphql"),
|
|
96
|
-
turms=build_relative_path("api", "project.json"),
|
|
97
|
-
)
|
|
98
|
-
def kraph(
|
|
99
|
-
kraph: Annotated[
|
|
100
|
-
Alias,
|
|
101
|
-
Require(
|
|
102
|
-
"live.arkitekt.kraph",
|
|
103
|
-
"Where the knowledge graph relating entities lives",
|
|
104
|
-
version=TESTED,
|
|
105
|
-
),
|
|
106
|
-
],
|
|
107
|
-
datalayer: Annotated[
|
|
108
|
-
Alias | None,
|
|
109
|
-
Require(
|
|
110
|
-
"live.arkitekt.s3", "Where the graph's files are stored", optional=True
|
|
111
|
-
),
|
|
112
|
-
],
|
|
113
|
-
tokens: TokenLoader,
|
|
114
|
-
) -> Kraph:
|
|
115
|
-
"""Kraph: the knowledge graph relating entities.
|
|
116
|
-
|
|
117
|
-
The datalayer is optional, so a deployment that offers no store still gets a
|
|
118
|
-
working client -- uploads are what stop working, not the graph.
|
|
119
|
-
"""
|
|
120
|
-
store = DataLayer.from_alias(datalayer) if datalayer is not None else DataLayer()
|
|
121
|
-
|
|
122
|
-
return Kraph(
|
|
123
|
-
rath=KraphRath(
|
|
124
|
-
# Files in a request (a model's weights) go to the datalayer first, as every service's do.
|
|
125
|
-
middlewares=[UploadMiddleware(datalayer=store)],
|
|
126
|
-
link=compose(
|
|
127
|
-
ShrinkingLink(),
|
|
128
|
-
DictingLink(),
|
|
129
|
-
FaktsAuthLink(token_loader=tokens),
|
|
130
|
-
UploadLink(datalayer=store),
|
|
131
|
-
SplitLink(
|
|
132
|
-
left=AIOHttpLink(
|
|
133
|
-
endpoint_url=kraph.to_http_path("graphql"),
|
|
134
|
-
proxy=kraph.proxy,
|
|
135
|
-
ssl_context=kraph.ssl_context(),
|
|
136
|
-
),
|
|
137
|
-
right=GraphQLWSLink(
|
|
138
|
-
ws_endpoint_url=kraph.to_ws_path("graphql"),
|
|
139
|
-
proxy=kraph.proxy,
|
|
140
|
-
ssl_context=kraph.ssl_context(),
|
|
141
|
-
),
|
|
142
|
-
split=lambda o: o.node.operation != OperationType.SUBSCRIPTION,
|
|
143
|
-
),
|
|
144
|
-
),
|
|
145
|
-
),
|
|
146
|
-
datalayer=store,
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def _search(query: object) -> SearchWidget:
|
|
62
|
+
def _search(query: object) -> AssignWidgetInput:
|
|
151
63
|
"""The widget that picks one of these out of the deployment."""
|
|
152
64
|
return SearchWidget(query=query.Meta.document, ward="kraph") # type: ignore[attr-defined]
|
|
153
65
|
|
|
@@ -155,21 +67,19 @@ def _search(query: object) -> SearchWidget:
|
|
|
155
67
|
# --- views and their declarations ------------------------------------------------
|
|
156
68
|
|
|
157
69
|
|
|
158
|
-
@
|
|
70
|
+
@structure("@kraph/graph", widget=_search(SearchGraphsQuery))
|
|
159
71
|
async def expand_graph(id: str, kraph: Kraph) -> Graph:
|
|
160
72
|
"""A graph, by id."""
|
|
161
73
|
return await kraph.aget_graph(id)
|
|
162
74
|
|
|
163
75
|
|
|
164
|
-
@
|
|
165
|
-
"@kraph/entitycategory", widget=_search(SearchEntityCategoriesQuery)
|
|
166
|
-
)
|
|
76
|
+
@structure("@kraph/entitycategory", widget=_search(SearchEntityCategoriesQuery))
|
|
167
77
|
async def expand_entity_category(id: str, kraph: Kraph) -> EntityCategory:
|
|
168
78
|
"""An entity category, by id."""
|
|
169
79
|
return await kraph.aget_entity_category(id)
|
|
170
80
|
|
|
171
81
|
|
|
172
|
-
@
|
|
82
|
+
@structure(
|
|
173
83
|
"@kraph/relationcategory",
|
|
174
84
|
widget=_search(SearchRelationCategoriesQuery),
|
|
175
85
|
)
|
|
@@ -178,7 +88,7 @@ async def expand_relation_category(id: str, kraph: Kraph) -> RelationCategory:
|
|
|
178
88
|
return await kraph.aget_relation_category(id)
|
|
179
89
|
|
|
180
90
|
|
|
181
|
-
@
|
|
91
|
+
@structure(
|
|
182
92
|
"@kraph/measurementcategory",
|
|
183
93
|
widget=_search(SearchMeasurementCategoriesQuery),
|
|
184
94
|
)
|
|
@@ -187,7 +97,7 @@ async def expand_measurement_category(id: str, kraph: Kraph) -> MeasurementCateg
|
|
|
187
97
|
return await kraph.aget_measurement_category(id)
|
|
188
98
|
|
|
189
99
|
|
|
190
|
-
@
|
|
100
|
+
@structure(
|
|
191
101
|
"@kraph/structurerelationcategory",
|
|
192
102
|
widget=_search(SearchStructureRelationCategoriesQuery),
|
|
193
103
|
)
|
|
@@ -198,7 +108,7 @@ async def expand_structure_relation_category(
|
|
|
198
108
|
return await kraph.aget_structure_relation_category(id)
|
|
199
109
|
|
|
200
110
|
|
|
201
|
-
@
|
|
111
|
+
@structure(
|
|
202
112
|
"@kraph/naturaleventcategory",
|
|
203
113
|
widget=_search(SearchNaturalEventCategoriesQuery),
|
|
204
114
|
)
|
|
@@ -207,7 +117,7 @@ async def expand_natural_event_category(id: str, kraph: Kraph) -> NaturalEventCa
|
|
|
207
117
|
return await kraph.aget_natural_event_category(id)
|
|
208
118
|
|
|
209
119
|
|
|
210
|
-
@
|
|
120
|
+
@structure(
|
|
211
121
|
"@kraph/protocoleventcategory",
|
|
212
122
|
widget=_search(SearchProtocolEventCategoriesQuery),
|
|
213
123
|
)
|
|
@@ -223,25 +133,25 @@ async def expand_protocol_event_category(
|
|
|
223
133
|
|
|
224
134
|
# `Instance` has no scalar label -- its name lives at `term { key }` -- so it gets no
|
|
225
135
|
# search widget: a two-field `value`/`label` projection cannot reach it.
|
|
226
|
-
@
|
|
136
|
+
@structure("@kraph/entity")
|
|
227
137
|
async def expand_entity(id: str, kraph: Kraph) -> Instance:
|
|
228
138
|
"""The graph-free addressable claim an `@kraph/entity` names, by id."""
|
|
229
139
|
return await kraph.aget_instance(id)
|
|
230
140
|
|
|
231
141
|
|
|
232
|
-
@
|
|
142
|
+
@structure("@kraph/link")
|
|
233
143
|
async def expand_link(id: str, kraph: Kraph) -> Link:
|
|
234
144
|
"""A link, by id."""
|
|
235
145
|
return await kraph.aget_link(id)
|
|
236
146
|
|
|
237
147
|
|
|
238
|
-
@
|
|
148
|
+
@structure("@kraph/structure", widget=_search(SearchStructuresQuery))
|
|
239
149
|
async def expand_structure(id: str, kraph: Kraph) -> Structure:
|
|
240
150
|
"""A structure, by id."""
|
|
241
151
|
return await kraph.aget_structure(id)
|
|
242
152
|
|
|
243
153
|
|
|
244
|
-
@
|
|
154
|
+
@structure("@kraph/metric")
|
|
245
155
|
async def expand_metric(id: str, kraph: Kraph) -> Metric:
|
|
246
156
|
"""A metric, by id."""
|
|
247
157
|
return await kraph.aget_metric(id)
|
|
@@ -250,23 +160,21 @@ async def expand_metric(id: str, kraph: Kraph) -> Metric:
|
|
|
250
160
|
# --- vocabulary ------------------------------------------------------------------
|
|
251
161
|
|
|
252
162
|
|
|
253
|
-
@
|
|
163
|
+
@structure("@kraph/term", widget=_search(SearchTermsQuery))
|
|
254
164
|
async def expand_term(id: str, kraph: Kraph) -> Term:
|
|
255
165
|
"""A term, by id."""
|
|
256
166
|
return await kraph.aget_term(id)
|
|
257
167
|
|
|
258
168
|
|
|
259
169
|
# Identifier kept for wire compatibility; the type behind it is now StructureKind.
|
|
260
|
-
@
|
|
261
|
-
"@kraph/structurecategory", widget=_search(SearchStructureKindsQuery)
|
|
262
|
-
)
|
|
170
|
+
@structure("@kraph/structurecategory", widget=_search(SearchStructureKindsQuery))
|
|
263
171
|
async def expand_structure_kind(id: str, kraph: Kraph) -> StructureKind:
|
|
264
172
|
"""A structure kind, by id -- it travels as `@kraph/structurecategory`."""
|
|
265
173
|
return await kraph.aget_structure_kind(id)
|
|
266
174
|
|
|
267
175
|
|
|
268
176
|
# Identifier kept for wire compatibility; the type behind it is now MetricKind.
|
|
269
|
-
@
|
|
177
|
+
@structure("@kraph/metriccategory", widget=_search(SearchMetricKindsQuery))
|
|
270
178
|
async def expand_metric_kind(id: str, kraph: Kraph) -> MetricKind:
|
|
271
179
|
"""A metric kind, by id -- it travels as `@kraph/metriccategory`."""
|
|
272
180
|
return await kraph.aget_metric_kind(id)
|
|
@@ -287,7 +195,7 @@ def describe_pairs_query(query: GraphPairsQuery) -> dict:
|
|
|
287
195
|
|
|
288
196
|
# The search widgets forward a port's `requires` ($requires), so a picker for a typed port
|
|
289
197
|
# offers only the queries and runs that port accepts.
|
|
290
|
-
@
|
|
198
|
+
@structure(
|
|
291
199
|
"@kraph/pairsquery",
|
|
292
200
|
widget=_search(SearchGraphPairsQueriesQuery),
|
|
293
201
|
describe=describe_pairs_query,
|
|
@@ -302,7 +210,7 @@ def describe_pairs_run(run: PairsQueryRun) -> dict:
|
|
|
302
210
|
return dict(run.descriptors or {})
|
|
303
211
|
|
|
304
212
|
|
|
305
|
-
@
|
|
213
|
+
@structure(
|
|
306
214
|
"@kraph/pairsrun",
|
|
307
215
|
widget=_search(SearchPairsQueryRunsQuery),
|
|
308
216
|
describe=describe_pairs_run,
|
|
@@ -322,9 +230,7 @@ def describe_model(model: Model) -> dict:
|
|
|
322
230
|
return dict(model.descriptors or {})
|
|
323
231
|
|
|
324
232
|
|
|
325
|
-
@
|
|
326
|
-
"@kraph/model", widget=_search(SearchModelsQuery), describe=describe_model
|
|
327
|
-
)
|
|
233
|
+
@structure("@kraph/model", widget=_search(SearchModelsQuery), describe=describe_model)
|
|
328
234
|
async def expand_model(id: str, kraph: Kraph) -> Model:
|
|
329
235
|
"""A trained model, by id: its weights and the pairs query run it learned from."""
|
|
330
236
|
return await kraph.aget_model(id)
|
|
@@ -13,7 +13,7 @@ dependencies = [
|
|
|
13
13
|
"rath>=4.1.1",
|
|
14
14
|
"websockets>=15.0.1",
|
|
15
15
|
# The service and structures are declared with arkitekt-spec (5.0: a service reads its scopes off its client).
|
|
16
|
-
"arkitekt-spec>=
|
|
16
|
+
"arkitekt-spec>=14",
|
|
17
17
|
# The service wiring (Alias, Require, FaktsAuthLink); it came through rekuest before.
|
|
18
18
|
"fakts>=6.1",
|
|
19
19
|
# The datalayer: big files (a model's weights) go to S3 through obstore, as in mikro and elektro.
|
|
@@ -23,22 +23,6 @@ dependencies = [
|
|
|
23
23
|
[project.optional-dependencies]
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
[tool.uv]
|
|
27
|
-
dev-dependencies = [
|
|
28
|
-
"pytest-asyncio>=0.26.0",
|
|
29
|
-
"pytest-cov>=6.1.1",
|
|
30
|
-
"pytest>=8.3.5",
|
|
31
|
-
"python-semantic-release>=9.21.0",
|
|
32
|
-
"autoflake>=1.7.7,<2",
|
|
33
|
-
"aiohttp>=3.8.3,<4",
|
|
34
|
-
"black>=23.1.0,<24",
|
|
35
|
-
"pytest-aiohttp>=1.0.4,<2",
|
|
36
|
-
"turms>=3.0",
|
|
37
|
-
"dokker>=2.8",
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
# `_tested.json` is written by the integration tests (the server version they ran against)
|
|
41
|
-
# and is not in git: named as an artifact, on both, it is shipped all the same.
|
|
42
26
|
[tool.hatch.build.targets.sdist]
|
|
43
27
|
include = ["kraph"]
|
|
44
28
|
artifacts = ["kraph/_tested.json"]
|
|
@@ -119,4 +103,14 @@ exclude_commit_patterns = [
|
|
|
119
103
|
dev = [
|
|
120
104
|
"ruff==0.17.6",
|
|
121
105
|
"basedpyright==1.40.2",
|
|
106
|
+
"pytest-asyncio>=0.26.0",
|
|
107
|
+
"pytest-cov>=6.1.1",
|
|
108
|
+
"pytest>=8.3.5",
|
|
109
|
+
"python-semantic-release>=9.21.0",
|
|
110
|
+
"autoflake>=1.7.7,<2",
|
|
111
|
+
"aiohttp>=3.8.3,<4",
|
|
112
|
+
"black>=23.1.0,<24",
|
|
113
|
+
"pytest-aiohttp>=1.0.4,<2",
|
|
114
|
+
"turms>=3.0",
|
|
115
|
+
"dokker>=2.8",
|
|
122
116
|
]
|
kraph-7.2.1/kraph/__init__.py
DELETED
kraph-7.2.1/kraph/_tested.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version": "7.7.1"}
|
|
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
|