Skip to content

style: apply ruff format to four unformatted data_processing files - #4525

Closed
dieterolson wants to merge 6 commits into
mainfrom
fix/ruff-format-data-processing
Closed

style: apply ruff format to four unformatted data_processing files#4525
dieterolson wants to merge 6 commits into
mainfrom
fix/ruff-format-data-processing

Conversation

@dieterolson

Copy link
Copy Markdown
Collaborator

Why

python -m ruff format --check . is currently failing on main, so every open PR inherits a red format gate regardless of what it changes:

Would reformat: src\data_processing\data_processor\python\benchmarks\performance_benchmark.py
Would reformat: src\data_processing\data_processor\python\data_processor\core\data_loader.py
Would reformat: src\data_processing\data_processor\python\tests\test_nn_training_worker.py
Would reformat: src\data_processing\data_processor\python\tests\test_vectorized_filter_engine_contracts.py
4 files would be reformatted, 3141 files already formatted

All four predate this branch and are unrelated to any feature work. Landing the fix on its own unblocks the format gate for every open PR rather than burying it inside an unrelated feature branch.

What

Pure formatter output — python -m ruff format run on exactly those four paths, with no hand edits and nothing else touched.

Verification

Both gates green after the change:

$ python -m ruff format --check .
3144 files already formatted

$ python -m ruff check .
All checks passed!

No behavior change. Each file parses to a byte-identical AST before and after (compared against origin/main, decoding both sides from raw bytes so the comparison is encoding-safe):

File AST
performance_benchmark.py identical
data_loader.py identical
test_nn_training_worker.py identical
test_vectorized_filter_engine_contracts.py identical

The only substantive reflow is ruff moving assert messages out of a wrapped parenthesized condition, e.g.

-    assert (
-        trainer.train_thread != main_thread_id
-    ), "train() ran on the Qt main thread — UI would freeze"
+    assert trainer.train_thread != main_thread_id, (
+        "train() ran on the Qt main thread — UI would freeze"
+    )

Non-ASCII characters are preserved exactly (em-dash counts unchanged, zero U+FFFD introduced).

Note on spec-check

This PR touches src/**, which trips the spec-check freshness gate. Since the change is provably behavior-neutral (identical ASTs) and documents nothing, it carries the spec-exempt label rather than a spurious SPEC.md changelog row — matching that workflow's own stated rationale for the exemption.

`python -m ruff format --check .` has been failing on main, so every open
PR inherits a red format gate regardless of what it changes. The four
offending files are all under
src/data_processing/data_processor/python/ and predate this branch.

This is pure formatter output (`python -m ruff format` on exactly those
four paths) with no hand edits. All four parse to an identical AST before
and after, so there is no behavior change:

  performance_benchmark.py                        AST identical
  data_loader.py                                  AST identical
  test_nn_training_worker.py                      AST identical
  test_vectorized_filter_engine_contracts.py      AST identical

Landing this separately unblocks the format gate for every open PR rather
than burying the fix inside an unrelated feature branch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@dieterolson dieterolson added the spec-exempt Exempt from SPEC.md update requirement label Aug 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Performance Benchmark Results

No benchmark results available.

@github-actions

Copy link
Copy Markdown
Contributor

Performance Benchmark Results

No benchmark results available.

@github-actions

Copy link
Copy Markdown
Contributor

Performance Benchmark Results

No benchmark results available.

dieterolson added a commit that referenced this pull request Aug 18, 2026
`tests (3.11)` is one of only two required status checks on `main`, and its
runtime has grown into its own 90-minute cap. Measured across the last ten
completed `CI Standard` runs:

  success    77.7 min   <- the ONLY pass, at 86% of the budget
  cancelled  93.5 min   <- timeout kill
  cancelled  91.8 min   <- timeout kill
  cancelled  91.2 min   <- timeout kill
  cancelled  90.5 min   <- timeout kill
  cancelled  52.3 / 27.7 / 13.7 min
  failure    26.2 / 10.0 min

One pass in ten. The runs at 90+ minutes record **zero failed steps** — they are
timeout kills, not test failures, so a healthy run has roughly twelve minutes of
headroom and any contention on a shared runner consumes it.

Demonstrated concretely by PR #4525, a four-file formatting-only change whose
reformat was proven AST-identical: its `tests (3.11)` was cancelled at 90.0
minutes, re-run, and cancelled again at 90.3 minutes. No change to that PR can
make it pass. Combined with `strict = true` — which forces PRs to merge one at a
time and re-run CI after every sibling merge — a ~10% pass rate on the required
check makes a queue effectively unlandable without repeated luck.

This is a STOPGAP, deliberately reversible, and it does not pretend to be the
fix. 150 minutes is ~2x the observed successful run and ~1.6x the observed
maximum, which is headroom rather than a new ceiling to grow into.

The actual remedies are tracked in #4532: shard the suite across parallel jobs so
the required context no longer has a single-point timeout, scope the required
lane to the contract-critical set, and run `--durations` first to establish
whether this is broad growth or a handful of slow modules. One known contributor
is that `addopts` carries `-n auto --dist loadscope`, so Qt tests with 15-second
`waitUntil` timeouts are load-sensitive and wall-clock varies with the runner.

Worth noting what this is NOT: #4487 already cached the `tools_core` Rust wheel
so the lane stops installing a Rust toolchain and rebuilding the wheel per job,
and every measurement above is from AFTER that merged. The remaining runtime is
the test suite itself, not the toolchain.

Only `jobs.tests.timeout-minutes` changes. `quality-gate` (60) and
`rust-quality-gate` (15) are untouched. Verified with the repo's own gates:
`scripts/validate_workflows.py`, `scripts/check_workflow_pinning.py` and
`scripts/check_blocking_quality_gates.py` all pass, and the tests job still
parses to its full 27 steps.

Part of #4532

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Performance Benchmark Results

No benchmark results available.

dieterolson added a commit that referenced this pull request Aug 18, 2026
…erial everywhere) (#4548)

`tests (3.11)` is one of two required checks and it has been timing out. Raising
its cap from 90 to 150 minutes (#4539) did NOT help — the next run consumed
150.3 minutes. That ruled out "slightly too slow" and pointed at the real cause.

Per-step timings from the cancelled job on PR #4525 (a four-file, formatting-only
change whose reformat was proven AST-identical):

  step 23  Run Tests with Coverage (Python 3.11)   147.5 min   CANCELLED
  everything else combined                         ~4 min

So the test step is effectively the whole job, and it runs with `-n 0` — fully
serial. That override is unconditional, and its stated reason is specific to one
runner class: "the memory-constrained local runner fleet has repeatedly crashed
xdist workers even at low fan-out".

That reason does not hold on a hosted runner. The failing job ran on
`GitHub Actions 1000355575` — 4 vCPU / 16 GB, not memory-constrained. And the
timings across recent runs line up exactly with runner class rather than with any
code change:

  77.7 min  SUCCESS    d-sorg-local-Oglaptop-1   (fleet hardware, fast cores)
  150.3 min CANCELLED  hosted                    (slower per-core, same serial run)
   93.5 min CANCELLED  d-sorg-local-Desktop-3
   91.2 min CANCELLED  d-sorg-local-Desktop-6

Forcing serial execution onto slower hosted cores is what pushes the job past any
cap. So the fan-out is now chosen per runner class instead of globally:

  PYTEST_FANOUT: ${{ needs.pick-runner.outputs.runner == 'd-sorg-fleet' && '0' || 'auto' }}
  pytest_args+=(-n "${PYTEST_FANOUT:-0}")

Fleet hosts keep `-n 0`, so the crash this override was written to prevent is
still prevented. Hosted runners get `-n auto` (4 workers), which should take the
test step from ~148 minutes to roughly 40.

Two details that make this safer than it looks:

- `--dist loadscope` comes from the repo's own addopts and is unchanged, so a
  module's tests stay on one worker. That matters because the Qt tests use 15
  second `waitUntil` timeouts and are load-sensitive; loadscope keeps them from
  being split across workers.
- The default is `0`, not `auto` (`${PYTEST_FANOUT:-0}`). If the variable is ever
  unset the behaviour is today's serial run, so this fails safe.

This follows the conditional the tests job already uses for `PIP_CACHE_DIR`,
which switches on the same `needs.pick-runner.outputs.runner == 'd-sorg-fleet'`
test.

The 150-minute cap from #4539 is left in place as headroom rather than reverted;
with parallelism it should be far from binding. If it stops being needed it is a
one-line revert.

Verified: `scripts/validate_workflows.py`, `scripts/check_workflow_pinning.py`
and `scripts/check_blocking_quality_gates.py` all pass; the tests job still
parses to 27 steps; and the env var is on the `tests` job and NOT on
`quality-gate` (both jobs carry an identical `PIP_DEFAULT_TIMEOUT: "120"` line,
so a first-match patch lands in the wrong job — worth knowing when editing this
file).

Part of #4532

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@dieterolson

Copy link
Copy Markdown
Collaborator Author

Closing as superseded — this PR is now empty against main.

Its four files were reformatted on main by cded44f7f ("fix(data-processing): Make the Quarantined Directory…"), which touched the same paths for unrelated reasons and brought them into ruff format compliance as a side effect.

Verified before closing:

  • git diff --name-only origin/main...HEAD0 files
  • python -m ruff format --check . on origin/main (fe78bfcf9) → 3305 files already formatted, exit 0

So the repo-wide condition this PR was opened to fix — every open PR inheriting a red ruff format --check from main — is resolved, just not by this PR.

Worth recording what it turned up on the way, since that outlasts the PR:

Its tests (3.11) was cancelled at 90.0 min, then at 90.3 min after a re-run, then at 150.3 min after the cap was raised in #4539 — three timeouts on a four-file, formatting-only change whose reformat was proven AST-identical. That ruled out anything about the change itself and led to per-step timings showing the test step alone was 147.5 of 150 minutes, running -n 0 (fully serial) under an override whose stated justification is specific to the memory-constrained self-hosted fleet — while the job was executing on a hosted runner with 4 vCPU / 16 GB.

#4548 fixed that by choosing the xdist fan-out per runner class, keeping -n 0 on fleet hosts and using -n auto on hosted. That change is verified engaged (PYTEST_FANOUT: auto resolved, 1946 xdist worker markers in the run log), though its effect on a large delta selection is still unproven — #4548's own run only exercised the 694-test always-on core set, so it is not evidence of the 147-minute case being fixed.

Remaining CI work is tracked in #4532: shard the suite so the required context has no single-point timeout, scope the required lane to the contract-critical set, and run --durations to see whether the serial runtime is broad growth or a few slow modules.

No code is lost by closing this: main already has the formatting.

auto-merge was automatically disabled August 18, 2026 21:00

Pull request was closed

@github-actions

Copy link
Copy Markdown
Contributor

Anti-Phantom-Merge Guard — Rule 1 (empty diff) failed

This PR has 0 changed files against the base branch. Empty PRs are not mergeable. If you intentionally want an empty PR, set the title to exactly chore: empty PR.

How to fix

  • If this PR genuinely has no implementation yet, mark it as a draft.
  • If the title overstates the change, retitle it to match the diff.
  • If you're closing an issue, ensure the diff touches the paths the issue references.

Escape hatch

A repo admin can add the label phantom-guard-override to bypass this check.
The label is ignored when applied by non-admins.

Workflow: .github/workflows/anti-phantom-merge.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spec-exempt Exempt from SPEC.md update requirement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant