Skip to content

Guard n_jobs access after conditional column drop - #223

Merged
ethanglaser merged 1 commit into
IntelPython:mainfrom
ethanglaser:dev/eglaser-fix-njobs-keyerror
Sep 10, 2026
Merged

Guard n_jobs access after conditional column drop#223
ethanglaser merged 1 commit into
IntelPython:mainfrom
ethanglaser:dev/eglaser-fix-njobs-keyerror

Conversation

@ethanglaser

Copy link
Copy Markdown
Contributor

Description

Fixes a crash in --compatibility-mode report generation introduced by #219.

#219 added a block that drops the n_jobs column when it is partially NaN:

if (
    "n_jobs" in results.columns
    and results["n_jobs"].isna().any()
    and results["n_jobs"].notna().any()
):
    results.drop(inplace=True, columns=["n_jobs"])

The pre-existing access below it (added in #184) was left unguarded, so once
the column is dropped, transform_results_to_compatible raises
KeyError: 'n_jobs'.

Three conditions are needed to trigger it, which is why it wasn't caught:

  1. --compatibility-mode — the only caller of transform_results_to_compatible
  2. n_jobs partially NaN, so the new block drops it. True for any full-suite
    run, since LinearRegression/kNN/ensemble carry n_jobs while Ridge/
    Lasso/ElasticNet do not.
  3. More than one environment_name — true when comparing a measurements file
    against a baseline captured on another environment.

Observed on a nightly benchmark report comparing current SPR measurements
against the sklearnex_performance_SPR_2026.1.0 baseline.


🤖 Generated with Claude Code

IntelPython#219 added a block that drops the `n_jobs` column when it is partially
NaN, but the pre-existing access below it was left unguarded, so any
`--compatibility-mode` report over more than one environment_name raises
KeyError: 'n_jobs'.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ethanglaser
ethanglaser merged commit 9294a43 into IntelPython:main Sep 10, 2026
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants