Skip to content

fix(breeze): use prek from breeze bin instead of PATH#62277

Merged
potiuk merged 3 commits intoapache:mainfrom
uplsh580:breeze/prek-check
Mar 2, 2026
Merged

fix(breeze): use prek from breeze bin instead of PATH#62277
potiuk merged 3 commits intoapache:mainfrom
uplsh580:breeze/prek-check

Conversation

@uplsh580
Copy link
Contributor

@uplsh580 uplsh580 commented Feb 21, 2026

Related PR

Problem

When running breeze start-airflow or asset compilation, users could encounter:

  1. Version check failure: "Package name prek version is wrong. It should be at least 0.3.2 and is 0.2.25" — even when prek 0.3.3 was installed in the breeze Python environment
  2. Asset compilation failure: "Required minimum prek version 0.3.2 is greater than current version 0.2.25"

This occurred because breeze was checking and invoking prek from PATH, which could point to an older standalone installation (e.g. uv tool install prek at 0.2.25), while breeze's own environment had the correct version (0.3.3) in its bin directory.
image
image

Solution

  • get_prek_executable(): New helper that returns the path to prek in the same bin directory as breeze's Python (sys.executable's parent)
  • assert_prek_installed(): Uses get_prek_executable() instead of "prek" from PATH, so the version check uses breeze's prek
  • run_compile_ui_assets(): Uses get_prek_executable() instead of "prek", so asset compilation invokes the correct prek version

Error message improvements

  • When prek version is insufficient: suggests uv tool install -e ./dev/breeze --force to reinstall breeze with updated dependencies
  • When prek is not found: same reinstall suggestion (breeze includes prek as a dependency)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    cursor

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added area:dev-tools backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch labels Feb 21, 2026
@uplsh580
Copy link
Contributor Author

uplsh580 commented Feb 21, 2026

Validation

image ---- image

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Better solution will be to run prek via -m / module rather than modifying PATH

[sys.executable, "-m", "prek", ....]

@uplsh580
Copy link
Contributor Author

uplsh580 commented Feb 22, 2026

Better solution will be to run prek via -m / module rather than modifying PATH

[sys.executable, "-m", "prek", ....]

@potiuk
That command failed with the message "No module named prek", so I created a PR with the current command.
image

@uplsh580
Copy link
Contributor Author

uplsh580 commented Feb 23, 2026

Opened a PR for -m option support in prek. Currently in review.

j178/prek#1686

I think it's best to merge this PR first, then update it once the version of prek supporting the -m option is officially released.

@CarliJoy
Copy link

CarliJoy commented Feb 25, 2026

Can you not simply use prek_bin = shutil.which("prek", path=str(Path(sys.executable).parent))?
This way there is no need to again slowly init a python interpreter when running a fast rust command.

@CarliJoy
Copy link

@potiuk Why do you prefer python -m prek over shutil.which("prek", path=str(Path(sys.executable).parent))
Yes the later is a bit more complex but prevent spinning up a python interpreter to just run a subprocess again.

@uplsh580
Copy link
Contributor Author

Can you not simply use prek_bin = shutil.which("prek", path=str(Path(sys.executable).parent))?

This way there is no need to again slowly init a python interpreter when running a fast rust command.

@CarliJoy I've updated the code to use shutil.which as you suggested. Thanks for the sharp catch!

@uplsh580
Copy link
Contributor Author

@potiuk
Since prek v0.3.4 was released including j178/prek#1686, the -m option is now supported.
I have updated the code to apply this -m option.

@uplsh580 uplsh580 force-pushed the breeze/prek-check branch 4 times, most recently from bac85fe to ac4b754 Compare February 28, 2026 13:11
@potiuk
Copy link
Member

potiuk commented Mar 2, 2026

Nice!

@potiuk potiuk merged commit d785ca2 into apache:main Mar 2, 2026
129 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 2, 2026
…2277)

* fix(breeze): use prek from breeze bin instead of PATH

* Apply review of @CarliJoy - shutil.which

* Apply python -m prek
(cherry picked from commit d785ca2)

Co-authored-by: SeonghwanLee <[email protected]>
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Backport successfully created: v3-1-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-1-test PR Link

github-actions bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Mar 2, 2026
…ache#62277)

* fix(breeze): use prek from breeze bin instead of PATH

* Apply review of @CarliJoy - shutil.which

* Apply python -m prek
(cherry picked from commit d785ca2)

Co-authored-by: SeonghwanLee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants