You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bo...@apache.org on 2017/11/27 20:39:46 UTC
[09/11] incubator-airflow git commit: [AIRFLOW-1827] Fix api endpoint
date parsing
[AIRFLOW-1827] Fix api endpoint date parsing
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/f43c0e9b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/f43c0e9b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/f43c0e9b
Branch: refs/heads/master
Commit: f43c0e9ba59b9e89f2932f3a34254bf675a291ff
Parents: 8aadc31
Author: Bolke de Bruin <bo...@xs4all.nl>
Authored: Thu Nov 16 07:10:45 2017 +0100
Committer: Bolke de Bruin <bo...@xs4all.nl>
Committed: Mon Nov 27 15:54:27 2017 +0100
----------------------------------------------------------------------
airflow/www/api/experimental/endpoints.py | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/f43c0e9b/airflow/www/api/experimental/endpoints.py
----------------------------------------------------------------------
diff --git a/airflow/www/api/experimental/endpoints.py b/airflow/www/api/experimental/endpoints.py
index b5a3052..d1e2d19 100644
--- a/airflow/www/api/experimental/endpoints.py
+++ b/airflow/www/api/experimental/endpoints.py
@@ -19,13 +19,13 @@ from airflow.api.common.experimental.get_task import get_task
from airflow.api.common.experimental.get_task_instance import get_task_instance
from airflow.exceptions import AirflowException
from airflow.utils.log.logging_mixin import LoggingMixin
+from airflow.utils import timezone
from airflow.www.app import csrf
from flask import (
g, Markup, Blueprint, redirect, jsonify, abort,
request, current_app, send_file, url_for
)
-from datetime import datetime
_log = LoggingMixin().log
@@ -58,12 +58,11 @@ def trigger_dag(dag_id):
# Convert string datetime into actual datetime
try:
- execution_date = datetime.strptime(execution_date,
- '%Y-%m-%dT%H:%M:%S')
+ execution_date = timezone.parse(execution_date)
except ValueError:
error_message = (
'Given execution date, {}, could not be identified '
- 'as a date. Example date format: 2015-11-16T14:34:15'
+ 'as a date. Example date format: 2015-11-16T14:34:15+00:00'
.format(execution_date))
_log.info(error_message)
response = jsonify({'error': error_message})
@@ -123,12 +122,11 @@ def task_instance_info(dag_id, execution_date, task_id):
# Convert string datetime into actual datetime
try:
- execution_date = datetime.strptime(execution_date,
- '%Y-%m-%dT%H:%M:%S')
+ execution_date = timezone.parse(execution_date)
except ValueError:
error_message = (
'Given execution date, {}, could not be identified '
- 'as a date. Example date format: 2015-11-16T14:34:15'
+ 'as a date. Example date format: 2015-11-16T14:34:15+00:00'
.format(execution_date))
_log.info(error_message)
response = jsonify({'error': error_message})
@@ -162,9 +160,9 @@ def latest_dag_runs():
if dagrun.execution_date:
payload.append({
'dag_id': dagrun.dag_id,
- 'execution_date': dagrun.execution_date.strftime("%Y-%m-%d %H:%M"),
+ 'execution_date': dagrun.execution_date.isoformat(),
'start_date': ((dagrun.start_date or '') and
- dagrun.start_date.strftime("%Y-%m-%d %H:%M")),
+ dagrun.start_date.isoformat()),
'dag_run_url': url_for('airflow.graph', dag_id=dagrun.dag_id,
execution_date=dagrun.execution_date)
})