Ghanashyam Alakke
01/21/2022, 12:38 AMsandy
01/21/2022, 4:07 PMowen
01/21/2022, 5:08 PMGhanashyam Alakke
01/21/2022, 9:18 PMowen
01/25/2022, 9:26 PMproject_dir
and profiles_dir
at the op level, the best way is still to use resources at a job level. That would look something like this:
@op(required_resource_keys={'dbt'})
def op_run_dbt(context,project_dir:str,profiles_dir:str):
context.resources.dbt.run(
project_dir=project_dir,
profiles_dir=profiles_dir
)
@job(resource_defs={"dbt": dbt_cli_resource})
def my_job():
# ...
but if you have a hard requirement of not going through the resource system, you can create a resource instance from a resource definition by invoking it with a value for the "context" parameter (generally None is fine here).
@op
def op_run_dbt(context,project_dir:str,profiles_dir:str):
dbtcli_obj = dbt_cli_resource
result = dbt_cli_resource.configured(
{
"project_dir": project_dir,
"profiles_dir": profiles_dir,
}
)(context=None)
result.run()
To be clear, this isn't really a recommended pattern, but it should do what you're looking forGhanashyam Alakke
01/25/2022, 10:33 PM