:wave: I’ve a problem setting a hook to an asset j...
# ask-community
r
👋 I’ve a problem setting a hook to an asset job, here is the minimal code with the issue:
Copy code
from dagster import asset, failure_hook, Definitions, define_asset_job


@asset
def my_asset():
    return 1


@failure_hook(required_resource_keys={'my_resource'})
def my_hook(context):
    print("hello hook")


definitions = Definitions(
    assets=[my_asset],
    jobs=[define_asset_job("my_job", selection='my_asset', hooks={my_hook})],
    resources={
        'my_resource': None
    }
)
When I run Dagit then I get:
Copy code
dagster._core.errors.DagsterInvalidDefinitionError: resource with key 'my_resource' required by hook 'my_hook' attached to job 'my_job' was not provided. Please provide a <class 'dagster._core.definitions.resource_definition.ResourceDefinition'> to key 'my_resource', or change the required key to one of the following keys which points to an <class 'dagster._core.definitions.resource_definition.ResourceDefinition'>: ['io_manager']
This error does not happen when instead of creating the job from an asset, I create it from a graph via the
<http://graph.to|graph.to>_job
method. I’m running on dagster 1.3.11
🤖 1
should I open a new issue on Github?
s
Hi Riccardo, thanks for the report-- this looks like a genuine bug in resource binding, yes pls open an issue on GH and we’ll get it addressed.
r
b
There's an already existing issue here
s
Ah, thank you Brian, apologies Riccardo I didn’t realize that hooks with SDAs weren’t currently supported!
r
according to your docs they should be supported https://docs.dagster.io/changelog#138-core--0198-libraries indeed from that version
define_asset_job
accepts hooks now, before it didn’t
b
Sorry, linked to the wrong issue. If you check this thread here. Owen mentions a fix is coming in this week's release
👍 1