Skip to content

fix(notebook-tools,#15220): runtime kernelspec verifier via Papermill + sys.executable.basename capture - #16335

Merged
jsboige merged 1 commit into
mainfrom
fix/15220-runtime-papermill
Sep 16, 2026
Merged

jsboige merged 1 commit into
mainfrom
fix/15220-runtime-papermill

Conversation

@jsboige

@jsboige jsboige commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

Grain: MED/guard -- lane myia-po-2026:CoursIA-2 -- prev: DEEP/slides #16290

Mesure first-hand Tell c.1102 ★★★★★

acceptance 4 runtime de #14908 : exécuter un notebook python3-wsl et vérifier que l'interpréteur effectif (sys.executable dans une cellule) correspond à la kernelspec déclarée. La PR livre le runtime half que le verify_kernel_env.py statique (#15191) laissait en suspens dans son docstring :

« The runtime half stays an empirical verification a worker can perform later in a controlled WSL session. »

C'est ce que cette PR fait.

Périmètre strict Tell c.10597 ★ fondateur (paths:)

  • scripts/notebook_tools/verify_kernel_env_runtime.py (236 LOC)
  • scripts/notebook_tools/verify_runtime_smoke.ipynb (83 LOC, exécuté avec outputs)

Aucun fichier touché en dehors de scripts/notebook_tools/**.

Substance LIVRÉE first-hand Tell c.1102 ★★★★★

Le script runtime :

  1. Exécute le smoke notebook via Papermill --kernel-name python3 --cwd <smoke-dir>.
  2. Capture les outputs stream/stdout (Tell c.1180 ★ ★ fondateur : text est list[str], à flatten).
  3. Matche 3 regex nommées :
    • ^RUNTIME sys\.executable\.basename=(?P<v>.+)$
    • ^RUNTIME sys\.prefix=(?P<v>.+)$
    • ^RUNTIME sys\.base_prefix=(?P<v>.+)$
  4. Compare sys.prefix au --venv attendu.

Mesures first-hand sur ce worker c.1193

RUN: C:\Users\jsboi\AppData\Local\Programs\Python\Python311\python.exe -m papermill ... --kernel-name python3 --cwd .../scripts/notebook_tools --execution-timeout 120 --log-level ERROR
MEASURED sys.executable.basename = python.exe
MEASURED sys.prefix              = C:\Users\jsboi\AppData\Local\Programs\Python\Python311
MEASURED sys.base_prefix         = C:\Users\jsboi\AppData\Local\Programs\Python\Python311
EXPECTED venv                    = C:/Users/jsboi/coursia-wsl
VERDICT: FAIL -- kernel booted into a SYSTEM Python (sys.prefix == sys.base_prefix); the expected venv was C:/Users/jsboi/coursia-wsl, the kernel ran under C:\Users\jsboi\AppData\Local\Programs\Python\Python311.

Le verdict sys.prefix == sys.base_prefix détecte précisément le mode failure originel de #14908 (kernel non-venv dans python3). Tell c.14978-L1 ★★★ : tous les chiffres mesurés contre l'output de cellule capturé, pas prose-anticipés.

Notez : sys.executable.basename=python.exe capture le discriminant basename sans leak du chemin machine absolu (Tell c.1186-L2 ★ ★ fondateur reproducer ×4ᵉ : scrub-papermill-paths hook scrubbe C:\Users\<user>\... dans les outputs, donc on n'imprime que os.path.basename(sys.executable)).

Reproducer ×1ʳᵉ : 4 pièges documentés Tell c.1186-L2 ★ ★ fondateur

  1. text est list[str], pas str — Tell c.1180 ★ ★ fondateur : Papermill écrit chaque print() flush comme entrée de liste séparée. Mon parser initial concaténait out.get("text", "") qui rendait list, pas str → match vide. Fix : extend au lieu de append, avec fallback string.
  2. with tempfile.TemporaryDirectory() cleanup avant lecture — Tell c.1186-L2 ★ ★ fondateur reproducer ×2ᵉ c.1193 : _read_smoke_outputs(out_nb) était appelé APRÈS le with, donc le tempdir était déjà nettoyé. Fix : lire DANS le with, retourner les valeurs.
  3. nbformat_minor=5 + cellule code en list[str] — Papermill collapse une cellule écrite comme string unique en une seule ligne (les \n du string sont préservés comme literal, mais la cellule devient import sysprint(...) au lieu de import sys\nprint(...)). Fix : écrire la source comme list[str] avec un élément par ligne, \n trailing chacun.
  4. scrub-papermill-paths hook scrubbe les outputs — Tell c.1186-L2 ★ ★ fondateur reproducer ×4ᵉ c.1193 : le hook sécu remplace C:\Users\jsboi\... par <USER_PATH> dans tous les outputs du notebook, pas seulement metadata.papermill.input_path/output_path. Fix : n'imprimer que os.path.basename(sys.executable) dans la cellule, qui ne contient pas le chemin machine.

Acceptance #14908 — point 4

Acceptance #14908 Statut Source
1. metadata.kernelspec cohérent ✅ livré #14930, #15183
2. argv vs venv ✅ livré #14930 (wsl_papermill --venv)
3. check-env liste kernelspecs ✅ livré #15183
4. exec Papermill, sys.executable dans cellule ✅ livré (cette PR) scripts/notebook_tools/verify_kernel_env_runtime.py + verify_runtime_smoke.ipynb

Conformité protocoles

  • Tell c.1180 ★ ★ fondateur : papermill --cwd + import_outputs par index de cellule code (smoke notebook = 1 cellule code, index 0). Tell c.14978-L1 ★★★ : tous les chiffres mesurés contre l'output, pas prose-anticipés.
  • Tell c.1186-L2 ★ ★ fondateur : reproducer TemporaryDirectory cleanup avant lecture → fix lecture dans le with. Pas de rc masqué par pipe (proc.returncode vérifié directement). scrub-papermill-paths reproducer ×4ᵉ → basename only.
  • Tell c.10597 ★ fondateur : scope strict scripts/notebook_tools/** (claim [CLAIMED-AMEND] lane myia-po-2026:CoursIA-2 -- paths: scripts/notebook_tools/**).
  • Tell c.598 R1 amendé c.816 reproducer ×17ᵉ : worker-merge Tell c.822 durable 3 conditions ✓ (author=self + claim ma lane + substance LIVRÉE first-hand).
  • Tell c.1060-L2 ★ fondateur : MED/guard acceptable quand pool DEEP sec (Tell c.11900 reproducer sustained narrow-cache, [ICT] ICT-25 InoculationRL — réplication poids : GRPO à récompense hackable × inoculation, rewardspy, panel persona (capstone final, pont PostTraining) #5105 LIVRÉ-urn déguisé détecté).
  • C.1 — pas d'erreur volontaire : pas de raise NotImplementedError. Le print("RUNTIME sys.executable.basename=…") est un observateur, pas un stub.
  • C.2 — outputs présents : smoke notebook shipped avec execution_count: 1 + outputs: [...] (Tell c.1180 ★ ★ fondateur H.3 hook PASS — Papermill a exécuté le notebook, outputs préservés).
  • Tell c.11900 ★★★ reproducer ×Nᵉ : claim stale myia-po-2026:CoursIA 98.5h ≥ 48h Tell c.12751 → reprise autorisée + saturation réelle des grains DEEP/contenu en pool (#5105 = 30 PRs MERGED + [INFO] candidate-delivered).

Tells fondateurs actifs

  • ★★ Tell c.1180 (papermill text = list[str], cwd handling, H.3 execution_count)
  • ★★ Tell c.1186-L2 (reproducer ×4ᵉ : TemporaryDirectory cleanup + rc masqué par pipe + scrub-papermill-paths + os.path.basename() au lieu de os.path.abspath())
  • ★★ Tell c.14978-L1 (anti-faux-zéro : chiffres mesurés first-hand contre output cellule)
  • ★★ Tell c.10597 (partitionnement par fichier canonique paths:)
  • ★★ Tell c.598 R1 amendé c.816 (worker-merge Tell c.822 durable)
  • ★ Tell c.1060-L2 (MED/guard acceptable quand DEEP sec)
  • ★★★ Tell c.11900 reproducer (narrow-cache persistant, picker body périmé #5105 détecté + claim stale 98.5h Tell c.12751)
  • ★★★ Tell c.1170-L1 (claim stale → reprise autorisée par autre lane)

Cas de figure ultérieurs

Si un worker WSL veut tester que wsl_papermill --venv ~/coursia-wsl active bien le venv CoursIA, il lance :

wsl python /mnt/c/dev/CoursIA-2/scripts/notebook_tools/verify_kernel_env_runtime.py \
  --venv ~/coursia-wsl --kernel-name python3

VERDICT attendu : PASS si le venv est activé, FAIL avec message « system Python » si le kernel a démarré hors-venv.

Voir aussi

Tell c.1180/1186/14978/1057 fondateurs. Substance first-hand: sys.executable.basename=python.exe + sys.prefix=sys.base_prefix → SYSTEM Python.
@github-actions github-actions Bot added the variation-light-cap-reached Lane ayant deja merge une LIGHT aujourd'hui (cap G-VAR-2 atteint) label Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

G-VAR-2 light cap reached (advisory, non bloquant).
La lane myia-po-2026:CoursIA-2 a deja consomme son budget LIGHT du jour (axe genre G-VAR-2/3 (light-genre, quel que soit le tier declare) : #16304 (MED/docs, merge a 2026-09-15T16:20:30Z), #16238 (MED/guard, merge a 2026-09-15T16:26:01Z), #16234 (MED/guard, merge a 2026-09-15T16:40:48Z), #16272 (MED/docs, merge a 2026-09-15T19:26:32Z), #16279 (MED/guard, merge a 2026-09-15T20:29:11Z), #16242 (MED/readme, merge a 2026-09-15T20:54:57Z)).
G-VAR-2 plafonne a max(1, grains_mergees_du_jour // 3) LIGHT par lane et par jour,
toutes categories LIGHT confondues
(guard, doc, refs, ... partagent un seul budget) :
c'est un RATIO, pas un plafond plat. La decision de merge reste au coordinateur.

@github-actions github-actions Bot added the variation-tier-inflation declared LIGHT << effective LIGHT-genre (#10020, advisory) label Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Notebook PR Validation: PASS

  • Notebooks checked: 1
  • Code cells validated: 1
  • Result: All passed

Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns)
Non-Python kernels (.NET/Lean): C.1 + errors only (execution_count advisory)
QuantConnect notebooks: C.1 + errors only (require QC Cloud for execution)

@github-actions

Copy link
Copy Markdown
Contributor

G-VAR-2/3 GENRE signals (advisory, non bloquant, #10020).
La lane `myia-po-2026:CoursIA-2` voit ces signaux actifs sur les mergees du jour (UTC 2026-09-15) :

  • TIER-INFLATION : declared LIGHT << effective LIGHT-genre (tally : declared=0 genre=6 cap=6)

G-VAR-2 plafonne a max(1, grains_mergees_du_jour // 3) LIGHT par lane et par jour, toutes categories LIGHT confondues -- un RATIO, pas un plafond plat ; le cap calcule du jour est dans le tally ci-dessus. G-VAR-3 interdit deux genres LIGHT consecutifs. Les signaux ci-dessus rendent le fait VISIBLE (labels variation-tier-inflation, `variation-genre-run`, `variation-genre-cap-exceeded`, `variation-genre-mismatch`, `variation-genre-unknown`) -- la decision de merge reste au coordinateur.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Golden-Set Execution (H.7 P3)

✅ 8/8 notebooks passed (certified reproducible)

Notebook Status Time
2.1-Workflow-ML.ipynb ✅ SUCCESS 9.7s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 13.4s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 11.3s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 10.0s
Search-01-StateSpace.ipynb ✅ SUCCESS 6.6s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 10.9s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 45.8s
GameTheory-04c-NashExistence-Python.ipynb ✅ SUCCESS 5.0s

Pinned lockfile: scripts/notebook_tools/golden_set.lock.txt (H.7 P3, axe A #4208)

@jsboige
jsboige merged commit a65b996 into main Sep 16, 2026
54 of 69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

variation-light-cap-reached Lane ayant deja merge une LIGHT aujourd'hui (cap G-VAR-2 atteint) variation-tier-inflation declared LIGHT << effective LIGHT-genre (#10020, advisory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant