Skip to content

Add support for PackageIndex connections in PythonVirtualenvOperator #52288

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

wolfdn
Copy link
Contributor

@wolfdn wolfdn commented Jun 26, 2025

Description

The PythonVirtualenvOperator offers the option to pass additional index_urls that are used as additional package sources. Furthermore there is the PackageIndexHook which allows users to define Python package sources as Airflow connection. They can put the index URL and also credentials for this index URL in there. See here: https://airflow.apache.org/docs/apache-airflow-providers-standard/stable/_api/airflow/providers/standard/hooks/package_index/index.html

However there is currently no "clean" way to pass a PackageIndex connection into the PythonVirtualenvOperator. This PR adds this integration to the PythonVirtualenvOperator.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, very cool! I am wondering that nobody else was missing this until today!

Can I kindly request that (1) you add a pytest to ensure that passed parameters are correctly resolved in the list and (2) that the feature is also visible in the documentation in providers/standard/docs/operators/python.rst describing also "why" and when to use it?

As I assume the benefit of the passing of connection IDs is that no Jinja templating is needed but this would lead to a "late resolution" of connections, what happens if the named connection is not existing? Task will fail and what will be the presented error message? Might there need to be a bit exception handling/error hints being needed? Or how would the error look like if connection is not existing?

@wolfdn wolfdn force-pushed the feature/add-support-for-package-index-connections-to-PythonVirtualenvOperator branch from 0f9098e to 6643e8b Compare June 27, 2025 11:06
@wolfdn
Copy link
Contributor Author

wolfdn commented Jun 27, 2025

Oh, very cool! I am wondering that nobody else was missing this until today!

Can I kindly request that (1) you add a pytest to ensure that passed parameters are correctly resolved in the list and (2) that the feature is also visible in the documentation in providers/standard/docs/operators/python.rst describing also "why" and when to use it?

As I assume the benefit of the passing of connection IDs is that no Jinja templating is needed but this would lead to a "late resolution" of connections, what happens if the named connection is not existing? Task will fail and what will be the presented error message? Might there need to be a bit exception handling/error hints being needed? Or how would the error look like if connection is not existing?

Thanks for the review! I just added a unit test and extended the documentation.
If the passed connection ID does not exist the user will currently see an error message like this:

grafik

The error message is already relatively clear I think. Or should we add a custom exception to extend the error message?

@wolfdn wolfdn marked this pull request as ready for review June 27, 2025 11:12
Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great in my view. Thanks! Just catced some conflict needed to be resolved, probably due to Python 3.9 deprecation.

As I was having a very detailled review initially when I was contributing this base, would ask some additional pair of eyes... @potiuk you were the reviewer in the past - is this okay also with an extra eye on security?

wolfdn added 2 commits June 30, 2025 07:40
…or-package-index-connections-to-PythonVirtualenvOperator
…or-package-index-connections-to-PythonVirtualenvOperator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants