The standalone Link/Chain homoiconic composition primitives (UCO) — pure stdlib, zero deps.
Project description
universal-chain-ontology (UCO)
The standalone Link / Chain homoiconic composition primitives — the chain substrate that a lot of systems reimplement. Pure stdlib, zero dependencies.
from uco import Link, Chain, LinkResult, LinkStatus
class Inc(Link):
async def execute(self, context=None, **_):
ctx = dict(context or {}); ctx["n"] = ctx.get("n", 0) + 1
return LinkResult(status=LinkStatus.SUCCESS, context=ctx)
# a Chain IS a Link (homoiconic) — so Chains nest like any other Link
import asyncio
out = asyncio.run(Chain("two", [Inc(), Inc()]).execute({"n": 0}))
assert out.context["n"] == 2
What's here
| primitive | what it is |
|---|---|
Link |
ABC: execute(context) -> LinkResult |
Chain |
sequential composition of Links; a Chain IS a Link |
EvalChain |
a Chain + an evaluator loop (gate to a condition / max_cycles) |
Compiler |
a Chain whose output is itself a Link |
ConfigLink / LinkConfig |
config-driven Links |
LinkResult / LinkStatus |
the result + status enum (SUCCESS/BLOCKED/ERROR/AWAITING_INPUT) |
Why standalone
The same Link/Chain abstraction was living inside SDNA and getting copy-pasted into other projects. UCO is
that abstraction extracted once. Downstreams import uco; sdna.chain_ontology re-exports it, so existing
from sdna.chain_ontology import Link, Chain, … keeps working unchanged and the class identity is shared
(one Link everywhere).
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file universal_chain_ontology-0.1.0.tar.gz.
File metadata
- Download URL: universal_chain_ontology-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0b19e33ffa26fbd2dc0911e8e656ff3407b55ea2f32245969b19eddf2943367
|
|
| MD5 |
a355bd3d8378c54eb731484a4f4130bb
|
|
| BLAKE2b-256 |
1b79598cc51771a11462b126a9f42e8846bb459df74aa0de670adbf0b8c999de
|
File details
Details for the file universal_chain_ontology-0.1.0-py3-none-any.whl.
File metadata
- Download URL: universal_chain_ontology-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
231b3d5f6326c1bf568958d55f4ce850aa85928dfdf1c3f69b8942d85ac10b91
|
|
| MD5 |
dd82edd3547372b33d5ea1e67b5b6e24
|
|
| BLAKE2b-256 |
b5c01df4443b1cc4e7acf44e3a2635d5bd37f4c8bcaba06b32657f48827ee3dc
|