Hi, Is possible update the selection of a previous...
# ask-community
s
Hi, Is possible update the selection of a previous "define_asset_job" created? My use case is: I have a dbt project with multiple models and I have "N selection rules" for these models. So I am thinking that I will need to create N "jobs" with "define_asset_job" by N "selection rules". So I was thinking only create a job and update the selections rules on the fly. is possible?
o
hi @Saul Burgos! how are you planning on launching executions of this job, and what sort of selection rules are you imagining? in general, you can materialize any subset of a job from the UI, or in a sensor, but how you define those selections might differ
s
I have a custom webapp that show a list of dbt models and users can select what models want to materialized , so the combinations of selections can be unlimited and additional custom rules that the user con set. EX: only run this model if these others 2 models have been materialized, etc I have to take this user selections and rules and using dagster I want to run the assets (dbt models) based on my custom rules. My idea was used "define_asset_job" with the select property. So after run my custom rules I will have a "Sequence[AssetKey]" to pass. and I only need to run the job But I am realizing that I need to create N Jobs for my unpredictable rules. I have these idea that maybe I can update only the selection. If there another way to "materialized assets" using only code. Not the UI. I guess my use case is: I want to run a job that have N assets and every time this job run ... I want to define which assets should be materialized un runtime. I hope my explanation was good
o
ah as long as you can compile those requests down into a
Sequence[AssetKey]
, then you can just have a single job. That base job will contain all of the assets. From there, it depends on what execution APIs you want to invoke. If you're doing things in python (i.e. using
execute_job
), then you can pass in this sequence of asset keys into the
asset_selection
argument, which will make sure that only the selected asset keys get executed. If you're executing over GraphQL, then there is a similar asset_selection parameter that also accepts a list of asset keys
❤️ 1