Comments (6)
I need to add an entry in the documentation to explain this, but variables are general purpose and used to control or alter the behavior of specific pipelines that define logic based on the content of variables.
For instance there could be a convention that an "aggregation framework" would look for variables starting with the prefix aggfwk_
and perhaps read a JSON config from the variable. The JSON config would define the metadata for the aggregation framework needs to operate. Adding new variables would create new pipelines or sets of pipes.
So it's just a place to store metadata that pipelines can read from. Arguably most of this metadata should be code and live in source control, but sometimes we need some settings to be more reactive and that's when we use variables.
Our only internal use case now is a backfilling framework that allows us to run huge backfills efficiently.
Another thought is Airflow doesn't expose a way to communicate across tasks, or even for an upstream task influence the behavior of a downstream tasks. Maybe variables could be used for that purpose, but that's somewhat messy.
from airflow.
How can variables be accessed?
Is there an API to access variables defined in the UI?
I assume they are stored in the database?
We want to use variables for providing development and production flags within the creation of the DAG or within the task template.
from airflow.
Variable is a sqlalchemy model and is located at airflow.models.Variable
I just added a simple utility classmethod to easily Variable.get(key, deser_json=False)
9c36068
This makes it a very concise call to get a variable.
from airflow.models import Variable
foo = Variable.get("foo")
Though this is not in the current pypi release, it will make it to 1.1.0 . In the meantime you can look at the method for the more verbose way to get the variable.
from airflow.
Thank's a lot! That was, what I was looking for.
I just discovered the 1.1.0 release on pypi as well.
from airflow.
Just asking if it is possible to set Variables in code(like in some hook class). Cause I want to save the http connection cookies as variables.
from airflow.
Never mind, I found my answer here: #220
from airflow.
Related Issues (20)
- Update Databricks provider to depend on databricks-sql-connector >= 3.1.0 HOT 4
- [Bug]: Papermill Provider installed via pip seems empty HOT 2
- Create a Cloud Storage Operator that could return a list of objects in a folder HOT 2
- KubernetesPodOperator callback example from Doc doesn't work HOT 2
- webserver - acces task log | TypeError: '<' not supported between instances of 'Interval' and 'DateTime'
- FTPHook doesn't not allow to change port HOT 3
- Support Async Cursor for SQLExecuteOperator
- In provider docs, the environment variables in Configuration tab are shown incorrectly HOT 3
- Send email alert failed when task fail HOT 2
- Release helm chart for Airflow 2.9.0 HOT 2
- Missing termination argument in DockerOperator HOT 8
- Logs from elastic not visible in Grid menu HOT 5
- Status of testing of Apache Airflow 2.9.1rc2 HOT 7
- DAG disappearing from Airflow in case of standalone DAG processor HOT 1
- Create new Callback Types HOT 2
- New release covering latest main HOT 1
- webserver static file caching is disabled above 2.3.0 version. HOT 2
- Status of testing Providers that were prepared on May 01, 2024 HOT 24
- Mock all connections in `TestYandexCloudYqHook::test_select_results` HOT 3
- This function is deprecated. Please use `create_unique_id`. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airflow.