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

Jeferson Machado Santos

05/23/2023, 7:30 PM
Hi Folks, is there anyway to trigger an asset materialization from inside an op? something lis:
Copy code
@op
def trigger_asset_materialization():
    materialize_asset(asset_key=[.....])
o

owen

05/23/2023, 8:57 PM
hi @Jeferson Machado Santos ! answered this question here: https://dagster.slack.com/archives/C01U954MEER/p1684872544643039
j

Jeferson Machado Santos

05/23/2023, 8:57 PM
Yes, but is it possible with asset key?
because i am importing assets from dbt manifest, so I am not defining them with @asset
o

owen

05/23/2023, 9:00 PM
ah in that case you could do
Copy code
dbt_assets = load_assets_from_dbt_manifest(...)

@op
def my_op(context):
   materialize(assets=[dbt_assets], instance=context.instance, selection=AssetSelection.keys("my_key", "my_other_key"))
however, the same general advice of "this should probably be in a `define_asset_job`" applies
j

Jeferson Machado Santos

05/23/2023, 9:00 PM
yeah, but i need to materialize only some of the assets in dbt_assets
not all of them
ah, I see, I can use selection, right?
👍 1
thanks
o

owen

05/23/2023, 9:02 PM
blob salute
j

Jeferson Machado Santos

05/23/2023, 9:44 PM
It worked perfect owen, thank you very much
and yes, I used define_asset_job.