airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ricardo Garcia Silva (JIRA)" <>
Subject [jira] [Created] (AIRFLOW-1391) airflow trigger_dag cannot serialize exec_date when using the json client
Date Mon, 10 Jul 2017 14:41:00 GMT
Ricardo Garcia Silva created AIRFLOW-1391:

             Summary: airflow trigger_dag cannot serialize exec_date when using the json client
                 Key: AIRFLOW-1391
             Project: Apache Airflow
          Issue Type: Bug
          Components: api
    Affects Versions: 1.8.0
            Reporter: Ricardo Garcia Silva

The {{airflow trigger_dag}} command cannot serialize a {{datetime.datetime}} when the cli
is configured to use the {{json_client}}.
The command:

airflow trigger_dag --run_id test1 --exec_date 2017-01-01 example_bash_operator

Throws the error:

Traceback (most recent call last):
  File "/home/geo2/.venvs/cglops-dissemination/bin/airflow", line 28, in <module>
  File "/home/geo2/.venvs/cglops-dissemination/local/lib/python2.7/site-packages/airflow/bin/",
line 180, in trigger_dag
  File "/home/geo2/.venvs/cglops-dissemination/local/lib/python2.7/site-packages/airflow/api/client/",
line 32, in trigger_dag
    "execution_date": execution_date,
  File "/home/geo2/.venvs/cglops-dissemination/local/lib/python2.7/site-packages/requests/",
line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/geo2/.venvs/cglops-dissemination/local/lib/python2.7/site-packages/requests/",
line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/geo2/.venvs/cglops-dissemination/local/lib/python2.7/site-packages/requests/",
line 488, in request
    prep = self.prepare_request(req)
  File "/home/geo2/.venvs/cglops-dissemination/local/lib/python2.7/site-packages/requests/",
line 431, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/home/geo2/.venvs/cglops-dissemination/local/lib/python2.7/site-packages/requests/",
line 308, in prepare
    self.prepare_body(data, files, json)
  File "/home/geo2/.venvs/cglops-dissemination/local/lib/python2.7/site-packages/requests/",
line 458, in prepare_body
    body = complexjson.dumps(json)
  File "/usr/lib/python2.7/json/", line 243, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2017, 1, 1, 0, 0) is not JSON serializable

The same command works fine if airflow is configured to use the {{local_client}} instead.

A fix for this would need to encode the {{datetime}} as a string in the client then being
able to deserialize back to a datetime in the server.

This message was sent by Atlassian JIRA

View raw message