Thanks Daniel, this something I have been thinking about for a while.  One use 
case I have is for a dag only gets run on an ad hoc basis, for any combination 
of a subset of tasks (I recognize this is a rather non-standard use of 
airflow). One question though, if you specified skip_list=[“task b”] wouldn’t 
the scheduler skip task c as well?

James Coder
________________________________
From: Daniel Standish <[email protected]>
Sent: Friday, February 4, 2022 1:41:12 AM
To: [email protected] <[email protected]>
Subject: Re: [DISCUSSION] Specify tasks to skip when triggering DAG

That skip func had a typo (conf where it should have been context)...

this is more likely to work:

def skip_if_specified(context):
    if not context:
        return
    dr = context.get('dag_run')
    ti = context.get('task_instance')
    if not (dr and ti):
        return
    conf = dr.conf
    if not conf:
        return
    skip_list = conf.get('skip_list', [])
    if ti.task_id in skip_list:
        raise AirflowSkipException()

Apologies for the spam.

Reply via email to