apache / apache/airflow

Hash Virtual Environment Cache Based on Actual Package Versions in `PythonVirtualEnvOperator`

Open
#41,328 11 comments 0 reactions 0 assignees View on GitHub
area:core good first issue kind:feature provider:standard
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 10h
Merged PRs (30d)
483

Description

### Description

Update the `PythonVirtualEnvOperator` to hash the virtual environment cache based on the actual versions of the installed packages rather than just the checksum of the requirements. This change would ensure that the cache reflects the true state of the environment, avoiding issues with packages tagged as **"latest"** or other dynamic versioning.

### Use case/motivation

Currently, when using the `PythonVirtualEnvOperator`, if dependencies in the requirements use tags like **"latest"**, the checksum used for caching remains unchanged even if the package versions are updated. This can lead to situations where outdated versions of packages are used from the cache, causing potential inconsistencies and issues in workflows. By hashing the cache based on the actual versions of installed packages, the virtual environment would be refreshed appropriately whenever package versions change, ensuring that the most current versions are used.

### Related issues

_No response_

### Are you willing to submit a PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Research direction

Start by locating the PythonVirtualEnvOperator and its virtual environment cache checksum logic. Trace how requirements and installed package versions are currently represented, then define completion as cache keys changing when dynamically resolved package versions change, with coverage for that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, data-engineering
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.