arkitekt-runtime 1.0.1__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.
- arkitekt_runtime-1.0.1/.gitignore +7 -0
- arkitekt_runtime-1.0.1/PKG-INFO +29 -0
- arkitekt_runtime-1.0.1/README.md +13 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/__init__.py +8 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/__init__.py +6 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/actify.py +91 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/base.py +641 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/build.py +28 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/debug.py +117 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/dependency.py +163 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/errors.py +15 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/functional.py +210 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/helper.py +164 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/actors/types.py +279 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/__init__.py +1 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/backend.py +93 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/base.py +1893 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/dataclasses.py +51 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/hooks/__init__.py +1 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/hooks/background.py +78 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/hooks/materialize.py +35 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/hooks/shutdown.py +80 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/hooks/startup.py +120 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/journal.py +772 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/lock.py +146 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/policy.py +102 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/transport/__init__.py +1 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/transport/base.py +149 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/agents/transport/types.py +159 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/calls.py +205 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/constants.py +4 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/invoke.py +253 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/messages.py +1235 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/postmans/__init__.py +1 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/postmans/errors.py +25 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/postmans/types.py +131 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/qt/__init__.py +1 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/qt/builders.py +347 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/state/__init__.py +1 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/state/gate.py +79 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/state/observable.py +809 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/state/readonly.py +201 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/state/shrink.py +36 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/state/write.py +174 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/__init__.py +1 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/__init__.py +1 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/actor.py +856 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/batching.py +100 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/context.py +112 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/expand.py +340 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/memory.py +50 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/port_errors.py +64 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/postman.py +10 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/predication.py +103 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/protocols.py +99 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/structures/serialization/shrink.py +307 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/task.py +362 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/task_scope.py +24 -0
- arkitekt_runtime-1.0.1/arkitekt_runtime/types.py +125 -0
- arkitekt_runtime-1.0.1/pyproject.toml +109 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: arkitekt-runtime
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: the execution core of an Arkitekt app: agent, actors, tasks, journal, state and structure serialization, shared by every runtime
|
|
5
|
+
Author-email: jhnnsrs <jhnnsrs@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: arkitekt-spec>=1.1
|
|
9
|
+
Requires-Dist: janus>=2.0.0
|
|
10
|
+
Requires-Dist: jsonpatch>=1.33
|
|
11
|
+
Requires-Dist: koil>=3.3.3
|
|
12
|
+
Requires-Dist: pydantic>=2.11
|
|
13
|
+
Provides-Extra: qt
|
|
14
|
+
Requires-Dist: qtpy>=2.4; extra == 'qt'
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# arkitekt-runtime
|
|
18
|
+
|
|
19
|
+
The execution core of an Arkitekt app: what every runtime needs to *run* a declared app.
|
|
20
|
+
|
|
21
|
+
An app is declared with [arkitekt-spec](../arkitekt-spec). A runtime executes it:
|
|
22
|
+
[rekuest](../rekuest) in distributed mode (a socket agent registered with a rekuest server),
|
|
23
|
+
[arkitekt-fastapi](../arkitekt-fastapi) in server mode (an HTTP service). Both build on this
|
|
24
|
+
package: the agent's assignment handling, actors, `Task`, the journal, state, locks, hook
|
|
25
|
+
runners and structure serialization.
|
|
26
|
+
|
|
27
|
+
It carries no transport and no client -- no websockets, rath or graphql-core. A runtime plugs
|
|
28
|
+
in its transport (`agents.transport.base.AgentTransport`), its caller (to call other actions)
|
|
29
|
+
and its task scope (e.g. rath's, so service clients attribute requests to the running task).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# arkitekt-runtime
|
|
2
|
+
|
|
3
|
+
The execution core of an Arkitekt app: what every runtime needs to *run* a declared app.
|
|
4
|
+
|
|
5
|
+
An app is declared with [arkitekt-spec](../arkitekt-spec). A runtime executes it:
|
|
6
|
+
[rekuest](../rekuest) in distributed mode (a socket agent registered with a rekuest server),
|
|
7
|
+
[arkitekt-fastapi](../arkitekt-fastapi) in server mode (an HTTP service). Both build on this
|
|
8
|
+
package: the agent's assignment handling, actors, `Task`, the journal, state, locks, hook
|
|
9
|
+
runners and structure serialization.
|
|
10
|
+
|
|
11
|
+
It carries no transport and no client -- no websockets, rath or graphql-core. A runtime plugs
|
|
12
|
+
in its transport (`agents.transport.base.AgentTransport`), its caller (to call other actions)
|
|
13
|
+
and its task scope (e.g. rath's, so service clients attribute requests to the running task).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""arkitekt-runtime: the execution core every runtime of an Arkitekt app shares.
|
|
2
|
+
|
|
3
|
+
A declared app (:mod:`arkitekt_spec.declare`) is run by a runtime: rekuest in
|
|
4
|
+
distributed mode, arkitekt-fastapi in server mode. Both are built on this package --
|
|
5
|
+
the agent (:mod:`arkitekt_runtime.agents.base`), actors, :class:`~arkitekt_runtime.task.Task`,
|
|
6
|
+
the journal, state, locks, hook runners and structure serialization. A runtime plugs
|
|
7
|
+
in its transport, its caller and its task scope; this package has none of its own.
|
|
8
|
+
"""
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Actifier
|
|
2
|
+
|
|
3
|
+
This module contains the actify function, which is used to convert a function
|
|
4
|
+
into an actor.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import inspect
|
|
8
|
+
from functools import partial
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from arkitekt_runtime.actors.functional import (
|
|
12
|
+
FUNC,
|
|
13
|
+
GEN,
|
|
14
|
+
THREADED_FUNC,
|
|
15
|
+
THREADED_GEN,
|
|
16
|
+
FunctionalActor,
|
|
17
|
+
)
|
|
18
|
+
from arkitekt_spec.declare.protocol.types import AnyFunction
|
|
19
|
+
from arkitekt_spec.declare.actors.types import (
|
|
20
|
+
ImplementationDetails,
|
|
21
|
+
RegisterConfig,
|
|
22
|
+
)
|
|
23
|
+
from arkitekt_runtime.actors.types import ActorBuilder
|
|
24
|
+
from arkitekt_spec.actions import DefinitionInput
|
|
25
|
+
from arkitekt_spec.declare.structures.registry import StructureRegistry
|
|
26
|
+
from arkitekt_spec.declare.actors.actify import (
|
|
27
|
+
derive_implementation_details,
|
|
28
|
+
prepare_definition_from_config,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def reactify(
|
|
37
|
+
function: AnyFunction,
|
|
38
|
+
structure_registry: StructureRegistry,
|
|
39
|
+
config: RegisterConfig | None = None,
|
|
40
|
+
) -> tuple[DefinitionInput, ImplementationDetails, ActorBuilder]:
|
|
41
|
+
"""Reactify a function
|
|
42
|
+
|
|
43
|
+
This function takes a callable (of type async or sync function or generator) and
|
|
44
|
+
returns a builder function that creates an actor that makes the function callable
|
|
45
|
+
from the rekuest server.
|
|
46
|
+
|
|
47
|
+
All registration options are read from the bundled ``config``
|
|
48
|
+
(:class:`~rekuest.actors.types.RegisterConfig`); ``config`` defaults to an
|
|
49
|
+
empty config so ``reactify(func, registry)`` keeps working.
|
|
50
|
+
"""
|
|
51
|
+
config = config or RegisterConfig()
|
|
52
|
+
|
|
53
|
+
implementation_details = derive_implementation_details(function, config, structure_registry)
|
|
54
|
+
definition = prepare_definition_from_config(
|
|
55
|
+
function, structure_registry, config, implementation_details
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
is_coroutine = inspect.iscoroutinefunction(function)
|
|
59
|
+
is_asyncgen = inspect.isasyncgenfunction(function)
|
|
60
|
+
is_method = inspect.ismethod(function)
|
|
61
|
+
|
|
62
|
+
is_generatorfunction = inspect.isgeneratorfunction(function)
|
|
63
|
+
is_function = inspect.isfunction(function)
|
|
64
|
+
|
|
65
|
+
actor_attributes: dict[str, Any] = {
|
|
66
|
+
"assign": function,
|
|
67
|
+
"expand_inputs": not config.bypass_expand,
|
|
68
|
+
"shrink_outputs": not config.bypass_shrink,
|
|
69
|
+
"structure_registry": structure_registry,
|
|
70
|
+
"definition": definition,
|
|
71
|
+
**implementation_details.actor_kwargs(),
|
|
72
|
+
"concurrency": config.concurrency,
|
|
73
|
+
"policy": config.policy,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if is_coroutine:
|
|
77
|
+
iterator = FUNC
|
|
78
|
+
elif is_asyncgen:
|
|
79
|
+
iterator = GEN
|
|
80
|
+
elif is_generatorfunction and not config.in_process:
|
|
81
|
+
iterator = THREADED_GEN
|
|
82
|
+
elif (is_function or is_method) and not config.in_process:
|
|
83
|
+
iterator = THREADED_FUNC
|
|
84
|
+
else:
|
|
85
|
+
raise NotImplementedError("No way of converting this to a function")
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
definition,
|
|
89
|
+
implementation_details,
|
|
90
|
+
partial(FunctionalActor, iterator=iterator, **actor_attributes),
|
|
91
|
+
)
|