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

DBT #1421

Open
AkashSonu14 opened this issue Dec 23, 2024 · 3 comments
Open

DBT #1421

AkashSonu14 opened this issue Dec 23, 2024 · 3 comments
Labels
area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc

Comments

@AkashSonu14
Copy link

Hi,
I want code for batch job executing and its triggers when the previous job is fails, in the integration of dbt cosmos and airflow

Copy link

dosubot bot commented Dec 23, 2024

I couldn't find specific information in the Cosmos documentation about handling task dependencies to trigger a job only when the previous one fails. However, in Apache Airflow, you can achieve this by using the TriggerRule class. You can set the trigger_rule parameter of a task to TriggerRule.ONE_FAILED to ensure it runs only if the previous task fails.

Here's a basic example of how you might set this up in an Airflow DAG:

from airflow import DAG
from airflow.operators.dummy import DummyOperator
from airflow.utils.dates import days_ago
from airflow.utils.trigger_rule import TriggerRule

with DAG(dag_id='example_dag', start_date=days_ago(1), schedule_interval='@daily') as dag:
    task_1 = DummyOperator(
        task_id='task_1',
    )

    task_2 = DummyOperator(
        task_id='task_2',
        trigger_rule=TriggerRule.ONE_FAILED,
    )

    task_1 >> task_2

In this example, task_2 will only execute if task_1 fails. You can apply similar logic to your dbt tasks within the Cosmos integration by setting the trigger_rule for the relevant tasks.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc label Dec 23, 2024
@pankajastro
Copy link
Contributor

Hey @AkashSonu14. Could you please confirm if this request in not a duplicate of #1419

@AkashSonu14
Copy link
Author

@pankajastro I can't understand what you are saying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc
Projects
None yet
Development

No branches or pull requests

2 participants