You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jedcunningham (via GitHub)" <gi...@apache.org> on 2024/05/10 21:54:01 UTC

[PR] Faster `airflow_version` imports [airflow]

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

   Turns out `importlib.metadata.version` is much slower than a simple import, so let's switch back. It's not "slow", but might as well be faster :)
   
   


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


Re: [PR] Faster `airflow_version` imports [airflow]

Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham merged PR #39552:
URL: https://github.com/apache/airflow/pull/39552


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


Re: [PR] Faster `airflow_version` imports [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #39552:
URL: https://github.com/apache/airflow/pull/39552#issuecomment-2105382667

   Yes. That's actually better and there is actually a good reason for that other than performance (which is just marginal).
   
   I was going to propose it and also just changed it to also use `airflow.__version__` in https://github.com/apache/airflow/pull/39513 when running tests with airflow from packages
   
   cc: @Taragolis as well - you might find it interesting.
   
   During testing the V_2_10_PLUS switch I have found one case where `importlib.metadata.version` was actually wrong. 
   This is pretty obscure development-workflow only case, but it could  cause failing tests for contributors (and release manager (!) - especially switching between branches.
   
   When you are using IDE (say IntelliJ) it could be that the IDE will crate locally `.egginfo` folder where it will kepp information about the local module. I am not sure in which scenario .egginfo gets created (eggs have been replaced with wheel packaging and .egginfo is no longer created nor modified when you run `pip install -e .`). Interestingly enough during testing of #39513 I have found that my tests using `importlib.metadata.version` were showing airlfow version 2.9.0.dev0 where it was evidently 2.10.0.dev0, and reinstalling airflow in local venv with `pip install -e .` did not help. What I found was that 2.9.0.dev0 was set in the .egginfo folder and only after I deleted it, it started to show proper airlflow version.
   
   So I think while we should continue suggesting users to use importlib.metadata.version("apache-airflow") - if they want to check which airflow version they have installed, for all internal stuff (including providers `__init__.py` it's better to use `airflow.__version__` .


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