feat(pipekit-ops): a readable recipe format with named steps
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Read packages/pipekit-ops/src/pipekit_ops/serial.py and _base/graph.py, focusing on dumps, loads, Graph.get_config, and Sequential serialization. Then inspect the package exports and serialization tests to see how state records and sandbox checks work. Done means the readable API round trips supported graphs, handles shared operators and nesting, and has tests and exports; YAML support and explicit step naming are design decisions still open in the issue.
Written by the indexing model from the issue text.
Description
Problem / Request
pipekit.dumps(graph) writes a record built for machines: operators in a list, nodes that point at operators and at each other by index. It round-trips, but nobody can read a recipe from it or edit one by hand. There is no readable format with named steps, though the serial.py docstring already promises YAML front ends in an optional extra (pipekit[yaml]), which no package ships.
User Story
As someone who keeps recipes in a repository, reviews them in pull requests and edits them by hand, I want a readable form of a Graph, with each step named and its inputs named, that loads back to the same Graph.
Motivation
Found while writing the GeoStack Kinds and Roles design page (jejjohnson/geostack#127), whose plume recipe has four steps. Its dumps today:
{
"class": "Graph",
"config": {
"inputs": ["scene", "wind"],
"nodes": [
{ "operator": 0, "parents": [{ "input": "scene" }] },
{ "operator": 1, "parents": [{ "node": 0 }] },
{ "operator": 2, "parents": [{ "input": "wind" }] },
{ "operator": 3, "parents": [{ "node": 0 }, { "node": 1 }, { "node": 2 }] }
],
"operators": [
{ "class": "MethaneRetrieval", "config": { "window_nm": [2122.0, 2488.0] }, "module": "plume" },
{ "class": "PlumeSegmentation", "config": { "k": 3.0, "min_pixels": 20 }, "module": "plume" },
{ "class": "WindAt", "config": { "lat": 31.98, "lon": -103.52 }, "module": "plume" },
{ "class": "EmissionRate", "config": { "kappa": 6.56e-07 }, "module": "plume" }
],
"outputs": { "emission": { "node": 3 } }
},
"module": "pipekit_ops._base.graph"
}
To see what EmissionRate takes, you count positions in nodes, then in operators. The page now shows a readable view built by a 20-line helper. It should be pipekit's: the same view in a notebook, a PR diff, a DVC params file and a GeoApps upload.
Proposed API
# readable records: plain dicts, no new dependency, in pipekit-ops
def to_readable(op: Operator) -> dict[str, Any]: ...
def from_readable(record: dict[str, Any]) -> Operator: ... # same checks as loads
def from_readable_sandboxed(record: dict[str, Any]) -> Operator: ... # allowlist, as loads_sandboxed
# YAML on top, in the optional extra the serial.py docstring names
def dumps_yaml(op: Operator) -> str: ... # pipekit[yaml]
def loads_yaml(text: str, *, sandboxed: bool = False) -> Operator: ...
Design Snapshot
The same recipe, readable:
graph:
inputs: [scene, wind]
steps:
methane_retrieval:
op: plume.MethaneRetrieval
in: [scene]
config: {window_nm: [2122.0, 2488.0]}
plume_segmentation:
op: plume.PlumeSegmentation
in: [methane_retrieval]
config: {k: 3.0, min_pixels: 20}
wind_at:
op: plume.WindAt
in: [wind]
config: {lat: 31.98, lon: -103.52}
emission_rate:
op: plume.EmissionRate
in: [methane_retrieval, plume_segmentation, wind_at]
config: {kappa: 6.56e-07}
outputs:
emission: emission_rate
Rules the format needs (the implementer decides the details, the tests pin them):
- Step names. By default, the operator's class in snake case, with
_2,_3, … when a class repeats. Explicit names are an open question: aname=on the symbolic call, or anames=mapping onGraph. in. The positional inputs, in order; each is a declared input or an earlier step, by name. The order ofstepsis the topological order, asnodesis now.op.module.Class, so the loader resolves it exactly asfrom_statedoes.confignested, not inlined. Inlining the config next toopandinwould break for any operator with a parameter calledoporin.- Shared operators. The machine record lists an operator once when several nodes use it. The readable form needs to keep that: for example
op: {same_as: methane_retrieval}. - Nesting. A
Sequentialinside a step reads as a list of{op, config}; aGraphinside a step reads as a nestedgraph:. - Round trip.
from_readable(to_readable(g)).state == g.statefor every Graphdumpsaccepts. Operators that setforbid_in_yamlrefuse, asloadsdoes.
References & Existing Code
packages/pipekit-ops/src/pipekit_ops/serial.py:dumps,loads,from_state_sandboxed,loads_sandboxed, and the docstring that namespipekit[yaml].packages/pipekit-ops/src/pipekit_ops/_base/graph.py:Graph.get_config, the record the readable form maps to and from.- The motivating page: jejjohnson/geostack#127,
docs/design/pages/kinds-and-roles.html, section "⑥ Recipe, and orchestration".
Implementation Steps
- Add
to_readable/from_readable/from_readable_sandboxedinpackages/pipekit-ops/src/pipekit_ops/serial.py, mapping to and from theGraph.get_configrecord (andSequential's), recursively. - Default step names, deduplicated; decide explicit names (call-site
name=orGraph(names=…)). - Shared operators and nested containers, as above.
-
dumps_yaml/loads_yamlbehind a[yaml]extra (PyYAML,safe_loadonly), or fix theserial.pydocstring if YAML stays out of scope. - Export the new functions from
pipekit_ops/__init__.py(and the umbrella, if that is wheredumpsis exported).
Definition of Done
- Code lands at the intended path
- Public API exported via
src/<package>/__init__.py - Tests pass:
make test - Lint + typecheck pass:
make lint && make typecheck - Docstrings (Google-style) on all public symbols
Testing
- Round trip: for a linear chain, a fan-in Graph, a Graph with a shared operator and a Graph nesting a
Sequential,from_readable(to_readable(g)).state == g.state. - Step names: deduplicated when a class repeats; stable across runs.
- A config with keys named
oporinsurvives the round trip. -
from_readable_sandboxedrejects a class outside the allowlist at any depth;forbid_in_yamloperators refuse. - YAML:
loads_yaml(dumps_yaml(g)).state == g.state, andloads_yamlnever constructs arbitrary Python objects (safe_load).
Documentation
- The serialisation docs page: the readable form next to the JSON, with the recipe above as the example.
Relationships
- Related: jejjohnson/geostack#127 (the design page that found it); #221, the multi-input signatures filed alongside this one.
Generated by Claude Code
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 3h 50m
- Merged PRs (30d)
- 143
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jejjohnson/pipekit
-
area:code layer:0-primitives priority:p2 type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jejjohnson/pipekit#296 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 57/100
jejjohnson/pipekit#411 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jejjohnson/pipekit#410 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 5/5 Over a week Newbie friendliness 38/100
jejjohnson/pipekit#409 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 75/100
jejjohnson/pipekit#408 ·
Maintainers usually reply within 1 day
All issues in jejjohnson/pipekit
Similar issues
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
h2oai/h2o-llmstudio#1163 ·
Maintainers usually reply within 1 day