> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.conductorquantum.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.conductorquantum.com/_mcp/server.

# stanza.cli

Stanza CLI - Command-line interface for Stanza experiment framework.

## Module Contents

### Functions

| Name | Description |
|------|-------------|
| [`cli`](#stanzaclicli) | Stanza - Build tune up sequences for quantum computers fast. |
| [`init`](#stanzacliinit) | Initialize a new timestamped experiment session directory. |
| [`status`](#stanzaclistatus) | Show current active session information. |
| [`delete_session`](#stanzaclidelete_session) | Delete the active session directory or clear the pointer. |
| [`_get_config_file`](#stanzacli_get_config_file) | Get path to live plot config file. |
| [`_read_config`](#stanzacli_read_config) | Read live plot config from disk. |
| [`_write_config`](#stanzacli_write_config) | Write live plot config to disk. |
| [`live_plot`](#stanzaclilive_plot) | Manage live plotting configuration. |
| [`enable_live_plot`](#stanzaclienable_live_plot) | Enable live plotting for experiments. |
| [`disable_live_plot`](#stanzaclidisable_live_plot) | Disable live plotting for experiments. |
| [`live_plot_status`](#stanzaclilive_plot_status) | Show current live plotting configuration. |
| [`jupyter_cli`](#stanzaclijupyter_cli) | Manage Jupyter notebook server. |
| [`jupyter_start`](#stanzaclijupyter_start) | Start a Jupyter notebook server in the background. |
| [`jupyter_stop`](#stanzaclijupyter_stop) | Stop the Jupyter notebook server gracefully. |
| [`jupyter_status`](#stanzaclijupyter_status) | Show current Jupyter server status. |
| [`jupyter_open`](#stanzaclijupyter_open) | Open JupyterLab in your default browser. |
| [`_require_server`](#stanzacli_require_server) | Check if Jupyter server is running, abort if not. |
| [`_find_notebook`](#stanzacli_find_notebook) | Find notebook session by name, abort if not found or ambiguous. |
| [`jupyter_list`](#stanzaclijupyter_list) | List all active notebook sessions. |
| [`jupyter_logs`](#stanzaclijupyter_logs) | View or list notebook log files. |
| [`jupyter_attach`](#stanzaclijupyter_attach) | Attach to a notebook with active kernel control. |
| [`main`](#stanzaclimain) | Entry point for CLI. |

### API

```python
stanza.cli.cli() -> None
```

Stanza - Build tune up sequences for quantum computers fast.

Easy to code. Easy to run.


```python
stanza.cli.init(
    path: pathlib.Path | None, name: str | None
) -> None
```

Initialize a new timestamped experiment session directory.

Creates a directory with the format YYYYMMDDHHMMSS_`<name>` where all
experiment data from routines will be logged. The session becomes
active automatically.

Examples:

    stanza init

    stanza init --name my_experiment

    stanza init --path /data/experiments


```python
stanza.cli.status() -> None
```

Show current active session information.

Displays the active session name, location, and creation timestamp.
If no session is active, provides instructions for initializing one.


```python
stanza.cli.delete_session(
    force: bool, keep_data: bool
) -> None
```

Delete the active session directory or clear the pointer.


```python
stanza.cli._get_config_file() -> pathlib.Path
```

Get path to live plot config file.

**Returns:**

Path to live_plot_config.json in the .stanza directory


```python
stanza.cli._read_config() -> dict[str, typing.Any]
```

Read live plot config from disk.

**Returns:**

Configuration dictionary, or empty dict if file doesn't exist


```python
stanza.cli._write_config(config: dict[str, typing.Any]) -> None
```

Write live plot config to disk.

**Parameters:**

<ParamField path="config" type="dict[str, typing.Any]">
  Configuration dictionary to persist
</ParamField>


```python
stanza.cli.live_plot() -> None
```

Manage live plotting configuration.

Configure and control live plotting for experiment data visualization
during runtime. Supports both server and inline backends.


```python
stanza.cli.enable_live_plot(
    backend: str, port: int
) -> None
```

Enable live plotting for experiments.

Configures DataLogger to automatically start live plotting when
experiments run. The server backend starts a Bokeh server that
can be viewed in a browser, while the inline backend displays
plots directly in Jupyter notebooks.


```python
stanza.cli.disable_live_plot() -> None
```

Disable live plotting for experiments.

Turns off automatic live plotting. Experiments will run normally
without real-time visualization.


```python
stanza.cli.live_plot_status() -> None
```

Show current live plotting configuration.

Displays whether live plotting is enabled and the configured
backend and port settings.


```python
stanza.cli.jupyter_cli() -> None
```

Manage Jupyter notebook server.

Start, stop, and monitor a background Jupyter server with automatic
cell output logging. The server runs detached and survives terminal
closure.


```python
stanza.cli.jupyter_start(
    notebook_dir: pathlib.Path, port: int
) -> None
```

Start a Jupyter notebook server in the background.

Launches a JupyterLab server as a detached process with automatic
cell output logging enabled. The server runs independently of the
terminal and can be stopped with 'stanza jupyter stop'.

Cell outputs are automatically logged to `<notebook_name>`.log files
in the same directory as the notebook.

Examples:

    stanza jupyter start

    stanza jupyter start /path/to/notebooks --port 8889


```python
stanza.cli.jupyter_stop() -> None
```

Stop the Jupyter notebook server gracefully.

Uses escalating shutdown strategies to ensure the server stops:
1. REST API shutdown request
2. SIGTERM signal
3. SIGKILL signal (if necessary)

Safe to run even if no server is currently running.

Examples:

    stanza jupyter stop


```python
stanza.cli.jupyter_status() -> None
```

Show current Jupyter server status.

Displays server information including process ID, JupyterLab URL,
uptime, and notebook root directory. Shows helpful message if no
server is running.

Examples:

    stanza jupyter status


```python
stanza.cli.jupyter_open() -> None
```

Open JupyterLab in your default browser.

Opens the JupyterLab URL with authentication token automatically
included. If no server is running, starts one automatically in the
current directory.

Examples:

    stanza jupyter open


```python
stanza.cli._require_server() -> None
```

Check if Jupyter server is running, abort if not.

**Raises:**

click.Abort: If no server is running


```python
stanza.cli._find_notebook(name: str) -> dict[str, typing.Any]
```

Find notebook session by name, abort if not found or ambiguous.

Performs case-insensitive substring matching on notebook names.

**Parameters:**

<ParamField path="name" type="str">
  Notebook name or partial name to search for
</ParamField>

**Returns:**

Session dictionary containing notebook_path, log_path, etc.

**Raises:**

click.Abort: If no matches found or multiple matches found


```python
stanza.cli.jupyter_list() -> None
```

List all active notebook sessions.

Shows the names of all notebooks currently running with active
kernels on the Jupyter server.


```python
stanza.cli.jupyter_logs(
    notebook: str | None, lines: int
) -> None
```

View or list notebook log files.

Without arguments, lists all active notebook sessions with their
log files and sizes. With a notebook name, streams the log file
in real-time (like 'tail -f'). Press Ctrl+C to detach.

Examples:

    stanza jupyter logs

    stanza jupyter logs my_notebook.ipynb

    stanza jupyter logs my_notebook --lines 20


```python
stanza.cli.jupyter_attach(
    notebook: str, lines: int
) -> None
```

Attach to a notebook with active kernel control.

Similar to 'logs' but with additional keyboard controls:
- Ctrl+C: Kill the notebook's kernel
- ESC (twice): Exit without killing the kernel

Useful for monitoring and controlling long-running notebook executions.

Examples:

    stanza jupyter attach my_notebook.ipynb

    stanza jupyter attach experiment --lines 20


```python
stanza.cli.main() -> None
```

Entry point for CLI.