# Running

## How does a notebook run?

Python runs on Vistazo's servers, so a notebook runs the same from a laptop, a phone or a locked-down
browser. Each person gets their own kernel for each notebook. A kernel is the running Python that
holds your variables between cells. It can't reach your browser or your sign-in, and nobody else's
code runs in yours.

- **Run cell** runs one cell. Shift+Enter runs it and moves to the next Python or data cell, adding a
  Python cell if there is none.
- **Run all** runs every Python and data cell from the top in the same kernel, overwriting values from
  earlier runs as it goes.
- **Restart**, in the ⋯ menu, clears every variable and runs nothing. Restart and then **Run all** to
  be sure the outputs match the code as written.
- **Stop** interrupts the running cell and keeps everything else.

A run stops at the first cell that fails, since the cells below depend on what it didn't define. A
Python cell is marked **outdated** when its own code changed after it ran, or when a cell above it was
edited or ran again. A data cell is marked outdated only when its own form changes. An outdated cell
keeps its output, but that output may no longer follow from the code.

The first run after you open a notebook starts a session, meaning your kernel and the variables it
holds. Starting one takes a few moments. When every kernel is in use, the page shows **Session
queued**, and the run starts as soon as one frees up. **Stop** gives up your place. Your variables are
saved as you go and kept for about a day after your last run, so coming back within that time brings
them back. After that the session starts fresh, and **Run all** rebuilds it.

Running a notebook needs edit access, and its outputs are then what everyone reads. A viewer reads
the last run and its outputs, and can run the notebook with their own values in the **Parameters**
tab, which saves nothing ([Parameters](/docs/notebooks/parameters)).

> [!WARNING]
> Run executes whatever the cells hold, whoever wrote them, with no extra confirmation for cells the
> built-in assistant or your agent wrote. Read cells you didn't write before you run them, since they run under your access.

## How are outputs shown?

Each cell's output sits under it. Tables show as tables, figures as images, and printed text as text.

While a cell's code is open, an **Output** bar sits between the code and the result. For a table it
switches between **Table** and **JSON**, with Copy and Download. Those give CSV from the table view and
JSON from the JSON view, with the columns in the table's order. Printed text has Copy and Download as a
`.txt` file.

Outputs are saved with the run, so the people you share with read results without running anything. Figures and large tables are stored as files and count against your storage, like
any upload. A notebook keeps its five most recent runs, and a run is cleared after 30 days.

## What limits a notebook?

| | Limit |
|---|---|
| Notebooks you own | Depends on your plan. Archived and example notebooks don't count. See [Limits](/docs/reference/limits) |
| Notebooks in a workspace | 200, not counting archived ones |
| Length | 100,000 characters |
| Cells | 50 |
| Data pulls | 50 `vistazo` calls per session every ten minutes |
| Data pulled | 20 MB per session every ten minutes, and 5 MB in a single pull |
| Wait for one pull | 60 seconds |
| One cell | 9 minutes when run from the page |
| One run through `run_notebook` or a schedule | 9 minutes for the whole run |
| Memory | About 1.8 GB per kernel |
| Saved variables | About a day after your last run, up to 500 MB |
| Kernels at once | 2 per person and 3 per workspace, not counting scheduled runs |
| Cell runs | 600 per person per hour |
| Scheduled notebooks | 25 per person in a workspace, each at most every 15 minutes |
| Runs kept | The five most recent, for up to 30 days |
| Jupyter file | 10 MB from the notebooks list, 1.5 MB through `save_notebook` |

A few tools return more rows to a notebook than to the built-in assistant or your agent, because the
rows go to pandas rather than a model. Weather's `storm_events` and `earthquakes` return up to 10,000 rows, and Countries' `get_data`
up to 12,000. Storm events with `include_narrative` stay at 1,000. Every other tool returns the same
rows either way.

Running cells uses your compute allowance, counted per second of execution. It costs the same whether
you, the built-in assistant, your agent or a schedule started the run. Pulling data is free, as every
fetch is, and running cells calls no model. See [Usage](/docs/billing/usage).
