Skip to content

PythonVirtualEnvOperator with tasks test command installs package outside of virtualenv. #32879

@starone99

Description

@starone99

Apache Airflow version

2.6.3

What happened

If I use PythonVirtualEnvOperator with airflow tasks test command, it installs package outside of virtualenv.
It is quite strange that scheduled task does not behave like this but with tasks test command.
I checked this behavior in two OS, Debian GNU/Linux 11 (bullseye) and MacOS 13.0
The detail is in how to reproduce

What you think should happen instead

No response

How to reproduce

helmfile version: 1.10.0
airflow version: 2.6.3

  1. make task using PythonVirtualEnvOperator with module that is preinstalled in system-site-packages
    in my case, it is openpyxl which is one of constraints of airflow.
    in 2.6.3 openpyxl==3.1.2
    following is my operator that I found the bug.
PythonVirtualenvOperator(
    task_id='test_venv',
    dag=dag,
    python_callable=dummy_callable,
    requirements='openpyxl==3.0.10',
)
  1. deploy airflow with helmfile
  2. go to worker with kubectl exec command
  3. check version of openpyxl with pip freeze command. It shows 3.1.2
  4. run command 'airflow tasks test dag_id task_id' with the task defined above.
  5. recheck version of openpyxl with pip freeze command. It shows 3.0.10

Operating System

Debian GNU/Linux 11 (bullseye), MacOS 13.0

Versions of Apache Airflow Providers

No response

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions