feat(pipekit-ops): a readable recipe format with named steps
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 0
- Fork
- 0
- Merge medio
- 3h 50m
- PR unite (30g)
- 143
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di jejjohnson/pipekit
-
area:code layer:0-primitives priority:p2 type:feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jejjohnson/pipekit#296 ·
I maintainer di solito rispondono entro 1 giorno
-
area:code type:feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 57/100
jejjohnson/pipekit#411 ·
I maintainer di solito rispondono entro 1 giorno
-
area:code type:feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
jejjohnson/pipekit#410 ·
I maintainer di solito rispondono entro 1 giorno
-
area:code type:feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
jejjohnson/pipekit#409 ·
I maintainer di solito rispondono entro 1 giorno
-
area:code type:feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 75/100
jejjohnson/pipekit#408 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di jejjohnson/pipekit
Issue simili
-
A JSON chat answer blocks the backend event loop for the whole RAG runForse già presa @NopeCharon l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
The-OpenROAD-Project/ORAssistant#656 ·
I maintainer di solito rispondono entro 1 giorno
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorForse già presa @jejjohnson l’ha presa oggi. Apertatype:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
jejjohnson/integrix#144 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
finos/ai-governance-framework#459 ·
-
slurm: a case outcome nested too deep crashes status/collect instead of reading as no outcomeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno