Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow manual trigger arguments to be passed to dbt nodes #151

Closed
MikeWallis42 opened this issue Feb 17, 2023 · 3 comments · Fixed by #623
Closed

Allow manual trigger arguments to be passed to dbt nodes #151

MikeWallis42 opened this issue Feb 17, 2023 · 3 comments · Fixed by #623
Labels
enhancement New feature or request
Milestone

Comments

@MikeWallis42
Copy link
Contributor

Things like dbt's full-refresh are likely to be run in exceptional circumstances and should not need a deployment to trigger.
In the style of a user story:

As a Cosmos user I'd like to be able to override some dbt command line flags for specific or all nodes via Airflow params so that I don't have to re-deploy my DAG to production for a one-off DAG run.

@chrishronek chrishronek added the enhancement New feature or request label Mar 17, 2023
@chrishronek
Copy link
Contributor

@MikeWallis42 not sure how this would work since our global args and command-specific args are parameters on the operators. Can you clarify what the vision is here?

@MikeWallis42
Copy link
Contributor Author

@pohek321 it's possible to pass in JSON configuration to an Airflow DAG when manually triggering it.
I'm wondering whether we could allow users to pass something in like.

{
  "run": [
    {
      "model_name": "orders",
      "args": [
        "--full-refresh"
      ]
    }
  ]
}

Within the operator then we can get these from the DAG run context and merge them with the others.

run_args = context["dag_run"].conf.get("run")

We should stipulate what can and can't be added which might inform the JSON structure. I'm just trying to limit the amount of DAG authoring we might have to do because quite a lot of us don't have production access so would have to dev and release to be able to do and ad-hoc process like a full refresh.

@tatiana tatiana added this to the 1.3.0 milestone Oct 24, 2023
@joppevos
Copy link
Contributor

Passing configuration through the DAG configuration is super useful and I would love to see that.
We started a discussion here on Slack

I will try to make a PR that allows templating of the operator_args, so that we can do something like the following example:

operator_args={"full-refresh": True if "{{ dag_run.conf.get('full_refresh') }}" == 'True' else False},

@tatiana tatiana closed this as completed in 9cd46d2 Nov 8, 2023
tatiana pushed a commit that referenced this issue Nov 9, 2023
This allows you to fully refresh a model from the console.
Full-refresh/backfill is a common task. Using Airflow parameters makes
this easy. Without this, you'd have to trigger an entire deployment. In our
setup, company analysts manage their models without modifying
the DAG code. This empowers such users.

Example of usage:
```python
with DAG(
        dag_id="jaffle",
        params={"full_refresh": Param(default=False, type="boolean")},
        render_template_as_native_obj=True
):
    task = DbtTaskGroup(
        operator_args={"full_refresh": "{{ params.get('full_refresh') }}", "install_deps": True},
    )

```

Closes: #151
arojasb3 pushed a commit to arojasb3/astronomer-cosmos that referenced this issue Jul 14, 2024
This allows you to fully refresh a model from the console.
Full-refresh/backfill is a common task. Using Airflow parameters makes
this easy. Without this, you'd have to trigger an entire deployment. In our
setup, company analysts manage their models without modifying
the DAG code. This empowers such users.

Example of usage:
```python
with DAG(
        dag_id="jaffle",
        params={"full_refresh": Param(default=False, type="boolean")},
        render_template_as_native_obj=True
):
    task = DbtTaskGroup(
        operator_args={"full_refresh": "{{ params.get('full_refresh') }}", "install_deps": True},
    )

```

Closes: astronomer#151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants