Runtime modes

interpret / compile / auto defaults differ by surface. Library interpret, POST /run auto, pyne run compile-only, pyne execute is Runtime.run. PyneTS 0.5.0 has interpret + JS compile.

This page

Abstract

mode selects how the bar loop executes: interpret (AST walk), compile (transpiled loop), or auto (try compile, fall back to interpret). The default is not the same on every surface. This is the most common footgun when moving a script from the library to the Pro API or between Python and PyneTS.

There is no Runtime.evaluate.

Conceptual model

Diagram

Rendering…

Interface surface

What each mode means

ModePythonPyneTS (this checkout)
interpretAST walker. Full host: input.*, request.*, libraries, profiler, alertsAST walker only (pynets/src/runtime/interpret.ts). Result mode is always "interpret"
compileNumba nopython or object-mode Python loopNot implemented — no src/runtime/compile/ in this tree
autoTry compile; on ineligibility / compile error / compiled runtime error → interpretNot implemented

Defaults by surface

SurfaceDefault modeCalls Runtime.run?
pynescript.runtime.Runtime.run(..., mode=None)PYNE_RUNTIME_MODE else interpretyes
Pro API POST /run body omits modeschema autoyes (host wrap)
?mode= query (legacy)overrides bodyyes
CLI pyne runcompile only — not Runtime.runno
CLI pyne execute--mode default auto (MCP pyne_execute)yes
new Runtime() / pynets runinterpret only (no --mode; --bars default 20)yes
AXIS engine serverwhatever you pass; UI default often autoHTTP /run
AXIS engine pyodideobject-mode in Wasm (no Numba)in-browser Python

Runtime.run (Python, exact)

python
Runtime(symbol="AAPL").run(
    source_code,
    ohlcv_data,
    data_feed=None,
    data_provider=None,
    mode=None,            # env PYNE_RUNTIME_MODE else "interpret"
    inputs=None,
    profiler=False,
    timeout_seconds=None,
    libraries=None,
    realtime_last_bar=False,
    realtime_ticks=1,
    realtime_bars=0,
    realtime_from_bar=None,
)
ArgumentSurfacesEffect on mode
modelibrary / POST /run / pyne executeSee defaults table. pyne run has no --mode.
inputslibrary / POST /runNon-empty overrides force interpret (compile does not apply them).
librarieslibrary / POST /run / POST /run/batch (max 32)[{namespace, name, version, source}] for import ns/Name/ver. Compile-ineligible; auto keeps the list on interpret fallback. Not on pyne run.
timeout_secondslibrary / POST /run / POST /run/batchInterpret wall-clock budget. Exceeded → partial plots + timed_out. Omit / null / ≤ 0 → no timeout. Not on pyne run.
profilerlibrary / POST /runForces interpret (line timings).
realtime_*library onlyInterpret forming-bar window (realtime_last_bar, realtime_ticks, realtime_bars, realtime_from_bar).

inputs / profiler / libraries / timeout_seconds / realtime_* force or keep the interpret host (or force interpret after compile miss).

Runtime.run (PyneTS)

ts
new Runtime(symbol, { inputs, broker, timeframe })
  .run(source, ohlcv, extra?)

There is no constructor/extra.mode and no libraries option on this host. RuntimeResult.mode is always "interpret".

Internals

SurfaceImplementation
Python librarysrc/pynescript/runtime/host.py
Python CLI runsrc/pynescript/__main__.py → compile_script + synthetic bars
Python CLI executesrc/pynescript/mcp/cli.py → Runtime.run (MCP pyne_execute)
Pro APIbackend/app.py RUN_SCHEMA default auto
PyneTS@hoox-sh/pynets 0.5.0 — interpret + JS compile (mode interpret / compile / auto). Python remains the oracle
PyneTS CLIpynets/src/cli.ts → new Runtime("AAPL", { broker }).run

Invariants & edge cases

  1. Do not document pyne run as mode=auto. It is compile-only smoke (--bars default 50). Use pyne execute --mode … for Runtime.run from the CLI.
  2. Do not document pynets run as Python pyne run. PyneTS Runtime.run defaults to interpret; 0.5.0 also has JS compile / auto. Default --bars is 20. The Python equivalent of pynets run is pyne execute (pyne run defaults to 50 bars and is compile-only).
  3. result.mode is what executed. After auto, also read auto_backend and compile_fallback_reason.
  4. Foreign request.security is na on every host. Compile does not invent bars to become "more complete".
  5. AXIS Pyodide compile / auto cannot be Numba (Wasm).

Worked examples

Force interpret everywhere you care about input.* + libraries + alerts:

python
Runtime(symbol="AAPL").run(src, bars, mode="interpret", inputs={"len": 14})
ts
new Runtime("AAPL", { inputs: { len: 14 } }).run(src, bars);
bash
# Python desk smoke (compile only)
pyne run script.pine --bars 50

# Python Runtime.run from the CLI
pyne execute script.pine --mode interpret --bars 50

# PyneTS desk smoke (Runtime.run; default interpret, --bars 20)
pynets run script.pine --bars 50

Failure modes

SymptomCauseFix
Pro API "misses" an inputauto compiled a path that drops overridesPass mode: "interpret"
pyne run ≠ notebook Runtime.runDifferent hostUse pyne execute, the library, or Pro API
Expect PyneTS ≡ Python compileJS emit is object-mode analog, not NumbaTreat Python Runtime as the oracle
mode omitted, two hosts disagreeDifferent defaultsSet mode explicitly

See also