Apache Airflow DAG cannot import local module : <p>I do not seem to understand how to import modules into an apache airflow DAG definition file. I would want to do this to be able to create a library which makes declaring tasks with similar settings less verbose, for instance.</p>

<p>Here is the simplest example I can think of that replicates the issue: I modified the airflow tutorial (<a href="https://airflow.apache.org/tutorial.html#recap" rel="noreferrer">https://airflow.apache.org/tutorial.html#recap</a>) to simply import a module and run a definition from that module. Like so:</p>

<p>Directory structure:</p>

<pre><code>- dags/
-- __init__.py
-- lib.py
-- tutorial.py
</code></pre>

<p>tutorial.py:</p>

<pre><code>"""
Code that goes along with the Airflow located at:
http://airflow.readthedocs.org/en/latest/tutorial.html
"""
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta

# Here is my added import
from lib import print_double

# And my usage of the imported def
print_double(2)

## -- snip, because this is just the tutorial code, 
## i.e., some standard DAG defintion stuff --
</code></pre>

<p><code>print_double</code> is just a simple def which multiplies whatever input you give it by 2, and prints the result, but obviously that doesn't even matter because this is an import issue.</p>

<p>I am able to run <code>airflow test tutorial print_date 2015-06-01</code> as per the tutorial docs successfully - the dag runs, and moreover the print_double succeeds. <code>4</code> is printed to the console, as expected. All appears well.</p>

<p>Then I go the web UI, and am greeted by <code>Broken DAG: [/home/airflow/airflow/dags/tutorial.py] No module named 'lib'</code>. Unpausing the dag and attempting a manual run using the UI causes a "running" status, but it never succeeds or fails. It just sits on "running" forever. I can queue up as many as I'd like, but they'll all just sit on "running" status.</p>

<p>I've checked the airflow logs, and don't see any useful debug information there.</p>

<p>So what am I missing?</p>
