Martin Laurent
02/06/2024, 4:26 PM"context" is not a valid name in Dagster. It conflicts with a Dagster or python reserved keyword.
Scout
02/06/2024, 4:26 PM@graph_asset
, you should not use context
as a parameter name because it conflicts with a reserved keyword in Dagster. However, it's important to note that @graph_asset
is a composition function, and composition functions have specific semantics that do not align with the use of a context parameter. If you need to define a @graph_asset
that depends on another upstream asset, you should specify the dependencies using the deps
parameter without including a context parameter. Here's an example of how you might define such a dependency without using `context`: python from dagster import graph_asset @graph_asset def my_upstream_asset(): # ... define the upstream asset ... pass @graph_asset def my_graph_asset(my_upstream_asset): # ... define the graph asset that depends on the upstream asset ... pass
In this example, my_graph_asset
depends on my_upstream_asset
, and the dependency is declared by including my_upstream_asset
as a parameter in the definition of my_graph_asset
. If you need to access the AssetExecutionContext
within an asset, you would typically do this within an @asset
-decorated function, not within a @graph_asset
. Here's an example of how you might use AssetExecutionContext
within an `@asset`: python from dagster import asset, AssetExecutionContext @asset def my_asset(context: AssetExecutionContext): # ... use the context to access loggers, resources, etc. ... pass
Remember that @graph_asset
is used to compose assets and define their dependencies, and it does not perform computation itself. If you need to perform computation and access execution context, you should use @asset
instead.