airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject [1/2] incubator-airflow git commit: [AIRFLOW-337] Add __repr__ to VariableAccessor and VariableJsonAccessor
Date Thu, 14 Jul 2016 18:08:36 GMT
Repository: incubator-airflow
Updated Branches:
  refs/heads/master c32452aba -> aea1fa2d6


[AIRFLOW-337] Add __repr__ to VariableAccessor and VariableJsonAccessor

The VariableJsonAccessor and VariableAccessor were missing the __repr__
function that leads to a VariableError when printing out the context
being passed to for example a PythonOperator.


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/3079da06
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/3079da06
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/3079da06

Branch: refs/heads/master
Commit: 3079da06249d7ff87dfc4ed58c999f7b81f3159a
Parents: 3c91bbb
Author: Bolke de Bruin <bolke@xs4all.nl>
Authored: Thu Jul 14 19:30:46 2016 +0200
Committer: Bolke de Bruin <bolke@xs4all.nl>
Committed: Thu Jul 14 19:30:46 2016 +0200

----------------------------------------------------------------------
 airflow/models.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/3079da06/airflow/models.py
----------------------------------------------------------------------
diff --git a/airflow/models.py b/airflow/models.py
index 60de65f..2736076 100644
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -1466,17 +1466,25 @@ class TaskInstance(Base):
             {var.variable_name}.
             """
             def __init__(self):
-                pass
+                self.var = None
 
             def __getattr__(self, item):
-                return Variable.get(item)
+                self.var = Variable.get(item)
+                return self.var
+
+            def __repr__(self):
+                return str(self.var)
 
         class VariableJsonAccessor:
             def __init__(self):
-                pass
+                self.var = None
 
             def __getattr__(self, item):
-                return Variable.get(item, deserialize_json=True)
+                self.var =  Variable.get(item, deserialize_json=True)
+                return self.var
+
+            def __repr__(self):
+                return str(self.var)
 
         return {
             'dag': task.dag,


Mime
View raw message