Graphs
This section contains detailed reference documentation for writing Graphbook graphs in Python.
- class graphbook.Graph
Creates a new graph object that can be used to define a workflow. Use the step and resource methods to add nodes to the graph.
- get_resources() List[GraphResourceWrapper]
Returns all resources in the graph
- get_steps() List[GraphStepWrapper]
Returns all steps in the graph
- md(text: str)
Adds markdown documentation to demonstrate usage of the workflow
- Parameters:
text (str) – The markdown text to add
- resource(n: Resource) GraphResourceWrapper
Creates a new resource node in the graph
- Parameters:
n (Resource) – The resource to add to the graph
- Returns:
A wrapper around the resource node that can have parameters set
- Return type:
- step(n: Step) GraphStepWrapper
Creates a new step node in the graph
- Parameters:
n (Step) – The step to add to the graph
- Returns:
A wrapper around the step node that can be used to bind step dependencies and parameters
- Return type:
- class graphbook.core.serialization.GraphNodeWrapper(node: type, id: str)
Base class for step and resource nodes returned by the Graph class. Do not create this directly, use the Graph.step or Graph.resource methods instead.
- Parameters:
node (type) – The node to wrap
id (str) – The unique identifier for the node
- class graphbook.core.serialization.GraphStepWrapper(node: Step, id: str)
Bases:
GraphNodeWrapper
A wrapper class around a step node that allows for binding dependencies and setting parameters. Do not create this directly, use the Graph.step method instead.
- Parameters:
node (Step) – The step node to wrap
id (str) – The unique identifier for the node
- bind(src: GraphStepWrapper, key='out')
Binds this step to the output of another step
- Parameters:
src (GraphStepWrapper) – The source step to bind to
key (str) – The output key on the source step to bind to
- class graphbook.core.serialization.GraphResourceWrapper(node: Resource, id: str)
Bases:
GraphNodeWrapper
A wrapper class around a resource node that allows for setting parameters. Do not create this directly, use the Graph.resource method instead.
- Parameters:
node (Resource) – The resource node to wrap
id (str) – The unique identifier for the node