Skip to content

fix(prewarm): critical imports must fail the script, normalize dep specs#1609

Merged
rgbkrk merged 1 commit intomainfrom
fix/prewarm-critical-imports
Apr 7, 2026
Merged

fix(prewarm): critical imports must fail the script, normalize dep specs#1609
rgbkrk merged 1 commit intomainfrom
fix/prewarm-critical-imports

Conversation

@rgbkrk
Copy link
Copy Markdown
Member

@rgbkrk rgbkrk commented Apr 7, 2026

Summary

Fixes two issues from Codex code review of #1608:

  • (High) Broken env admitted to pool: The warmup script wrapped ALL imports in try/except, so missing ipykernel/IPython would silently succeed and the env would be marked .warmed. Now ipykernel and IPython are bare imports that crash the script on failure, matching the pre-prewarm behavior.

  • (Medium) User dep specs not normalized: Dependency specifiers like numpy>=1.24 or scikit-learn were passed raw to importlib.import_module(), which silently failed. Added normalize_module_name() to strip version specs and convert hyphens to underscores, restoring the old package_import_name() behavior.

Test plan

  • 14 Python tests pass (uv run pytest python/prewarm/tests/ -v)
  • New tests: test_normalize_module_name, test_collect_modules_normalizes_specs, test_build_warmup_script_critical_imports_not_wrapped
  • Rust kernel-env::warmup tests pass (cargo test -p kernel-env -- warmup)
  • Lint clean (cargo xtask lint)

Two issues from code review:

1. (High) The warmup script wrapped ALL imports in try/except, so a
   broken environment (missing ipykernel) would still exit 0 and be
   admitted to the pool. Now ipykernel and IPython are bare imports
   that crash the script on failure, matching the old behavior.

2. (Medium) User-configured dependency specifiers (e.g. "numpy>=1.24",
   "scikit-learn") were passed raw to importlib.import_module(), which
   would silently fail. Added normalize_module_name() to strip version
   specs and convert hyphens, restoring the old package_import_name()
   behavior.
@blacksmith-sh
Copy link
Copy Markdown
Contributor

blacksmith-sh bot commented Apr 7, 2026

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
TestKernelLifecycle/test_interrupt_clears_queue_and_unblocks View Logs
TestTerminalEmulation/test_progress_bar_simulation View Logs

Fix in Cursor

@rgbkrk rgbkrk merged commit e0ba355 into main Apr 7, 2026
20 of 21 checks passed
@rgbkrk rgbkrk deleted the fix/prewarm-critical-imports branch April 7, 2026 08:49
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