@graph decorator creates a reusable op graph - a composition of ops with defined dependencies. Graphs can be used within other graphs or converted to jobs.
Signature
Parameters
The name of the op graph. Must be unique within any
RepositoryDefinition containing the graph. If not provided, defaults to the function name.A human-readable description of the graph.
Information about the inputs that this graph maps. Information provided here will be combined with what can be inferred from the function signature, with these explicit InputDefinitions taking precedence.Uses of inputs in the body of the decorated composition function will determine the
InputMappings passed to the underlying GraphDefinition.Output definitions for the graph. If not provided explicitly, these will be inferred from type hints.Uses of these outputs in the body of the decorated composition function, as well as the return value of the decorated function, will be used to infer the appropriate set of
OutputMappings for the underlying GraphDefinition.To map multiple outputs, return a dictionary from the composition function.Information about the inputs that this graph maps. Information provided here will be combined with what can be inferred from the function signature, with these explicit GraphIn taking precedence.
Information about the outputs that this graph maps. Information provided here will be combined with what can be inferred from the return type signature if the function does not use yield.To map multiple outputs, return a dictionary from the composition function.
Arbitrary metadata for any execution run of the graph. Values that are not strings will be JSON encoded and must meet the criteria that
json.loads(json.dumps(value)) == value. These tag values may be overwritten by tag values provided at invocation time.Describes how the graph is configured at runtime.
- If a
ConfigMappingobject is provided, then the graph takes on the config schema of this object. The mapping will be applied at runtime to generate the config for the graph’s constituent nodes. - If a dictionary is provided, then it will be used as the default run config for the graph. This means it must conform to the config schema of the underlying nodes.
- If no value is provided, then the config schema for the graph is the default (derived from the underlying nodes).
Returns
Type:GraphDefinition
A graph definition object.
Examples
Basic Graph
Graph with Multiple Ops
Graph with Inputs and Outputs
Converting Graph to Job
Nested Graphs
Graph with Config Mapping
Graph with Multiple Outputs
Related
- @op - Define operations
- @job - Create executable jobs
- GraphIn - Define graph inputs
- GraphOut - Define graph outputs
- ConfigMapping - Map configuration
