pipeline.objects.graph.Graph
Graph - class
pipeline.objects.graph.Graph(
name: str = "",
variables: List[Variable] = None,
functions: List[Function] = None,
outputs: List[Variable] = None,
nodes: List[GraphNode] = None,
models: List[Model] = None,
compute_type: str = "gpu",
min_gpu_vram_mb: int = None,
)
Description
The Graph
class is the core object that contains the computational flow from everything defined in the Pipeline
context manager. The Graph
contains GraphNodes
which intern reference both Variable
and Function
objects.
Parameters
name
(str
, optional) - a user facing name for the graph.variables
(List[Variable]
, optional) - variables to be used by the graph nodes.functions
(List[Function]
, optional) - functions to be used in the graph nodes.outputs
(List[Variable]
, optional) - the output variables of the graph.nodes
(List[GraphNode]
, optional) - node present in the graph.models
(List[Model]
, optional) - model objects used throughout the graph.compute_type
(str
, optional) - the required compute resource for the graph (cpu
orgpu
).min_gpu_vram_mb
(int
, optional) - the minimum required GPU VRAM to run the graph.
Functions
_startup(self) -> None
_startup(self) -> None
Description
Run any nodes (functions) that have the on_startup
flag set to true.
The graph startup function is always called in the Graph.run(...)
function but can be called separately at any point.
run(self, *inputs: List[Any]) -> List[Any]
run(self, *inputs: List[Any]) -> List[Any]
Description
Run the inputs
through the computation graph. An array of values is then returned from the graph.
_update_function_local_id(self, old_id: str, new_id: str) -> None
_update_function_local_id(self, old_id: str, new_id: str) -> None
Description
Update the ID references for a function in the graph.
Parameters
old_id
(str
) - old ID of the function.new_id
(str
) - new ID to use for the function.
from_schema(cls, schema: PipelineGet) -> Graph
from_schema(cls, schema: PipelineGet) -> Graph
Description
Reform a graph from the PipelineGet
schema.
Parameters
schema
(PipelineGet
) - the schema containing the graph information.
save(self, save_path: str) -> None
save(self, save_path: str) -> None
Description
Serialise the Graph
object and write to a local file.
Parameters
save_path
(str
) - the path to write the graph.
load(cls, load_path: str) -> Graph
load(cls, load_path: str) -> Graph
Description
Load the Graph
object from a file.
Parameters
load_path
(str
) - the path to the graph file.
Updated 7 months ago