mufasa.graph_svg.spec#

Graph descriptions: nodes with their data types, and edges. Built from a Graph or from example code.

Exceptions#

FusionGraphCodeError

Inappropriate argument value (of correct type).

Classes#

Functions#

spec_from_graph(graph) → GraphSpec

Describe a built Graph, with the data types its nodes resolved at construction and wiring.

class_types(cls) → tuple[list[type], type | None]

Data types declared by a node class.

spec_from_code(source) → GraphSpec

Describe the graph that example code builds, without running it.

Module Contents#

class mufasa.graph_svg.spec.NodeSpec#
id: str#
cls: type#
input_types: list[type]#
output_type: type | None#
property is_input: bool#
Return type:

bool

property is_output: bool#
Return type:

bool

class mufasa.graph_svg.spec.GraphSpec#
nodes: dict[str, NodeSpec]#
edges: list[tuple[str, str]] = []#
exception mufasa.graph_svg.spec.FusionGraphCodeError(message: str, lineno: int | None = None)#

Bases: ValueError

Inappropriate argument value (of correct type).

Initialize self. See help(type(self)) for accurate signature.

Parameters:
  • message (str)

  • lineno (int | None)

mufasa.graph_svg.spec.spec_from_graph(graph) → GraphSpec#

Describe a built Graph, with the data types its nodes resolved at construction and wiring.

Return type:

GraphSpec

mufasa.graph_svg.spec.class_types(cls: type) → tuple[list[type], type | None]#

Data types declared by a node class.

Nodes that resolve their types later (at construction or wiring) declare their broadest valid types on the class, so a graph drawn from code shows what a class accepts and produces in general.

Parameters:

cls (type)

Return type:

tuple[list[type], type | None]

mufasa.graph_svg.spec.spec_from_code(source: str) → GraphSpec#

Describe the graph that example code builds, without running it.

Understands from module import NodeClass and assignments name = NodeClass(...) (a source) or name = NodeClass(...)(input, ...). Everything else, such as Graph(...) or graph.run(), is ignored.

Parameters:

source (str)

Return type:

GraphSpec