Skip to content

MNT remove HF-specific overflow injection from model plot#517

Merged
adrinjalali merged 6 commits into
skops-dev:mainfrom
adrinjalali:fix-sklearn-nightly-overflow
May 26, 2026
Merged

MNT remove HF-specific overflow injection from model plot#517
adrinjalali merged 6 commits into
skops-dev:mainfrom
adrinjalali:fix-sklearn-nightly-overflow

Conversation

@adrinjalali
Copy link
Copy Markdown
Member

@adrinjalali adrinjalali commented May 26, 2026

Summary

The sklearn nightly tests started failing on PR #516 because newer sklearn (1.9+) emits sk-top-container twice in the HTML repr — once as a CSS selector (.sk-top-container.sk-global { ... }) and once as an HTML class attribute. A naive string replace would have corrupted the new CSS.

Looking at why the injection existed in the first place: it was specifically to work around how sklearn's HTML repr renders inside the HuggingFace Hub models page. Since skops no longer targets HF Hub (see #462 and #512), this HF-specific HTML manipulation is no longer needed.

  • Remove the inline style=\"overflow: auto;\" injection from _add_model_plot.
  • Drop the corresponding test_no_overflow test.
  • Add a changelog entry.

Test plan

  • pixi run -e ci-sklearn18 pytest skops/card/tests/test_card.py (140 passed)
  • Initial fix commit passed sklearn-nightly on Ubuntu and macOS in CI
  • Full matrix CI on this PR

Newer sklearn versions (1.9+) emit `sk-top-container` both as a CSS
class definition (.sk-top-container.sk-global { ... }) and as an HTML
class attribute. The previous naive string replace only ran when the
token appeared exactly once and would have corrupted the CSS otherwise.

Use a regex that targets the class attribute on the top <div> so the
inline `style="overflow: auto;"` is added correctly regardless of
how many times the token appears in the HTML output.
The inline `style="overflow: auto;"` was added to work around how
sklearn's HTML repr renders inside the HuggingFace Hub models page.
skops no longer specifically targets HF Hub (see skops-dev#462 and skops-dev#512), so
this HF-specific HTML manipulation is no longer needed.

This also resolves the breakage with sklearn 1.9+ where the previous
naive string replace would have corrupted the new CSS that now also
mentions `sk-top-container`.
@adrinjalali adrinjalali changed the title FIX overflow handling for sklearn nightly HTML repr MNT remove HF-specific overflow injection from model plot May 26, 2026
Also adds narwhals as a transitive dep of sklearn nightly, which was
missing from the v6 lock and would have broken the sklearn-nightly CI
once the new nightly wheels start depending on narwhals.
Comment thread skops/card/_model_card.py

"""
model_plot_div = re.sub(r"\n\s+", "", str(estimator_html_repr(model)))
if model_plot_div.count("sk-top-container") == 1:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

these were for HF specific overflow issue which is not used anymore.

@adrinjalali adrinjalali merged commit c9b827d into skops-dev:main May 26, 2026
27 checks passed
@adrinjalali adrinjalali deleted the fix-sklearn-nightly-overflow branch May 26, 2026 08:42
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.

1 participant