airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AIRFLOW-1823) API get_task_info is incompatible with manual runs created by UI
Date Sun, 25 Nov 2018 21:06:00 GMT

    [ https://issues.apache.org/jira/browse/AIRFLOW-1823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16698300#comment-16698300
] 

ASF GitHub Bot commented on AIRFLOW-1823:
-----------------------------------------

xnuinside closed pull request #4237: [WIP][AIRFLOW-1823] added possibility to send execution
date with millisec…
URL: https://github.com/apache/incubator-airflow/pull/4237
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/www_rbac/api/experimental/endpoints.py b/airflow/www_rbac/api/experimental/endpoints.py
index 21aa7e8a1a..6589d203d2 100644
--- a/airflow/www_rbac/api/experimental/endpoints.py
+++ b/airflow/www_rbac/api/experimental/endpoints.py
@@ -168,18 +168,21 @@ def task_instance_info(dag_id, execution_date, task_id):
     """
     Returns a JSON with a task instance's public instance variables.
     The format for the exec_date is expected to be
-    "YYYY-mm-DDTHH:MM:SS", for example: "2016-11-16T11:34:15". This will
+    "YYYY-mm-DDTHH:MM:SS", for example: "2016-11-16T11:34:15" or
+    "YYYY-mm-DDTHH:MM:SS.f", for example: "2016-11-16T11:34:15.680399". This will
     of course need to have been encoded for URL in the request.
     """
 
     # Convert string datetime into actual datetime
     try:
-        execution_date = timezone.parse(execution_date)
+        execution_date = datetime.strptime(
+            execution_date, '%Y-%m-%dT%H:%M:%S.%f' if '.' in execution_date
+            else '%Y-%m-%dT%H:%M:%S')
     except ValueError:
         error_message = (
             'Given execution date, {}, could not be identified '
-            'as a date. Example date format: 2015-11-16T14:34:15+00:00'
-            .format(execution_date))
+            'as a date. Example date format: 2015-11-16T14:34:15 or '
+            '2015-11-16T14:34:15.680399'.format(execution_date))
         _log.info(error_message)
         response = jsonify({'error': error_message})
         response.status_code = 400
@@ -209,17 +212,21 @@ def dag_run_status(dag_id, execution_date):
     """
     Returns a JSON with a dag_run's public instance variables.
     The format for the exec_date is expected to be
-    "YYYY-mm-DDTHH:MM:SS", for example: "2016-11-16T11:34:15". This will
+    "YYYY-mm-DDTHH:MM:SS", for example: "2016-11-16T11:34:15" or
+    "YYYY-mm-DDTHH:MM:SS.f", for example: "2016-11-16T11:34:15.680399". This will
     of course need to have been encoded for URL in the request.
     """
 
     # Convert string datetime into actual datetime
     try:
-        execution_date = timezone.parse(execution_date)
+        execution_date = datetime.strptime(
+            execution_date, '%Y-%m-%dT%H:%M:%S.%f' if '.' in execution_date
+            else '%Y-%m-%dT%H:%M:%S')
     except ValueError:
         error_message = (
             'Given execution date, {}, could not be identified '
-            'as a date. Example date format: 2015-11-16T14:34:15+00:00'.format(
+            'as a date. Example date format: 2015-11-16T14:34:15+00:00 or '
+            '2015-11-16T14:34:15.680399'.format(
                 execution_date))
         _log.info(error_message)
         response = jsonify({'error': error_message})


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> API get_task_info is incompatible with manual runs created by UI
> ----------------------------------------------------------------
>
>                 Key: AIRFLOW-1823
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1823
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: api
>    Affects Versions: 2.0.0
>         Environment: ubuntu
> Airflow 1.9rc02
> commit: https://github.com/apache/incubator-airflow/blob/master/airflow/www/api/experimental/endpoints.py#L126
>            Reporter: Jeremy Lewi
>            Assignee: Iuliia Volkova
>            Priority: Minor
>
> The API method [task_instance_info|https://github.com/apache/incubator-airflow/blob/master/airflow/www/api/experimental/endpoints.py#L126]
doesn't work with manual runs created by the UI.
> The UI creates dag runs with ids with sub second precision in the name. An example of
a run created by the UI is
> 2017-11-16T20:23:32.045330
> The endpoint for  [task_instance_info|https://github.com/apache/incubator-airflow/blob/master/airflow/www/api/experimental/endpoints.py#L126]
however assumes the dag run id is of the form '%Y-%m-%dT%H:%M:%S'.
> Runs triggered via the CLI generate run ids with the form expected by the API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message