[GitHub] [airflow] kaxil commented on a change in pull request #7923: Get Airflow Variables from Environment Variables

2020-03-28 Thread GitBox
kaxil commented on a change in pull request #7923: Get Airflow Variables from 
Environment Variables
URL: https://github.com/apache/airflow/pull/7923#discussion_r399648015
 
 

 ##
 File path: docs/concepts.rst
 ##
 @@ -663,7 +663,7 @@ accessible and modifiable through the UI.
 
 .. code:: python
 
-from airflow.models import Variable
+from airflow.models.variable import Variable
 
 Review comment:
   Fixed


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


With regards,
Apache Git Services


[GitHub] [airflow] kaxil commented on a change in pull request #7923: Get Airflow Variables from Environment Variables

2020-03-28 Thread GitBox
kaxil commented on a change in pull request #7923: Get Airflow Variables from 
Environment Variables
URL: https://github.com/apache/airflow/pull/7923#discussion_r399648000
 
 

 ##
 File path: docs/concepts.rst
 ##
 @@ -687,6 +687,34 @@ or if you need to deserialize a json object from the 
variable :
 
 echo {{ var.json. }}
 
+Storing Variables in Environment Variables
+--
+
+Airflow Variables can also be created and managed using Environment Variables. 
The environment variable
+naming convention is ``AIRFLOW_VAR_``, all uppercase.
+So if your variable key is ``FOO`` then the variable name should be 
``AIRFLOW_VAR_FOO``.
+
+For example,
+
+.. code:: bash
+
+export AIRFLOW_VAR_FOO=BAR
+
+# To use JSON, store them as JSON strings
+export AIRFLOW_VAR_FOO_JSON='{"hello":"world"}'
 
 Review comment:
   Fixed


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


With regards,
Apache Git Services


[GitHub] [airflow] kaxil commented on a change in pull request #7923: Get Airflow Variables from Environment Variables

2020-03-27 Thread GitBox
kaxil commented on a change in pull request #7923: Get Airflow Variables from 
Environment Variables
URL: https://github.com/apache/airflow/pull/7923#discussion_r399615781
 
 

 ##
 File path: airflow/secrets/metastore.py
 ##
 @@ -37,3 +37,16 @@ def get_connections(self, conn_id, session=None) -> 
List[Connection]:
 conn_list = session.query(Connection).filter(Connection.conn_id == 
conn_id).all()
 session.expunge_all()
 return conn_list
+
+@provide_session
+def get_variable(self, key: str, session=None):
+"""
+Get Airflow Variable from Metadata DB
+
+:param key: Variable Key
+:return: Variable Value
+"""
+from airflow.models.variable import Variable
 
 Review comment:
   This looks tough as we need Variable model here and we need to get the value 
in Variables.py file to keep it fully backward compatible


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


With regards,
Apache Git Services