Skip to content

Python Analysis

Python Analysis

Some questions can’t be answered with SQL alone — distributions, regressions, custom transforms. datarelix.ai runs Python in an isolated sandbox to handle them.

When Python runs

  • When the planner decides a question needs analysis beyond SQL — typically charts or aggregations that pandas does better than SQL.
  • When you toggle the chart icon and the planner produces a sandbox step.

Sandbox steps consume the SQL step’s results. The DataFrame you get is the rows the SQL step produced.

What’s available in the sandbox

  • pandas, numpy for data manipulation.
  • scipy, statsmodels for stats.

The sandbox runs a fixed, vetted set of scientific-Python libraries — pandas, numpy, scipy, and statsmodels. Arbitrary package installs are not available.

Charts are not authored in Python. When your question warrants a visualization, datarelix.ai generates a declarative chart spec from the query result and renders it as an interactive Vega-Lite chart — the sandbox is for data analysis (transforms, stats), not plotting.

What’s NOT available

  • No network. The sandbox cannot make outbound HTTP calls. You can’t requests.get("...") to leak data.
  • No filesystem outside the run scratch dir. No reading from your home dir, no writing to /tmp indefinitely.
  • No shell. os.system and subprocess are blocked.
  • No native code loading. No ctypes, no FFI.

These boundaries are enforced at the OS level (read-only root filesystem, dropped capabilities, network namespace isolation).

Resource limits

LimitDefault
Wall-clock timeout30s
Memory512 MB
CPU1 core
Output bytes10 MB

These limits keep analysis fast and bounded. Enterprise plans can raise them — contact us.

Inspecting a sandbox step

Open the trace toggle on the assistant message. You’ll see:

  • The Python source the LLM produced.
  • The DataFrame it consumed (referenced by name).
  • The artifact it produced (table or chart).
  • Stdout / stderr captured during execution.

If something failed, the error class will be CODE_ERROR and the exception type/message is in the trace.

When Python isn’t the answer

If the LLM repeatedly produces Python that fails or doesn’t match the question, the planner will retry up to the configured repair budget (default: 3). After that the run is marked failed with a PLAN_FAILURE. Edit the question and ask again.