Skip to content

Expose a pre-execution seam in @stx.session for pre-flight compute checks (scitex-clew P3) #258

Description

@ywatanabe1989

Context

scitex-clew has shipped a pre-flight compute estimate (scitex-compute-preflight-check):

  • Phase 1 (merged, scitex-clew#64): clew estimate <script> predicts runtime p50/p90 + success rate + #outputs from run history.
  • Phase 2 (merged, scitex-clew#65): adds size_bytes + predicted output volume and a cached-intermediate reuse hint.

The end goal (operator-requested) is a pre-run prompt: before a heavy compute/figure script executes, warn "this is a lot (~Xm, ~N files, ~Y MB) — are you sure? consider subset / sbatch / GPU / reuse-cached." This mirrors scitex-writer's pre-COMPILE pre-check framework, on the COMPUTE side.

The ask

clew can compute the estimate today (scitex_clew.estimate(script_path)), and it already owns the session lifecycle hooks (on_session_start / on_session_close, wired via clew's observers). What's missing is a pre-execution seam in scitex-dev's @stx.session decorator (scitex_dev.decorators): a hook point that fires AFTER the session is identified but BEFORE the decorated body runs, where a registered callback can:

  1. receive the script path / session context,
  2. optionally emit a warning + return a decision, and
  3. when interactive (tty) and over a threshold, prompt the user; when non-interactive/CI, no-op (must never block batch jobs).

Proposed shape (open to your design)

  • A pre_run / before_execute callback registry on @stx.session (analogous to the existing start/close observer mechanism clew already plugs into), OR
  • A documented pre_execute_hooks list the decorator invokes before the body.

clew would register a callback that calls scitex_clew.estimate(...) and prompts. No import of clew from scitex-dev is required — clew registers into scitex-dev's hook, keeping the coupling one-way and optional (removing clew degrades to "no pre-flight," never breaks @stx.session).

Constraints

  • Zero added cold-start cost when no pre-run hook is registered.
  • Non-interactive / CI runs must short-circuit (no prompt, no block).
  • One-way dependency only (scitex-dev must not import scitex-clew).

Tracking

scitex-clew side is carded as clew-preflight-p3 (blocked on this). Happy to implement the clew-side callback once the seam exists, and to pair on the hook signature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions