title: Airflow DAG in functions?
body: <p>I am working in <code>$AIRFLOW_HOME/dags</code>. I have created the following files:</p>
  
  <pre><code>- common
    |- __init__.py   # empty
    |- common.py     # common code
  - foo_v1.py        # dag instanciation
  </code></pre>
  
  <p>In <code>common.py</code>:</p>
  
  <pre><code>default_args = ...
  
  def create_dag(project, version):
    dag_id = project + '_' + version
    dag = DAG(dag_id, default_args=default_args, schedule_interval='*/10 * * * *', catchup=False)
    print('creating DAG ' + dag_id)
  
    t1 = BashOperator(
      task_id='print_date',
      bash_command='date',
      dag=dag)
  
    t2 = BashOperator(
      task_id='sleep',
      bash_command='sleep 5',
      retries=3,
      dag=dag)
  
    t2.set_upstream(t1)
  </code></pre>
  
  <p>In <code>foo_v1.py</code>:</p>
  
  <pre><code> from common.common import create_dag
  
   create_dag('foo', 'v1')
  </code></pre>
  
  <p>When testing the script with python, it looks OK:</p>
  
  <pre><code> $ python foo_v1.py
   [2018-10-29 17:08:37,016] {__init__.py:57} INFO - Using executor SequentialExecutor
   creating DAG pgrandjean_pgrandjean_spark2.1.0_hadoop2.6.0
  </code></pre>
  
  <p>I then launch the webserver and the scheduler locally. My problem is that I don't see any DAG with id <code>foo_v1</code>. There is no <code>pyc</code> file being created. What is being done wrong? Why isn't the code in <code>foo_v1.py</code> being executed?</p>