# ormaos diff

> Compares two recordings by place in the code and by order, and says what each one has, without saying which one is right.

```text
ormaos diff [-h] [--json] [--limit N] a b
```

| Argument | From the parser | Default |
|---|---|---|
| `a` | a recording: r3, 3 or last. |  |
| `b` | the other recording. |  |
| `--json` | print JSON on stdout. |  |
| `--limit N` | show at most N differences of each kind (default 20) | `20` |

```console
$ ormaos diff r1 r3
r1 -> r3, matched by place in the code and order, not by address
  r1: exit 0, 322 calls, 7 exceptions, 182 io events, 8 logging records
  r3: exit 0, 346 calls, 1 exception, 218 io events, 2 logging records
calls: 6 of 31 places differ
  check_order at validate.py:47: 36 calls in both; 6 raised in r1, none in r3; call 7 raised in r1 and returned in r3  [r1:c167 r3:c167]
  check_sku at validate.py:22: 36 calls in both; 6 raised in r1, none in r3; call 7 raised in r1 and returned in r3  [r1:c168 r3:c168]
  check_quantity at validate.py:27: 30 calls in r1, 36 in r3  [r1:c133 r3:c133]
  check_unit at validate.py:42: 30 calls in r1, 36 in r3  [r1:c134 r3:c134]
  apply_order at inventory.py:78: 30 calls in r1, 36 in r3  [r1:c135 r3:c135]
  to_units at inventory.py:71: 30 calls in r1, 36 in r3  [r1:c136 r3:c136]
exceptions: 1 of 2 groups differ
  swallowed validate.SkuFormatError, raised at validate.py:24, handled at job.py:57: 6 in r1, none in r3  [r1:e1]
io: 6 of 8 groups differ
  sqlite "SELECT on_hand, pack_size FROM stock WHERE sku = ?"  at inventory.py:87 in apply_order: 30 in r1, 36 in r3  [r1:i3 r3:i3]
  sqlite "SELECT ? FROM applied_orders WHERE order_id = ?"  at inventory.py:92 in apply_order: 30 in r1, 36 in r3  [r1:i4 r3:i4]
  sqlite BEGIN  at inventory.py:101 in apply_order: 30 in r1, 36 in r3  [r1:i5 r3:i5]
  sqlite "UPDATE stock SET on_hand = on_hand - ? WHERE sku = ?"  at inventory.py:101 in apply_order: 30 in r1, 36 in r3  [r1:i6 r3:i6]
  sqlite "INSERT INTO applied_orders (order_id, sku, quantity, applied_at) VALU..."  at inventory.py:105 in apply_order: 30 in r1, 36 in r3  [r1:i7 r3:i7]
  sqlite COMMIT  at inventory.py:100 in apply_order: 30 in r1, 36 in r3  [r1:i8 r3:i8]
logs: 1 of 3 groups differ
  WARNING order_sync "order %s skipped: %s"  dropped by the level  at job.py:58 in sync_orders: 6 in r1, none in r3  [r1:l2]
data: the same in both (0 places)
not compared: values, shapes of arguments and results, durations, cpu and memory, the lines of `path`, which process or thread an event was in, the versions of the code
next: ormaos exceptions r1:e1 | ormaos tree r1:c167 | ormaos io r1:i3 | ormaos logs r1:l2 | ormaos tree r3:c167
```

`diff` matches a call, an exception, an I/O event or a logging record by where it is in the code (file, function, line), and events at the same place by order. It never matches by address. For each kind it says how many places or groups differ, then each difference with the counts and the addresses on both sides.

- `code:` says whether the two recordings ran the same version of the code, when git knows it.
- `data:` compares the DataFrames, arrays and tensors at the calls: for each place it names the first call where what was recorded is not the same. The smallest and the largest number are not compared.
- `capabilities:` appears when the two recorded different capabilities; what one of them did not record is not compared.
- `not compared:` lists what `diff` never compares: values, shapes of arguments and results, durations, CPU and memory, the lines of `path`, processes and threads.

Two recordings of the same code and the same input give `the same in both` for every kind.

## Arguments

### `a`, `b`

Two recordings: `r3`, `3` or `last`. An address inside a recording is refused.

### `--limit N`

At most N differences of each kind. Default 20.

### `--json`

Kind `diff`. Schema: [/schemas/diff.json](/schemas/diff.json).

## Recordings with different capabilities

```console
$ ormaos diff r1 r2
r1 -> r2, matched by place in the code and order, not by address
  r1: exit 0, 203 calls, 0 exceptions, 10 io events
  r2: exit 0, 0 calls, 0 exceptions, 10 io events
capabilities: calls context dataframes exceptions io logs tensors in r1, context exceptions io in r2
calls: not compared (calls not recorded in r2)
exceptions: the same in both (0 groups)
io: the same in both (10 groups)
logs: not compared (logs not recorded in r2)
data: not compared (dataframes and tensors not recorded in r2)
not collected only in r1: logs with no line of user code
not compared: values, shapes of arguments and results, durations, cpu and memory, the lines of `path`, which process or thread an event was in, the versions of the code
next: ormaos show r1 | ormaos show r2
```

---

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