You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/19 16:04:02 UTC

[GitHub] [airflow] andrewgodwin opened a new pull request, #25832: Add a way to import Airflow without side-effects

andrewgodwin opened a new pull request, #25832:
URL: https://github.com/apache/airflow/pull/25832

   I know it's been a long-standing issue that it should be possible to import Airflow as a library without side-effects, and while I think the ultimate fix for this is to go through and steadily remove the need to call `settings.initalize()` in `__init__.py`, I am currently working on a project where I would really like to use Airflow without it doing strange things to logging, sys.path, or atexit.
   
   As such, this PR wraps the import side-effect in a simple environment variable check that code can use to disable the side-effects for now, while we slowly try and progress towards a "cleaner" solution. Without this, I am having to dynamically modify the source code of `__init__.py` in an import hook, and nobody wants that!
   
   I don't believe it's possible to write tests for this as Airflow is already imported when tests are running, but if you can think of a way, let me know and I'll have a go. The environment variable name is also up for consideration - I just picked something that looked a bit like a setting, but we can deliberately make it not look like that if we want.


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on pull request #25832: Add a way to import Airflow without side-effects

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25832:
URL: https://github.com/apache/airflow/pull/25832#issuecomment-1221148630

   Yeah. good tactical solution :). But eventually I think we should lazy intialize everything on first use (but that's far more complex change).


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] andrewgodwin commented on pull request #25832: Add a way to import Airflow without side-effects

Posted by GitBox <gi...@apache.org>.
andrewgodwin commented on PR #25832:
URL: https://github.com/apache/airflow/pull/25832#issuecomment-1220859501

   I like both those ideas - I have added a warning and the private prefix.


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] kaxil merged pull request #25832: Add a way to import Airflow without side-effects

Posted by GitBox <gi...@apache.org>.
kaxil merged PR #25832:
URL: https://github.com/apache/airflow/pull/25832


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org