Hi, I’d like to run “dbt deps” before “dbt run”. c...
# ask-community
g
Hi, I’d like to run “dbt deps” before “dbt run”. can you share which way is recommended?
j
cc @owen
g
thank you!
o
hi @Gatsby Lee! Are you using ops for this, or software-defined assets? and are you executing your job in a distributed manner (i.e. each step runs on a different node) or is everything running on the same machine?
g
I am currently trying to use ops
since I don’t know it is distributed or not, I guess it is not distributed.
in one container
o
got it -- you can make a
dbt_deps_op
pretty easily in that case. that would look something like
Copy code
@op(required_resource_keys={'dbt'})
def dbt_deps_op(context):
    context.resources.dbt.deps()
then you can hook up the built-in dbt_run_op with the dbt_deps op like this
Copy code
@job
def deps_and_run_job():
    dbt_run_op(start_after=dbt_deps_op())
g
I will try it. Thank you very much!!
o
no problem! I didn't directly test that code so it's possible there's a typo or something, let me know if you run into any issues 🙂
g
I have one following question.
how is the resource implementation looks like for
required_resource_keys={'dbt'})
?
I define resource sth like this for models
Copy code
dbt_resource_all_models = dbt_cli_resource.configured(
    {
        "project_dir": "../dbt_data_tf",
        "profiles_dir": "../dbt_data_tf",
    }
)
do I have to define a resource “dbt” for “deps” as well?
o
nope! both of these ops are requiring a resource named "dbt", so when you supply that resource to your job (
resource_defs={"dbt": dbt_resource_all_models, ...}
), both the dbt deps op and the dbt run op will use that same resource
g
ah i see.
Thank you very much!!
dagstir 1
hi. the api
deps
doesn’t exist.
AttributeError: 'DbtCliResource' object has no attribute 'deps'
o
ah sorry, my bad! I misremembered it being there -- you can do
context.resources.dbt.execute_cli("deps")
instead
g
ah.. Thank you. Thank you!!
let me try with it.
hmm. the
execute_cli
also doesn’t exist.
AttributeError: 'DbtCliResource' object has no attribute 'execute_cli'
do you know where I can find the api reference for DbtCliResource?
maybe this ? - c
o
double facepalm facepalm -- it's just
cli
(sorry again) and I'll grab the api docs for you
ah yeah that's it
g
hehe. np.
it helps me find the api reference
thank you again. 😄
o
no prob, appreciate your patience 🙂
❤️ 1
g
thank you for your reply 😄
r
belated thanks to both of you for this thread!
was just helpful