Variable - class
pipeline.objects.variable.Variable( type_class: Any, *, is_input: bool = False, is_output: bool = False, name: str = None, remote_id: str = None, local_id: str = None )
Variable class acts as an input/output to nodes in the pipeline computation graph, or as input/output to the whole pipeline. It does not explicitly contain a value when defined in the context manager, but is used to refer to a value that will exist when the pipeline is run.
Variable class is instantiated either explicitly by the user, or created and returned by a
pipeline_function when that function is used in the
Pipeline context manager. It can only be defined when the Pipeline context manager is active.
Variable objects must be manually added to the context manager builder, and the builder must be notified of output
Variable objects. See the example below.
bool, optional) - states whether this variable is expected to be an input to the pipeline when the pipeline run function is called.
bool, optional) - states whether this variable is returned from the pipeline run function when called.
str, optional) - the name of the variable
str, optional) - the ID of the variable on a remote system. Not currently used.
str, optional) - the local UID of the variable that is referenced by graph nodes
Creating an input
from pipeline import Pipeline, Variable, pipeline_function @pipeline_function def add_numbers(a: int, b: int) -> int: return a + b with Pipeline("add-numbers") as pipeline: a = Variable(type_class=int, is_input=True) b = Variable(type_class=int, is_input=True) pipeline.add_variables(a, b) c = add_numbers(a, b) pipeline.output(c)
Updated 7 months ago