Skip to content

FE-1412: Support seeded trials in the Python client and optimizer image - #9229

Draft
kube wants to merge 1 commit into
cf/fe-1270-create-python-bindings-to-petrinaut-corefrom
cf/fe-1412-python-client-support-seeded-trials-in-the-optimizer-service
Draft

FE-1412: Support seeded trials in the Python client and optimizer image#9229
kube wants to merge 1 commit into
cf/fe-1270-create-python-bindings-to-petrinaut-corefrom
cf/fe-1412-python-client-support-seeded-trials-in-the-optimizer-service

Conversation

@kube

@kube kube commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Top of the FE-1408 stack: makes the Python side ready for trials that run multiple seeded simulations. Until this layer, the deployed optimizer image cannot execute manifests with execution.seedsPerTrial > 1 — its Node permission flags lack --allow-worker and its fixed 240 s response deadline assumes one simulation per evaluate.

Stack #9226: FE-1410FE-1411FE-1408FE-1413FE-1270this PR.

🔗 Related links

  • FE-1412 (internal) — this PR
  • FE-1408 (internal) — parent: seeded trials in the CLI

🔍 What does this change?

@local/petrinaut-python

  • The bootstrap loop skips Node startup diagnostics on stderr while waiting for the CLI's readiness line. --allow-worker under --permission makes Node print a two-line SecurityWarning (verified on the image's Node 22: the warning plus a (Use `node --trace-warnings ...`) hint that carries no (node: prefix) — without the skip, every run in the image would die at startup.
  • OptimizationSession.describe_optimization() validates the reported study.seedsPerTrial (integer, 1–100; protocol error otherwise) and multiplies the per-response deadline by it: one evaluate may now legally run that many sequential simulations.
  • _child_environment forwards PETRINAUT_CLI_MAX_PARALLEL_SIMULATIONS to the CLI child, so operators can cap the worker pool.

apps/petrinaut-opt image

  • --allow-worker added to both Node permission flag sets.
  • PETRINAUT_CLI_MAX_PARALLEL_SIMULATIONS=1 pinned: production stays sequential until the task's CPU/memory allocation is raised — each simulation worker holds its own compiled model, and worker heaps are not capped by the main isolate's --max-old-space-size. README documents the behaviour and the scaled timeout.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies workspaces but not a publishable library

📜 Does this require a change to the docs?

The changes in this PR:

  • require changes to docs which are made as part of this PR
    • The bindings README (timeout scaling, warning tolerance) and the optimizer README (seeded-runs behaviour, pool cap, scaled deadline).

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🛡 What tests cover this?

  • Bindings (27 tests): the two-line SecurityWarning bootstrap skip, timeout scaling from the described seedsPerTrial, rejection of invalid values, env forwarding — plus a new end-to-end test that runs a two-seed trial on real CLI worker threads (PETRINAUT_CLI_MAX_PARALLEL_SIMULATIONS=2), asserting the derived seed sequence [42, 1013904268], the per-seed replicates, and the mean objective.
  • petrinaut-opt: full suite (75) unchanged and green.

❓ How to test this?

turbo run test:unit --filter @local/petrinaut-python --filter @apps/petrinaut-opt

🤖 Generated with Claude Code

With execution.seedsPerTrial, one optimization.evaluate may legally run
up to 100 simulations, and enabling worker threads under Node's
permission model changes the CLI's startup output. The bindings now
skip Node startup diagnostics (the two-line --allow-worker
SecurityWarning) while waiting for the readiness line, scale the
per-response timeout by the seedsPerTrial reported by
optimization.describe, and forward PETRINAUT_CLI_MAX_PARALLEL_SIMULATIONS
into the child environment. The optimizer image grants --allow-worker
and pins the parallel-simulations cap to 1 until the task's CPU/memory
allocation is raised. A new end-to-end test drives a two-seed trial on
real CLI worker threads from Python.
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 16, 2026 6:24pm
petrinaut Ready Ready Preview Aug 16, 2026 6:24pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 16, 2026 6:24pm

@github-actions github-actions Bot added area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests area/apps labels Aug 16, 2026
@kube kube self-assigned this Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

1 participant