Salina Wu
05/10/2022, 6:43 PMdbt_docs_generation_op
) to run if i'm running dagster locally. this didn't seem to work - can someone point me in the right direction?
# base graph for running dbt transformations.
# this will run transformations, run dbt test, and deploy the dbt documentation
@graph
def run_dbt_transformations():
env = os.getenv('ENVIRONMENT')
if env == Env.DEV:
test_dbt_models(after=run_dbt_models())
else:
dbt_docs_generation_op(after=test_dbt_models(after=run_dbt_models()))
# dagster jobs for specific model groups. they use the same dagster graph but with different dagster-dbt resources
dbt_run_assist_models = run_dbt_transformations.to_job(resource_defs={"dbt_resource": dbt_resource_assist}, tags=DBT_DOCS_K8S_CONFIG, name="dbt_run_assist_models")
my DBT_DOCS_K8S_CONFIG:
DBT_DOCS_K8S_CONFIG = {
"dagster-k8s/config": {
"pod_spec_config": {
"serviceAccountName": "dbt-data-transformation",
"volumes": [{"name": "config-secrets", "secret": {"secret_name": "github-app-secret"}}]
},
"container_config": {
"resources": {
"requests": {"cpu": "250m", "memory": "64Mi"},
"limits": {"cpu": "500m", "memory": "2560Mi"},
},
"volume_mounts": [
{"name": "config-secrets", "mount_path": "/etc/secrets"}
],
"envFrom": [ # THIS IS WHERE ENVIRONMENT IS PASSED IN
{
"configMapRef": {
"name": "dbt-custom-run-env"
}
}
]
}
}
}
yuhan
05/10/2022, 7:24 PMowen
05/10/2022, 8:22 PM@op(required_resource_keys={"dbt"}, ins={"start_after": In(Nothing)})
def dbt_docs_generation_op(context):
if env != Env.DEV:
context.resources.dbt.generate_docs()
Salina Wu
05/10/2022, 8:25 PMSalina Wu
05/10/2022, 10:00 PMowen
05/10/2022, 10:06 PMfrom dagster import Field
@op(config_schema={"should_run": Field(bool, default_value=True)}, required_resource_keys={"dbt"}, ins={"start_after": In(Nothing)})
def dbt_docs_generation_op(context):
if context.op_config.should_run:
context.resources.dbt.generate_docs()
then, when you're creating the dev version of this graph, you can supply a False value for this configuration option to "turn off" this opowen
05/10/2022, 10:07 PMSalina Wu
05/10/2022, 10:18 PMowen
05/10/2022, 11:56 PM.to_job(..., config={"ops": {"dbt_docs_generation_op": {"config": {"should_run": False}}}})
)owen
05/10/2022, 11:56 PMowen
05/10/2022, 11:57 PMdbt_run_assist_models_dev = run_dbt_transformations.to_job(..., config=<that config>)
dbt_run_assist_models_prod = run_dbt_transformations.to_job(...)