You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2016/11/15 07:05:58 UTC

[jira] [Commented] (AIRFLOW-464) Add setdefault method to Variable Object

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

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

Commit dd1f50e59008e95f457ce47ba877f631d5187530 in incubator-airflow's branch refs/heads/master from [~btallman@gmail.com]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-airflow.git;h=dd1f50e ]

[AIRFLOW-464] Add setdefault method to Variable

In order to assist with environment migrations, we
added a setdefault method to
the Variable object. This allows default variables
to be created (and then
edited) with less chance for typos/copy+paste
bugs.

Also changed Variable.get ValueError exception to
a KeyError

Variable.setdefault(key, default,
deserialize_json=[True|False]) returns either the
value stored in Variable(key) or sets
Variable(key) = default and returns default.

Dear Airflow Maintainers,

Please accept this PR that addresses the following
issues:
- _https://issues.apache.org/jira/browse/AIRFLOW-
464_

This was changed from adding a create_if_none flag
to Variable.get based on feedback on this PR.

Testing Done:
- Added a test to test/core.py to cover this
functionality

Closes #1765 from btallman/CreateIfNone_feature


> Add setdefault method to Variable Object
> ----------------------------------------
>
>                 Key: AIRFLOW-464
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-464
>             Project: Apache Airflow
>          Issue Type: Improvement
>            Reporter: Ben Tallman
>            Assignee: Ben Tallman
>            Priority: Trivial
>
> In order to assist with environment migrations, we added a setdefault method to
> the Variable object. This allows default variables to be created (and then
> edited) with less chance for typos/copy+paste bugs.
> Variable.setdefault(key, default, deserialize_json=[True|False]) returns either the
> value stored in Variable(key) or sets Variable(key) = default and returns default.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)