https://dagster.io/ logo
#ask-ai
Title
# ask-ai
j

Jacob Marcil

02/16/2024, 6:35 PM
@Scout Can I use .map in a graph_asset?
s

Scout

02/16/2024, 6:35 PM
The documentation does not explicitly mention the use of
.map
within a
graph_asset
. The
graph_asset
decorator is used for defining an asset that's computed using a graph of ops, and the dependencies between the ops are specified inside the body of the decorated function. However, the use of
.map
specifically within this context is not detailed in the documentation provided. If you're looking to apply an operation to multiple elements or perform parallel execution within a
graph_asset
, you might need to look into other patterns supported by Dagster, such as dynamic outputs or fan-in/fan-out patterns, which are mentioned in the context of op graphs. For a definitive answer or example usage, you may want to refer to the latest Dagster documentation or explore the Dagster community resources such as GitHub discussions or issues for any updates or community practices regarding the use of
.map
in
graph_asset
.
j

Jacob Marcil

02/16/2024, 6:36 PM
@Scout Does graph_asset requires a return value?
s

Scout

02/16/2024, 6:36 PM
Yes, when using the
@graph_asset
decorator in Dagster, you are expected to return a value from the decorated function. This return value represents the asset or assets that are computed by the graph of ops within the
graph_asset
. The return value can be a single output or a dictionary mapping output names to return values from invoked nodes. Here's an example from the documentation that illustrates a
graph_asset
with a return value:
Copy code
python @graph_asset def my_graph_assets():     bar_1, bar_2 = bar()     foo_1, foo_2 = foo(bar_1)     return {"foo_asset": foo_1, "baz_asset": baz(foo_2, bar_2)}
In this example,
my_graph_assets
is a
graph_asset
that invokes two ops,
bar
and
foo
, and then returns a dictionary mapping the names of the assets to their respective values. The keys in the dictionary (
"foo_asset"
and
"baz_asset"
) correspond to the names of the assets being defined, and the values are the outputs from the ops that compute the assets. If you attempt to define a
graph_asset
without returning a value, or if the return value does not match the expected outputs, Dagster will raise an error indicating that the definition is invalid.
2 Views