serializer
serializer
#
Flatten a Procedure DAG to the cross-platform wire form.
The wire form is {"schema", "root", "nodes"}:
schemais the targetStruct's wire form — the a-priori data schema, emitted once, that replaces the runtime manifest.rootis the id of the root node;nodesmaps id → node.- each node records its
kind(class name),return_type,label,settings,inputs(field name → id), andsubsteps(list of ids); falsy entries are omitted.Path/Voidreturn types serialize compactly ({"type": "path"}/{"type": "void"}) since their structure is recoverable fromschemaplus the access chain.
procedure_to_dict(procedure, target_schema=None)
#
Serialize a Procedure DAG to {"schema"?, "root", "nodes"}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
procedure
|
Procedure[CGType]
|
The root Procedure node to serialize. |
required |
target_schema
|
type[CGType] | None
|
The target |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The serialized procedure graph. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a ProcedureWhile violates loop invariants. |
Source code in capturegraph-lib/capturegraph/procedures/procedure/exporting/serializer.py
procedure_to_json(procedure, indent=4, target_schema=None, **json_kwargs)
#
Serialize a Procedure DAG to a JSON string (see [procedure_to_dict][]).