https://dagster.io/ logo
#ask-community
Title
# ask-community
t

Thomas Haederle

03/26/2023, 3:32 PM
I am having issues with the “context for assets”. from the documentation it appears that one can pass a context parameter to an asset to get access to system resources; however, when I do this on my assets, I get an error that the compute function of my asset has a “context” argument, but that I have not provided a context.
f

Frederik Löw

03/27/2023, 6:13 AM
Can you provide some minimal code of how you use it? For me this works as expected. I can see the log in the run overview.
Copy code
@asset(group_name="context")
def test_context(context:OpExecutionContext):
    <http://context.log.info|context.log.info>("test")
    pass
s

sean

03/27/2023, 4:54 PM
Hi Thomas, Are you directly invoking the asset (like this):
Copy code
@asset
def some_asset(context):
    return 1

some_asset()
If you are, it’s complaining because no context is provided-- when your asset runs as part of a job, Dagster has a defined context that it injects, but that context doesn’t exist for direct invocation, so you have to create one using `build_op_context`: https://docs.dagster.io/_apidocs/execution#dagster.build_op_context
11 Views