airflow-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Naik Kaxil <k.n...@reply.com>
Subject Re: How to trigger the dag to run immediately
Date Thu, 01 Feb 2018 20:17:14 GMT
As Sergei pointed out if you want to trigger DAG programmatically use "TriggerDagRunOperator".

Link to the class: https://pythonhosted.org/airflow/code.html?highlight=trigger#airflow.operators.TriggerDagRunOperator

You can also check the example at https://github.com/apache/incubator-airflow/blob/master/airflow/example_dags/example_trigger_controller_dag.py
And the DAG that is trigger from the above example is https://github.com/apache/incubator-airflow/blob/master/airflow/example_dags/example_trigger_target_dag.py

I hope that helps.


On 01/02/2018, 20:11, "Sergei Iakhnin" <llevar@gmail.com> wrote:

    You can trigger runs programmatically like this:
    
    def set_up_dag_run(context, dag_run_obj):
    
        dag_run_obj.payload = {"config": context["config"]}
    
        dag_run_obj.run_id = str(uuid4())
    
        print context
    
        return dag_run_obj
    
    
    my_dag_run = TriggerDagRunOperator(
    
            trigger_dag_id=my_workflow.workflow_name,
    
            python_callable=set_up_dag_run,
    
            task_id="run_my_workflow",
    
            owner="airflow")
    
    my_dag_run.execute({"config": effective_config})
    
    On Thu, Feb 1, 2018 at 9:05 PM Naik Kaxil <k.naik@reply.com> wrote:
    
    > Hi Song Liu,
    >
    > In Airflow 1.8 and higher there is a button for each dag on the dashboard
    > that looks like a play button, you will need to click on that button to
    > Trigger that DAG.
    >
    > More info: https://stackoverflow.com/a/43375518/5691525 .
    >
    > Regards,
    > Kaxil
    >
    > On 01/02/2018, 18:38, "Song Liu" <songliu@outlook.com> wrote:
    >
    >     Hi,
    >
    >     It seems that airflow scheduler is based on the start_date and
    > interval, but is that possible to be triggered only by user request on
    > demand immediately ? such as when user click a button "Run" then this dag
    > will be started right now and be stopped when finished.
    >
    >     Thanks for any information!
    >
    >     Thanks,
    >     Song
    >
    >
    >
    >
    >
    >
    > Kaxil Naik
    >
    > Data Reply
    > 38 Grosvenor Gardens
    > London SW1W 0EB - UK
    > phone: +44 (0)20 7730 6000 <+44%2020%207730%206000>
    > k.naik@reply.com
    > www.reply.com
    >
    -- 
    
    Sergei
    
    
    



Kaxil Naik 

Data Reply
38 Grosvenor Gardens
London SW1W 0EB - UK 
phone: +44 (0)20 7730 6000
k.naik@reply.com
www.reply.com
Mime
View raw message