wasmkeep 0.2.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.
- wasmkeep/__init__.py +496 -0
- wasmkeep/__main__.py +98 -0
- wasmkeep/_call.py +33 -0
- wasmkeep/kv.py +277 -0
- wasmkeep/queue.py +214 -0
- wasmkeep/wire.py +559 -0
- wasmkeep/wit/actor.wit +273 -0
- wasmkeep/wit/deps/cli.wit +233 -0
- wasmkeep/wit/deps/clocks.wit +162 -0
- wasmkeep/wit/deps/filesystem.wit +589 -0
- wasmkeep/wit/deps/http.wit +733 -0
- wasmkeep/wit/deps/io.wit +299 -0
- wasmkeep/wit/deps/random.wit +92 -0
- wasmkeep/wit/deps/sockets.wit +949 -0
- wasmkeep/workflow.py +110 -0
- wasmkeep-0.2.0.dist-info/METADATA +254 -0
- wasmkeep-0.2.0.dist-info/RECORD +20 -0
- wasmkeep-0.2.0.dist-info/WHEEL +4 -0
- wasmkeep-0.2.0.dist-info/licenses/LICENSE +202 -0
- wasmkeep-0.2.0.dist-info/licenses/NOTICE +14 -0
wasmkeep/workflow.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""Durable workflows (ADR 0019): the client side.
|
|
2
|
+
|
|
3
|
+
A workflow class is served by the Rust SDK's runner (or the TypeScript
|
|
4
|
+
one), one actor per instance, as `examples/workflows/orders` is. This module
|
|
5
|
+
starts and follows instances from any Python actor, speaking the runner's
|
|
6
|
+
protocol (`/wasmkeep-workflow/v1`) over `actors.call`, byte for byte like
|
|
7
|
+
the Rust `workflow::Client`:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from wasmkeep import Actor, workflow
|
|
11
|
+
|
|
12
|
+
orders = workflow.Client("orders")
|
|
13
|
+
|
|
14
|
+
class App(Actor):
|
|
15
|
+
def fetch(self, req):
|
|
16
|
+
orders.start("order-42", "item=book") # idempotent while kept
|
|
17
|
+
orders.send_event("order-42", "approved", b"")
|
|
18
|
+
return orders.status("order-42").state # "waiting", "completed", ...
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Errors raise `WorkflowError`: "unknown" (no such instance), "finished" (an
|
|
22
|
+
event to a finished instance), "call" or "refused".
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from typing import Optional
|
|
26
|
+
|
|
27
|
+
from ._call import CallFailed, call
|
|
28
|
+
from .wire import STATES, Data, Status, decode_status, hex, lossy, to_bytes
|
|
29
|
+
|
|
30
|
+
__all__ = ["STATES", "Client", "Status", "WorkflowError"]
|
|
31
|
+
|
|
32
|
+
_PREFIX = "/wasmkeep-workflow/v1"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class WorkflowError(Exception):
|
|
36
|
+
"""Why a workflow operation failed, as `kind`:
|
|
37
|
+
|
|
38
|
+
- "unknown": no instance with that id (never started, or deleted after
|
|
39
|
+
its retention);
|
|
40
|
+
- "finished": the instance has finished, so it takes no more events;
|
|
41
|
+
- "call": the call failed (the instance may or may not have recorded
|
|
42
|
+
it);
|
|
43
|
+
- "refused": the instance answered with an unexpected `status`.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def __init__(self, kind: str, detail: str = "", status: Optional[int] = None):
|
|
47
|
+
if kind == "unknown":
|
|
48
|
+
message = "no such workflow instance"
|
|
49
|
+
elif kind == "finished":
|
|
50
|
+
message = "the workflow instance has finished"
|
|
51
|
+
elif kind == "call":
|
|
52
|
+
message = detail
|
|
53
|
+
else:
|
|
54
|
+
message = f"refused ({status}): {detail}"
|
|
55
|
+
super().__init__(message)
|
|
56
|
+
self.kind = kind
|
|
57
|
+
self.detail = detail
|
|
58
|
+
"""The detail: the call's error, or the instance's answer."""
|
|
59
|
+
self.status = status
|
|
60
|
+
"""The instance's status, for "refused"."""
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class Client:
|
|
64
|
+
"""Starts and queries instances of one workflow class."""
|
|
65
|
+
|
|
66
|
+
def __init__(self, cls: str):
|
|
67
|
+
"""Instances of `cls` (the workflow class's name): instance `id` is
|
|
68
|
+
actor `cls/id`."""
|
|
69
|
+
self.cls = cls
|
|
70
|
+
|
|
71
|
+
def _call(self, id: str, method: str, path: str, body: bytes) -> bytes: # noqa: A002 - Rust's name
|
|
72
|
+
try:
|
|
73
|
+
status, reply = call(f"{self.cls}/{id}", method, f"{_PREFIX}{path}", {}, body)
|
|
74
|
+
except CallFailed as e:
|
|
75
|
+
raise WorkflowError("call", str(e)) from None
|
|
76
|
+
if status == 200:
|
|
77
|
+
return reply
|
|
78
|
+
if status == 404:
|
|
79
|
+
raise WorkflowError("unknown")
|
|
80
|
+
if status == 409:
|
|
81
|
+
raise WorkflowError("finished")
|
|
82
|
+
raise WorkflowError("refused", lossy(reply), status)
|
|
83
|
+
|
|
84
|
+
@staticmethod
|
|
85
|
+
def _status(body: bytes) -> Status:
|
|
86
|
+
status = decode_status(body)
|
|
87
|
+
if status is None:
|
|
88
|
+
raise WorkflowError("refused", "malformed status", 200)
|
|
89
|
+
return status
|
|
90
|
+
|
|
91
|
+
def start(self, id: str, input: Data = b"") -> Status: # noqa: A002 - Rust's names
|
|
92
|
+
"""Starts instance `id` with `input`, or returns its status if it
|
|
93
|
+
exists (a start is idempotent while the instance is kept). It runs
|
|
94
|
+
in its own event, soon after: this call only records it."""
|
|
95
|
+
return self._status(self._call(id, "POST", "/start", to_bytes(input)))
|
|
96
|
+
|
|
97
|
+
def status(self, id: str) -> Status: # noqa: A002 - Rust's name
|
|
98
|
+
"""The instance's status; "unknown" if there is none."""
|
|
99
|
+
return self._status(self._call(id, "GET", "/status", b""))
|
|
100
|
+
|
|
101
|
+
def send_event(self, id: str, name: str, payload: Data = b"") -> None: # noqa: A002 - Rust's name
|
|
102
|
+
"""Delivers event `name` with `payload`: recorded durably, then the
|
|
103
|
+
instance runs. "unknown" if it was never started, "finished" if it
|
|
104
|
+
has finished."""
|
|
105
|
+
self._call(id, "POST", f"/event?name={hex(name.encode())}", to_bytes(payload))
|
|
106
|
+
|
|
107
|
+
def cancel(self, id: str) -> Status: # noqa: A002 - Rust's name
|
|
108
|
+
"""Cancels the instance: it runs no further step (one running now
|
|
109
|
+
finishes first). Returns its status; a finished one is unchanged."""
|
|
110
|
+
return self._status(self._call(id, "POST", "/cancel", b""))
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: wasmkeep
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Write WasmKeep actors in Python.
|
|
5
|
+
Project-URL: Repository, https://github.com/WasmKeep/wasmkeep
|
|
6
|
+
Project-URL: Documentation, https://github.com/WasmKeep/wasmkeep/tree/main/sdks/python
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
Keywords: actors,component-model,wasi,wasmkeep,webassembly
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: componentize-py==0.25.1
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# WasmKeep actors in Python
|
|
18
|
+
|
|
19
|
+
Write [WasmKeep](https://github.com/WasmKeep/wasmkeep) actors as plain Python
|
|
20
|
+
classes. WasmKeep is a self-hosted platform for actors: WebAssembly
|
|
21
|
+
components, each with its own SQLite database, handling one event at a time.
|
|
22
|
+
This package is the SDK and the command that builds your module into such a
|
|
23
|
+
component, with
|
|
24
|
+
[componentize-py](https://github.com/bytecodealliance/componentize-py)
|
|
25
|
+
(CPython embedded). WasmKeep is pre-alpha.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python3 -m venv .venv && . .venv/bin/activate
|
|
31
|
+
pip install wasmkeep
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
That is all a build needs: the package carries the WIT files of the
|
|
35
|
+
`wasmkeep:actor` world, and componentize-py comes with it at the version
|
|
36
|
+
the SDK is written for. To run the result you need the `wasmkeep` server:
|
|
37
|
+
[install a release](https://github.com/WasmKeep/wasmkeep#install) of the
|
|
38
|
+
same version as the package.
|
|
39
|
+
|
|
40
|
+
## A first actor
|
|
41
|
+
|
|
42
|
+
`app.py`:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from wasmkeep import Actor, storage
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Hits(Actor):
|
|
49
|
+
# Once per deployed version, before any other event: create tables here.
|
|
50
|
+
def init(self):
|
|
51
|
+
storage.exec("CREATE TABLE IF NOT EXISTS hits (at INTEGER NOT NULL)")
|
|
52
|
+
|
|
53
|
+
# One HTTP request at a time, in arrival order: no locks needed.
|
|
54
|
+
def fetch(self, req):
|
|
55
|
+
storage.exec("INSERT INTO hits (at) VALUES (unixepoch())")
|
|
56
|
+
[row] = storage.query("SELECT count(*) AS n FROM hits")
|
|
57
|
+
return {"hits": row["n"], "path": req.path} # a dict is sent as JSON
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
WitWorld, IncomingHandler = Hits.exports()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Build it into a component and serve it:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python -m wasmkeep build app -o actor.wasm
|
|
67
|
+
wasmkeep serve --actor hits=actor.wasm
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
In another terminal:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
curl localhost:8080/actor/hits/alice # {"hits": 1, "path": "/"}
|
|
74
|
+
curl localhost:8080/actor/hits/alice # {"hits": 2, "path": "/"}
|
|
75
|
+
curl localhost:8080/actor/hits/bob # {"hits": 1, "path": "/"}: another actor, its own database
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`build` takes the module's name (`app` for `app.py`), found in the current
|
|
79
|
+
directory; `-p DIR` (repeatable) names other directories to find it and
|
|
80
|
+
what it imports in. Pure-Python packages installed in the same environment
|
|
81
|
+
are bundled too. The last line of `app.py` is what the component exports:
|
|
82
|
+
keep it at module level.
|
|
83
|
+
|
|
84
|
+
The other hooks, all optional:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from wasmkeep import Actor, sockets
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class Room(Actor):
|
|
91
|
+
# The alarm set with alarms.set(...) fired (at least once).
|
|
92
|
+
def alarm(self):
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
def websocket_open(self, conn, path):
|
|
96
|
+
sockets.send(conn, "welcome") # return False to refuse
|
|
97
|
+
|
|
98
|
+
def websocket_message(self, conn, data):
|
|
99
|
+
sockets.broadcast(data)
|
|
100
|
+
|
|
101
|
+
def websocket_close(self, conn, code, reason):
|
|
102
|
+
pass
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Versions
|
|
106
|
+
|
|
107
|
+
| | |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| The package | The version of the WasmKeep server it is released with; use the two at the same version |
|
|
110
|
+
| componentize-py | 0.25.1 exactly, installed with the package: the SDK imports the bindings that version generates |
|
|
111
|
+
| Python, to run the build | 3.10 or later (CI builds with 3.13) |
|
|
112
|
+
| Python, in the component | CPython 3.14, the one componentize-py 0.25.1 embeds, whatever Python ran the build |
|
|
113
|
+
| The interface | `wasmkeep:actor@0.2.0`, versioned on its own: `wasmkeep.WIT_VERSION`, the WIT files in the package's `wit/` |
|
|
114
|
+
|
|
115
|
+
`python -m wasmkeep --version` prints the package's version and the
|
|
116
|
+
interface's.
|
|
117
|
+
|
|
118
|
+
## Outside a component
|
|
119
|
+
|
|
120
|
+
The host's functions (`storage`, `alarms`, `actors`, `sockets`, `env`, and
|
|
121
|
+
`exports()`) exist only inside a built component, running on a WasmKeep
|
|
122
|
+
node. Under plain CPython the package imports, so an editor resolves it and
|
|
123
|
+
the build command runs, but calling one of them raises `RuntimeError`: an
|
|
124
|
+
actor is tried by building it and serving it (`wasmkeep serve` runs on a
|
|
125
|
+
laptop). Keep logic you want to unit-test in functions that take and return
|
|
126
|
+
plain values.
|
|
127
|
+
|
|
128
|
+
## API
|
|
129
|
+
|
|
130
|
+
| | |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| `storage.exec(sql, *params)` | Runs a statement; returns the rows changed |
|
|
133
|
+
| `storage.exec_durable(sql, *params)` | The same, returning once the write is durable (inside a transaction, only `COMMIT`) |
|
|
134
|
+
| `storage.query(sql, *params)` | Rows as dicts, by column name |
|
|
135
|
+
| `storage.delete_self()` | Deletes this actor when the event ends |
|
|
136
|
+
| `alarms.set(at_ms)`, `alarms.get()`, `alarms.clear()` | The actor's single alarm, in ms since the Unix epoch |
|
|
137
|
+
| `env.get(name, default=None)` | The class's configuration value or secret (`deploy --config`, `secrets set`, `serve --env`; last wins; see [`env`](https://github.com/WasmKeep/wasmkeep/blob/v0.2.0/docs/reference/api.md#interface-env)), or `default` |
|
|
138
|
+
| `actors.self_address()` | This actor's `ActorAddress` (`tenant`, `class_name`, `name`) |
|
|
139
|
+
| `actors.call("class/name", method=, path=, headers=, body=)` | Calls another actor; returns a `CallResponse` (`status`, `headers`, `body`, `text()`, `json()`) |
|
|
140
|
+
| `sockets.send(conn, data)`, `broadcast(data, except_conn=)`, `close(conn, code, reason)`, `connections()` | The actor's WebSockets (str is text, bytes binary) |
|
|
141
|
+
| `Response(body, status, headers)`, `json(value, status)` | Full responses; a handler may also return str, bytes, a dict or a list |
|
|
142
|
+
|
|
143
|
+
SQL values are `None`, `int`, `float`, `str` and `bytes` (`bool` binds as 0
|
|
144
|
+
or 1). Failures raise `SqlError` (with `.kind`: syntax, constraint, bind, ...)
|
|
145
|
+
and `CallError` (`.kind`: invalid-address, reentrant, too-large, timeout,
|
|
146
|
+
failed). An exception in `fetch` becomes a 500; in `init` or `alarm` it fails
|
|
147
|
+
the event (an alarm is retried).
|
|
148
|
+
|
|
149
|
+
One instance of your class handles events until the actor hibernates; keep
|
|
150
|
+
anything that must survive in `storage`, not on `self`.
|
|
151
|
+
|
|
152
|
+
## Key-value and queues
|
|
153
|
+
|
|
154
|
+
`wasmkeep.kv` and `wasmkeep.queue` are clients for key-value shards and
|
|
155
|
+
queues built from actors ([ADR 0015](https://github.com/WasmKeep/wasmkeep/blob/v0.2.0/docs/adr/0015-kv-and-queues-as-sdk-patterns.md)).
|
|
156
|
+
The shard and queue classes are the Rust SDK's: deploy the components of
|
|
157
|
+
[`examples/jobs`](https://github.com/WasmKeep/wasmkeep/tree/v0.2.0/examples/jobs)
|
|
158
|
+
as classes `kv` and `queue` (a release carries them already built, `kv.wasm`
|
|
159
|
+
and `queue.wasm`). These clients speak their protocol over `actors.call`, byte for byte like the
|
|
160
|
+
Rust and TypeScript clients, so all of them share the same data.
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from wasmkeep import Actor, kv, queue
|
|
164
|
+
|
|
165
|
+
store = kv.Client("kv", 8).with_read_cache(60_000) # 8 shards; get may serve 60 s old reads
|
|
166
|
+
jobs = queue.Client("queue/jobs")
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class App(Actor):
|
|
170
|
+
def fetch(self, req):
|
|
171
|
+
if queue.is_delivery(req): # a push from a queue
|
|
172
|
+
return queue.handle_delivery(req, lambda _queue, m: "ack")
|
|
173
|
+
version = store.put("user:42", "Ada")
|
|
174
|
+
store.compare_and_set("user:42", version, "Ada L.") # KvError "conflict" if it moved
|
|
175
|
+
jobs.send("resize 42")
|
|
176
|
+
return store.get("user:42").value
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
WitWorld, IncomingHandler = App.exports()
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
| | |
|
|
183
|
+
| --- | --- |
|
|
184
|
+
| `kv.Client(class_name, shards)` | Keys over `shards` actors `class_name/shard-<i>`; every caller uses the same count |
|
|
185
|
+
| `get(key)`, `get_fresh(key)` | An `Entry` (`value`, `version`, `expires_at`) or `None`; `get_fresh` skips the read cache |
|
|
186
|
+
| `put(key, value)`, `put_with(key, value, expect=, ttl_ms=, durable=)` | The new version; `expect` is `"any"`, `"absent"` or a version |
|
|
187
|
+
| `compare_and_set(key, expected, value)` | `put` only at version `expected` (`None`: absent) |
|
|
188
|
+
| `delete(key)`, `delete_if(key, version)` | `True` if the key was there |
|
|
189
|
+
| `list(prefix, after=None, limit=100)` | Keys (`bytes`) from every shard, in byte order |
|
|
190
|
+
| `queue.Client(address)` | One queue actor, `class/name` |
|
|
191
|
+
| `send(body)`, `send_delayed(body, ms)`, `send_batch(bodies)` | Ids, once durable; a batch (up to 1,000) is all or none |
|
|
192
|
+
| `lease(max, visibility_ms)`, `ack(m)`, `retry(m, delay_ms=None)`, `settle(items)` | Pull consumers; `ack` and `retry` are `False` for a stale lease |
|
|
193
|
+
| `stats()`, `dead_letters(limit)` | `Stats` (`ready`, `delayed`, `in_flight`, `dead`) and `DeadLetter`s |
|
|
194
|
+
| `queue.is_delivery(req)`, `queue.handle_delivery(req, handle)` | Push consumers: `handle(queue, message)` returns `"ack"`, `"retry"` or `queue.RetryAfter(ms)` |
|
|
195
|
+
|
|
196
|
+
Failures raise `kv.KvError` (`.kind`: conflict, key-too-long, storage, call,
|
|
197
|
+
refused with `.status`) and `queue.QueueError` (storage, call, refused);
|
|
198
|
+
numbers outside Rust's `u32`/`u64` raise `ValueError`. The
|
|
199
|
+
[guide](https://github.com/WasmKeep/wasmkeep/blob/v0.2.0/docs/kv-and-queues.md#python) covers the semantics and
|
|
200
|
+
limits; [`examples/py-jobs`](https://github.com/WasmKeep/wasmkeep/tree/v0.2.0/examples/py-jobs) is a working app.
|
|
201
|
+
|
|
202
|
+
## Workflows
|
|
203
|
+
|
|
204
|
+
`wasmkeep.workflow` starts and follows durable workflows
|
|
205
|
+
([ADR 0019](https://github.com/WasmKeep/wasmkeep/blob/v0.2.0/docs/adr/0019-workflows-as-an-sdk-pattern.md)): the
|
|
206
|
+
workflow class is written with the Rust SDK's runner (as
|
|
207
|
+
[`examples/workflows/orders`](https://github.com/WasmKeep/wasmkeep/tree/v0.2.0/examples/workflows/orders),
|
|
208
|
+
which a release carries already built, `workflows-orders.wasm`), one actor
|
|
209
|
+
per instance, and this client speaks its protocol over `actors.call`, like
|
|
210
|
+
the Rust `workflow::Client`. Only the client side is in Python.
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
from wasmkeep import workflow
|
|
214
|
+
|
|
215
|
+
orders = workflow.Client("orders") # instance `id` is actor `orders/<id>`
|
|
216
|
+
orders.start("order-42", "item=book") # a Status; idempotent while kept
|
|
217
|
+
orders.send_event("order-42", "approved", b"")
|
|
218
|
+
status = orders.status("order-42") # status.state, .output, .error, ...
|
|
219
|
+
orders.cancel("order-42")
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
| | |
|
|
223
|
+
| --- | --- |
|
|
224
|
+
| `workflow.Client(cls)` | Instances of the workflow class `cls` |
|
|
225
|
+
| `start(id, input=b"")` | Records the start (the instance runs in its own event, right after); returns its `Status` |
|
|
226
|
+
| `status(id)`, `cancel(id)` | The instance's `Status`; `cancel` stops it (a finished one is unchanged) |
|
|
227
|
+
| `send_event(id, name, payload=b"")` | Delivers an event, recorded durably |
|
|
228
|
+
| `Status` | `state` (`"running"`, `"waiting"`, `"completed"`, `"failed"`, `"cancelled"`), `wake_at`, `waiting_for`, `output`, `error`, `positions`, `is_finished` |
|
|
229
|
+
|
|
230
|
+
Failures raise `workflow.WorkflowError` (`.kind`: unknown, finished, call,
|
|
231
|
+
refused with `.status`). The [guide](https://github.com/WasmKeep/wasmkeep/blob/v0.2.0/docs/workflows.md#python) covers
|
|
232
|
+
the semantics.
|
|
233
|
+
|
|
234
|
+
## From a clone
|
|
235
|
+
|
|
236
|
+
The [examples](https://github.com/WasmKeep/wasmkeep/tree/v0.2.0/examples) build
|
|
237
|
+
against the SDK in the repository, with the same command
|
|
238
|
+
(`examples/py-counter/build.sh`): [counter](https://github.com/WasmKeep/wasmkeep/tree/v0.2.0/examples/py-counter),
|
|
239
|
+
[chat room](https://github.com/WasmKeep/wasmkeep/tree/v0.2.0/examples/py-chat-room),
|
|
240
|
+
[jobs](https://github.com/WasmKeep/wasmkeep/tree/v0.2.0/examples/py-jobs)
|
|
241
|
+
(key-value, queues and workflow orders). The protocol code
|
|
242
|
+
(`wasmkeep/wire.py`) imports no host bindings, so the SDK's unit tests run
|
|
243
|
+
under plain CPython, without componentize-py:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
sdks/python/test/run.sh # python3 -m unittest discover -s test
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Python components are large (about 19 MB, CPython included) and slower than
|
|
250
|
+
Rust: see [languages](https://github.com/WasmKeep/wasmkeep/blob/v0.2.0/docs/languages.md).
|
|
251
|
+
|
|
252
|
+
## License
|
|
253
|
+
|
|
254
|
+
Apache-2.0; see `LICENSE` and `NOTICE` in the package.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
wasmkeep/__init__.py,sha256=6GKfXDioyVSQ5mEof3Lr_1tCBst6Ri5AenQgLeMAakk,16310
|
|
2
|
+
wasmkeep/__main__.py,sha256=dz6l80XzZXSAGO5tVQEPA9ce42d3k-wRjGyVz1ZyNBE,4152
|
|
3
|
+
wasmkeep/_call.py,sha256=n90WoNMtRKzaCiRsegyBMgi8xG19DUfJeDnjhXCi9Os,1304
|
|
4
|
+
wasmkeep/kv.py,sha256=F9iuHhmdsSOZBH0VQSsHZCUe457ZLxMN0KragL7RSC0,9764
|
|
5
|
+
wasmkeep/queue.py,sha256=C09mo5lxyqPKVQ3VZms2c5iij1Id3l7rEhgbk4ulaYg,7901
|
|
6
|
+
wasmkeep/wire.py,sha256=C52YnKqu3ZmqZxp4tUgIeXukXoeDhu7j0g_NL7NFY9E,17049
|
|
7
|
+
wasmkeep/workflow.py,sha256=ekUaWzdKJ2kjRDGkMLOqyUdM2BdqCS_BPqRlNWVyH5Y,4370
|
|
8
|
+
wasmkeep/wit/actor.wit,sha256=saSp5z39e7ZGT59puv3PKha8bLefu2ywTzhQRqmE4h8,11509
|
|
9
|
+
wasmkeep/wit/deps/cli.wit,sha256=-2rF0j_K89IxFCo8L5ux6bwf5a9vHzKfaxpVVc4NOHM,6843
|
|
10
|
+
wasmkeep/wit/deps/clocks.wit,sha256=btiqZbuMviJKCyy6yfwbO9Jb2xftpa4NI8mD7THER8w,5867
|
|
11
|
+
wasmkeep/wit/deps/filesystem.wit,sha256=5nXyYQF7-bT6ffW5cBAj_gJJ7ecQIawb-Xh0jmLtzag,24592
|
|
12
|
+
wasmkeep/wit/deps/http.wit,sha256=S71Y9QlwCmY3OFYR8YPFvVmE2B_u-F4p39wF69KDBFo,31611
|
|
13
|
+
wasmkeep/wit/deps/io.wit,sha256=luIG0AB2-gSA3zLFvPJVo_pIYoBawva4U3p4HM5U9DM,13648
|
|
14
|
+
wasmkeep/wit/deps/random.wit,sha256=SFeMQCE9XKtmUJgJBfoUagvow5xEM-5efgBje4fb4I8,3349
|
|
15
|
+
wasmkeep/wit/deps/sockets.wit,sha256=rTjb87C73zTA8rYI7cv-4E1xtEOmP6_x9eAFPD-Es3c,46200
|
|
16
|
+
wasmkeep-0.2.0.dist-info/METADATA,sha256=Fsd8-4aP_Z3Q0Xuf-SWrJBSE3fXXKTB57QRJkEQgAs4,11745
|
|
17
|
+
wasmkeep-0.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
18
|
+
wasmkeep-0.2.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
19
|
+
wasmkeep-0.2.0.dist-info/licenses/NOTICE,sha256=oNnACLobuPOpDwv1QIi8kB_TIJwn8f_OrqDMqkCNk0o,632
|
|
20
|
+
wasmkeep-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
WasmKeep Python SDK
|
|
2
|
+
Copyright 2026 Julien Turbide
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
The WASI interface files in wasmkeep/wit/deps/ (copied from
|
|
7
|
+
crates/wasmkeep-wit/wit/deps/ in the WasmKeep repository) are Copyright the
|
|
8
|
+
Contributors to the WASI Specification, published by the WebAssembly
|
|
9
|
+
Community Group under the W3C Community Contributor License Agreement.
|
|
10
|
+
|
|
11
|
+
The SDK is built into a component with componentize-py, installed as a
|
|
12
|
+
separate package under its own license. A component built with it embeds
|
|
13
|
+
CPython and componentize-py's runtime, whose notices travel with that
|
|
14
|
+
component.
|