Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Do I Access Configuration Values from the airflow.cfg File? #168

Closed
r39132 opened this issue Jul 23, 2015 · 4 comments
Closed

How Do I Access Configuration Values from the airflow.cfg File? #168

r39132 opened this issue Jul 23, 2015 · 4 comments

Comments

@r39132
Copy link
Contributor

r39132 commented Jul 23, 2015

I would like to use include the base_url in emails that I send via from flow. The base_url is defined under the webserver section of the config in airflow.cfg

What's the easiest way to these variables in any operator? Currently, I send email using my own PythonOperator (so that I can send both text and html multipart email). Hence, I access the config using the code below.

    parser = SafeConfigParser()
    parser.read('airflow.cfg')
    base_url = parser.get('webserver', 'base_url')

This works, but I was wondering if there is a more elegant way? Also, this only works for PythonOperators, but what if I need to access a configuration parameter in any operator in a Jinja template?

@mistercrunch
Copy link
Member

It's easy for me to throw it in the context. Here's the PR:
#169

@r39132
Copy link
Contributor Author

r39132 commented Jul 23, 2015

Hi! I see the change in documentation, but didn't see a material change to the code. It's late, so I might have missed something.
-s

@mistercrunch
Copy link
Member

I added a line comment to point out which line makes the difference

@r39132
Copy link
Contributor Author

r39132 commented Jul 23, 2015

Great... replaced 4 lines of code (including an import) with one.
base_url = kwargs['conf'].get('webserver', 'base_url')

Thx

@r39132 r39132 closed this as completed Jul 23, 2015
kaxil added a commit to astronomer/airflow that referenced this issue Dec 10, 2024
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`
kaxil added a commit to astronomer/airflow that referenced this issue Dec 10, 2024
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`
kaxil added a commit to astronomer/airflow that referenced this issue Dec 10, 2024
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`
kaxil added a commit to astronomer/airflow that referenced this issue Dec 16, 2024
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`
kaxil added a commit to astronomer/airflow that referenced this issue Dec 16, 2024
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK in preparation for Airflow 3, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`. This is removed in Airflow 3 and deprecated in 2.10.x/2.11

Mailing list Thread: https://lists.apache.org/thread/2n0l8y2oyq4442p0lsnmbbcl6rmbj3k7
kaxil added a commit that referenced this issue Dec 16, 2024
This was initially added in response to #168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`
kaxil added a commit to astronomer/airflow that referenced this issue Dec 17, 2024
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK in preparation for Airflow 3, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`. This is removed in Airflow 3 and deprecated in 2.10.x/2.11

Mailing list Thread: https://lists.apache.org/thread/2n0l8y2oyq4442p0lsnmbbcl6rmbj3k7
kaxil added a commit that referenced this issue Dec 17, 2024
This was initially added in response to #168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK in preparation for Airflow 3, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`. This is removed in Airflow 3 and deprecated in 2.10.x/2.11

Mailing list Thread: https://lists.apache.org/thread/2n0l8y2oyq4442p0lsnmbbcl6rmbj3k7
LefterisXefteris pushed a commit to LefterisXefteris/airflow that referenced this issue Jan 5, 2025
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`
got686-yandex pushed a commit to got686-yandex/airflow that referenced this issue Jan 30, 2025
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages:

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28

https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76

So, to simplify what we need to pass from API server to the Task SDK, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants