airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AIRFLOW-1177) variable json deserialize does not work at set defaults
Date Sat, 16 Sep 2017 15:40:02 GMT

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

ASF subversion and git services commented on AIRFLOW-1177:
----------------------------------------------------------

Commit 610f68b22a8277f9521d0b9989b4dd5ce7cbcfe0 in incubator-airflow's branch refs/heads/master
from [~ashb]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-airflow.git;h=610f68b ]

[AIRFLOW-1177] Fix Variable.setdefault w/existing JSON

Previously due to a logic error if you attempt to
use
`Variable.setdefault()` with
`deserialize_json=True` and the value
already existed it would die with:

    ...
        my = Variable.setdefault('regions', ['uk'],
deserialize_json=True)
      File "/usr/local/lib/python3.5/site-
packages/airflow/models.py", line 3623, in
setdefault
        return json.loads(obj.val)
    AttributeError: 'str' object has no attribute
'val'

The problem was that the `Variable.get()` call was
returning the value,
not a variable object.

Closes #2540 from ashb/variable-setdefault-json


> variable json deserialize does not work at set defaults
> -------------------------------------------------------
>
>                 Key: AIRFLOW-1177
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1177
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: models
>    Affects Versions: Airflow 1.8
>            Reporter: barak schoster
>            Assignee: barak schoster
>
> at line:
> https://github.com/apache/incubator-airflow/blob/master/airflow/models.py#L3685
> obj has no attribute val, it is the val itself.
> it will throw error like:
> Variable.setdefault("some_key", deserialize_json=True,default=json.dumps(default_dag_variables))
>   File "/usr/local/lib/python2.7/site-packages/airflow/models.py", line 3586, in setdefault
>     return json.loads(obj.val)
> AttributeError: 'unicode' object has no attribute 'val'



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message