airflow
airflow copied to clipboard
schedule_interval can break tree view
Airflow.tree fails to deal with schedule_intervals longer than one day and I think it would also have problems with intervals that don't fit neatly into a single day.
Changing the section
num_runs = request.args.get('num_runs')
num_runs = int(num_runs) if num_runs else 25
from_time = datetime.min.time()
if dag.start_date:
from_time = dag.start_date.time()
from_date = (base_date-(num_runs * dag.schedule_interval)).date()
from_date = datetime.combine(from_date, from_time)
to
start_date = dag.start_date
if not start_date:
start_date = dag.default_args['start_date']
if start_date:
difference = base_date - start_date
offset = timedelta(seconds=int(difference.total_seconds() % dag.schedule_interval.total_seconds()))
base_date -= offset
base_date -= timedelta(microseconds=base_date.microsecond)
num_runs = request.args.get('num_runs')
num_runs = int(num_runs) if num_runs else 25
from_time = datetime.min.time()
from_date = (base_date-(num_runs * dag.schedule_interval))
seems to have fixed this. I've tested with a number of start_date/scheduler combinations and i've not had any issues however there may be some corner cases I've not considered.
PR please!
This is fixed