DagsterDocs

Dynamic Graphs (Experimental)

class dagster.experimental.DynamicOutputDefinition(dagster_type=None, name=None, description=None, is_required=None, io_manager_key=None, metadata=None, asset_key=None, asset_partitions=None)[source]

(EXPERIMENTAL) Variant of OutputDefinition for an output that will dynamically alter the graph at runtime. Each copy of DynamicOutput corresponding to this definition that is yielded from the solid will create a copy of the downstream graph.

@solid(
    config_schema={
        "path": Field(str, default_value=file_relative_path(__file__, "sample"))
    },
    output_defs=[DynamicOutputDefinition(str)],
)
def files_in_directory(context):
    path = context.solid_config["path"]
    dirname, _, filenames = next(os.walk(path))
    for file in filenames:
        yield DynamicOutput(os.path.join(dirname, file), mapping_key=_clean(file))
class dagster.experimental.DynamicOutput(value, mapping_key, output_name='result', metadata_entries=None)[source]

(Experimental) Variant of Output used to support mapping. Each DynamicOutput produced by a solid will result in the downstream dag being cloned to run on that individual value. Each DynamicOutput must have a unique mapping_key to distinguish it.

Parameters
  • value (Any) – The value returned by the compute function.

  • mapping_key (str) – The key that uniquely identifies this dynamic value relative to its peers.

  • output_name (Optional[str]) – Name of the corresponding output definition. (default: “result”)

  • metadata_entries (Optional[Union[EventMetadataEntry, PartitionMetadataEntry]]) – (Experimental) A set of metadata entries to attach to events related to this Output.