Daniel Michaelis
02/06/2024, 12:18 PMScout
02/06/2024, 12:18 PMpython
@op
def my_op(context: OpExecutionContext, param: int) -> int:
# Your op logic here
return param + 1
2. When constructing your graph-backed assets, you can use the .alias
method on the op invocation to give it a unique name within the graph and pass different parameters to each aliased op. For example:
python
@graph
def graph_asset_one():
# Using the op with one parameter
my_op.alias("op_with_param_1")(param=1)
@graph
def graph_asset_two():
# Reusing the op with a different parameter
my_op.alias("op_with_param_2")(param=2)
3. Create asset definitions from these graphs using the AssetsDefinition.from_graph
method. For example:
python
asset_def_one = AssetsDefinition.from_graph(graph_asset_one)
asset_def_two = AssetsDefinition.from_graph(graph_asset_two)
By following these steps, you can reuse the same op in different graph-backed assets with different parameters. Each aliased op within the graph can be configured independently, allowing for the reuse of op logic while varying the parameters as needed for each asset. enable executing a subset of steps in a ... button Dagster 0.15.0: Cool for the Summer | Da... button Thank you for your feedback!