Hello everyone, how can I pass resource definition...
# ask-community
b
Hello everyone, how can I pass resource definitions to define_asset_job similar to job? # test @graph_asset() def middle_asset(): return optimize_table_op(get_data_op(create_dataset_op())) middle_asset_schedule = ScheduleDefinition( _cron_schedule_="* * * * *", job=define_asset_job( name="middle_asset_job", selection=[middle_asset] ) )
z
I usually use
with_resources
to tie the resources to the asset, then define the asset job using the resource-associated assets. Something like this:
Copy code
from dagster import with_resources

@graph_asset()
def middle_asset():
    return optimize_table_op(get_data_op(create_dataset_op()))

middle_asset_with_resources = with_resources([middle_asset], resource_defs={"db": my_db_resource})

middle_asset_schedule = ScheduleDefinition(
    cron_schedule="* * * * *",
    job=define_asset_job(
            name="middle_asset_job",
            selection=[middle_asset_with_resources]
        )
    )
I'm not sure if new ways to do it have been exposed recently though, I'm not as familiar with the new ConfigurableResource system
b
I had already tried something similar, but I forgot to remove the asset from the selection list and pass the resource key to operations, with the adjustments it worked, thanks for the support
🎉 1