How exactly does the subDAG work in Airflow? What does it mean for a subDAG to be enabled?
<p>I have looked at the Airflow subDAG section and tried to find anything else online that would be helpful, however I have not found anything that explained in detail how to make a subDAG work. One of the requirements for a subDAG to run is that it should be enabled. How do you enable/disable a subdag?</p>

<p>I wrote some sample code that doesn't show any errors in airflow, however when I try to run it, none of the operators in the subDAG get executed. </p>

<p>This is my main dag code:</p>

<pre><code>import os
from airflow import DAG
from airflow.operators import BashOperator
from datetime import datetime, timedelta
from airflow.operators.subdag_operator import SubDagOperator
from linecount_subdag import sub_dag

parent_dag_name = 'example_linecount_dag'
child_dag_name = 'example_linecount_subdag'

args = {
    'owner': 'airflow',
    'start_date': datetime(2016, 04, 20),
    'retries': 0,
}
main_dag = DAG(
    dag_id=parent_dag_name,
    default_args=args,
    schedule_interval=timedelta(minutes=5),
    start_date=datetime(2016, 04, 20),
    max_active_runs=1
)

subdag = SubDagOperator(
    subdag=sub_dag(parent_dag_name, child_dag_name, args, main_dag.schedule_interval),
    task_id=child_dag_name,
    default_args=args,
    dag=main_dag)
t = BashOperator(
    task_id='start',
    bash_command='echo "waiting for subdag..."',
    default_args=args,
    dag=main_dag)
t.set_downstream(subdag)
</code></pre>

<p>In this code, the task 'start' succeeds, however the subdag task doesn't do anything and neither fails nor succeeds.</p>

<p>Here is my subDAG code:</p>

<pre><code>from airflow.models import DAG
from airflow.operators import BashOperator

# Dag is returned by a factory method
def sub_dag(parent_dag_name, child_dag_name, args, schedule_interval):
  dag = DAG(
    '%s.%s' % (parent_dag_name, child_dag_name),
    default_args=args,
    start_date=args['start_date'],
    max_active_runs=1,
  )
  t1 = BashOperator(
    task_id='count_lines',
    bash_command='cat /root/airflow/airflow.cfg | wc -l',
    default_args=args,
    xcom_push=True,
    dag=dag)
  t2 = BashOperator(
    task_id='retrieve_val',
    bash_command='grep "airflow_home" /root/airflow/airflow.cfg',
    default_args=args,
    xcom_push=True,
    dag=dag)
  templated_command = """
    {
        echo "{{ ti.xcom_pull(task_ids='count_lines') }}"
        echo "{{ ti.xcom_pull(task_ids='retrieve_val') }}"
    }"""
  t3 = BashOperator(
    task_id='print_values',
    bash_command=templated_command,
    default_args=args,
    dag=dag)
  t3.set_upstream(t1)
  t3.set_upstream(t2)
  return dag
</code></pre>

<p>The 3 operators in this code get the number of lines of the file "airflow.cfg", find the value of "airflow_home" in that file, and return both of those values to be printed. This code works on its own, so I don't think it's the problem. </p>

<p>What do I have to change to make the subDAG execute its operators?</p>