# ormaos run

> Runs a command unchanged, records the Python processes it starts into .ormaos/, prints a summary on stderr and exits with the command's exit code.

```text
ormaos run [--path SCOPE] [--only CAPABILITIES] [--no-io] [--values] [--json-out FILE] -- <command> [args...]
```

| Argument | From the parser | Default |
|---|---|---|
| `--only CAPABILITIES` | record only these capabilities, separated by commas, out of: context, calls, exceptions, path, io, logs, dataframes, tensors (context is always recorded; path also needs --path; path, dataframes and tensors need calls) |  |
| `--values` | also record values: arguments and results of calls and messages of exceptions, cut at a size limit, with likely secrets written as ***. Never recorded without this option. |  |
| `--path SCOPE` | also record line by line inside SCOPE: file.py, file.py:function or function (can be given more than once) Can be given more than once. |  |
| `--no-io` | do not record I/O (database, files, subprocesses, HTTP) |  |
| `--json-out FILE` | also write the overview of the recording to FILE, as JSON. |  |

Everything after `--` is the command, as you would type it. The command runs with its own stdin, stdout and stderr. The summary, at most five lines, goes to stderr after the command ends, each line starting with `ormaos:`.

```console
$ ormaos run -- python job.py
sync finished: OK
ormaos: r1 exit 0 in …: 1 Python process, 322 calls, 7 exceptions (6 swallowed), 182 io
ormaos: swallowed 6x validate.SkuFormatError at job.py:57, raised at validate.py:24 [r1:e1]
ormaos: not collected: io: reads of the 1 file opened at fetch.py:26: opened for reading, and no `read` call by Python code was seen on a file of that name: if it was read, that was inside C code (a file that is iterated, `for line in f`, `csv.reader`)
ormaos: saved in .ormaos/r1, next: ormaos exceptions r1:e1 | ormaos tree r1:c1
```

## Arguments

### `--only CAPABILITIES`

Records only these capabilities, separated by commas: `context`, `calls`, `exceptions`, `path`, `io`, `logs`, `dataframes`, `tensors`. `context` is always recorded. `path` also needs `calls` and a scope (`--path`); `dataframes` and `tensors` need `calls`. A name that is not a capability is rejected before anything runs, with exit code `2`:

```console
$ ormaos run --only calls,nothing -- python ok.py
usage: ormaos [-h] [--version] <verb> ...
ormaos: error: --only: unknown capability 'nothing': the capabilities are context, calls, exceptions, path, io, logs, dataframes, tensors
# exit code 2
```

With `--only context`, nothing is watched inside the program. With any other choice, the calls and exceptions that were not asked for are still followed while the program runs and are left out when the recording is written: the recording is smaller, the program is not much faster. What was left out is in `not_collected`.

```console
$ ormaos run --only context,exceptions,io --json-out overview.json -- python job.py
sync finished: OK
ormaos: r5 exit 0 in …: 1 Python process, 0 calls, 7 exceptions (6 swallowed), 182 io
ormaos: swallowed 6x validate.SkuFormatError at job.py:57, raised at validate.py:24 [r5:e1]
ormaos: not collected: io: reads of the 1 file opened at fetch.py:26: opened for reading, and no `read` call by Python code was seen on a file of that name: if it was read, that was inside C code (a file that is iterated, `for line in f`, `csv.reader`)
ormaos: saved in .ormaos/r5, next: ormaos exceptions r5:e1
```

### `--values`

Also records values: the arguments and results of calls and the messages of exceptions, when they are of simple types, cut at a size limit, with likely secrets written as `***`. Never recorded without this option. See [Shapes, not values](/python/concepts/shapes-and-values.md).

```console
$ ormaos exceptions r4:e1
r4:e1 validate.SkuFormatError: swallowed
  raised at   validate.py:24 in check_sku  [r4:c168]
  left calls   check_sku [r4:c168], check_order [r4:c167]
  handled at  job.py:57 in sync_orders  [r4:c130]  and not raised again
  message     "SKU 'kbd-0101' is not in the format AAA-0000"  (recorded with --values: cut at a size limit, likely secrets written as ***)
  logs        6 logging records in the call that handled it and below (6 dropped by the level)  [r4:l2]
  same type, same handler: 6 in all: r4:e1 r4:e2 r4:e3 r4:e4 r4:e5 ...
next: ormaos tree r4:c130 | ormaos logs r4:c130 | ormaos io r4:c130 | ormaos tree r4:c168 | ormaos exceptions r4:e2
```

### `--path SCOPE`

Also records line by line inside a scope: `file.py`, `file.py:function` or `function`. Can be given more than once. Read the lines with [`ormaos path`](/python/reference/cli/path.md).

```console
$ ormaos run --path job.py:sync_orders -- python job.py
sync finished: OK
ormaos: r2 exit 0 in …: 1 Python process, 322 calls, 7 exceptions (6 swallowed), 182 io
ormaos: swallowed 6x validate.SkuFormatError at job.py:57, raised at validate.py:24 [r2:e1]
ormaos: not collected: io: reads of the 1 file opened at fetch.py:26: opened for reading, and no `read` call by Python code was seen on a file of that name: if it was read, that was inside C code (a file that is iterated, `for line in f`, `csv.reader`)
ormaos: saved in .ormaos/r2, next: ormaos exceptions r2:e1 | ormaos tree r2:c1
```

### `--no-io`

Does not record I/O (database, files, subprocesses, HTTP).

### `--json-out FILE`

Also writes the overview of the recording to `FILE`, as the JSON document of `ormaos show --json`. The JSON is never mixed with the output of the program.

## Exit code

The command's own, always. 128 plus the signal number when a signal ended it; `127` when the command was not found; `126` when it could not be started; `2` when the options of `ormaos run` were not understood (the command did not run). See [Exit codes](/python/reference/exit-codes.md).

## Before and after the command

- Before: three read-only git commands in the working directory (`rev-parse`, `status`, `diff`), to know which code ran. See [Recording](/python/concepts/recording.md).
- After: it waits up to one second for Python processes of the recording that are still alive, then reads the recording to print the summary.

---

Source: https://docs.ormaos.com/python/reference/cli/run/ · ormaos 0.0.1 · ormaos-python 968f69776c · ormaos-examples 6e27be5922
