You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ra...@apache.org on 2026/04/17 17:14:38 UTC
(airflow) 02/17: [v3-2-test] Speed up cleanup_python_generated_files by skipping irrelevant dirs (#64927) (#64930)
This is an automated email from the ASF dual-hosted git repository.
vatsrahul1001 pushed a commit to branch v3-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 170916f307b692960315826109e282ccc2460bc1
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Thu Apr 9 01:28:00 2026 +0300
[v3-2-test] Speed up cleanup_python_generated_files by skipping irrelevant dirs (#64927) (#64930)
Replace two rglob calls with a single os.walk that prunes node_modules
and hidden directories (e.g. .git, .venv) in-place, avoiding unnecessary
traversal of large directory trees that never contain relevant .pyc files.
(cherry picked from commit 27258d567887a93f43af25a9d79d773198751bd9)
Co-authored-by: Jarek Potiuk <ja...@potiuk.com>
---
dev/breeze/src/airflow_breeze/utils/path_utils.py | 36 +++++++++++++----------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/dev/breeze/src/airflow_breeze/utils/path_utils.py b/dev/breeze/src/airflow_breeze/utils/path_utils.py
index 03877d64761..7f2625a0bcc 100644
--- a/dev/breeze/src/airflow_breeze/utils/path_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/path_utils.py
@@ -418,22 +418,26 @@ def cleanup_python_generated_files():
if get_verbose():
console_print("[info]Cleaning .pyc and __pycache__")
permission_errors = []
- for path in AIRFLOW_ROOT_PATH.rglob("*.pyc"):
- try:
- path.unlink()
- except FileNotFoundError:
- # File has been removed in the meantime.
- pass
- except PermissionError:
- permission_errors.append(path)
- for path in AIRFLOW_ROOT_PATH.rglob("__pycache__"):
- try:
- shutil.rmtree(path)
- except FileNotFoundError:
- # File has been removed in the meantime.
- pass
- except PermissionError:
- permission_errors.append(path)
+ for dirpath, dirnames, filenames in os.walk(AIRFLOW_ROOT_PATH):
+ # Skip node_modules and hidden directories (.*) — modify in place to prune os.walk
+ dirnames[:] = [d for d in dirnames if d != "node_modules" and not d.startswith(".")]
+ for filename in filenames:
+ if filename.endswith(".pyc"):
+ path = Path(dirpath) / filename
+ try:
+ path.unlink()
+ except FileNotFoundError:
+ pass
+ except PermissionError:
+ permission_errors.append(path)
+ if Path(dirpath).name == "__pycache__":
+ try:
+ shutil.rmtree(dirpath)
+ except FileNotFoundError:
+ pass
+ except PermissionError:
+ permission_errors.append(Path(dirpath))
+ dirnames.clear()
if permission_errors:
if platform.uname().system.lower() == "linux":
console_print("[warning]There were files that you could not clean-up:\n")