[Runtime modes]

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

Runtime modes

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

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
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)

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 /runSee 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)

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__.pycompile_script + synthetic bars
Pro APIbackend/app.py RUN_SCHEMA default auto
PyneTSpynets/ v0.2.0 — interpret + JS compile (mode interpret / compile / auto). Python remains the oracle
PyneTS CLIpynets/src/cli.tsnew Runtime("AAPL", { broker }).run

Invariants & edge cases

  1. Do not document pyne run as mode=auto. It is compile-only smoke (--bars default 50).
  2. Do not document pynets run as Python pyne run. PyneTS Runtime.run defaults to interpret; 0.2.0 also has JS compile / auto. Default --bars is 20 (Python pyne run defaults to 50).
  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:

Runtime(symbol="AAPL").run(src, bars, mode="interpret", inputs={"len": 14})
new Runtime("AAPL", { inputs: { len: 14 } }).run(src, bars);
# Python desk smoke (compile only)
pyne run script.pine --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 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