# orca.ui.parts

> A module of morca's API.

Pieces several pages draw: durations, times and partitions in a table's cells, a runs table with each row's actions, links to code, and a run's grant and usage as facts.

## Functions

### `dataset_links`

```mojo
def dataset_links(mut h: Html, names: List[String])
```

### `took_text`

```mojo
def took_text(seconds: Int) -> String
```

A duration as `42s`, `3m 07s` or `2h 05m`; empty for a negative one.

### `took_long`

```mojo
def took_long(seconds: Int) -> String
```

A duration as `42 s`, `3 min 21 s` or `2 h 5 min`.

### `partitions_fact`

```mojo
def partitions_fact(mut h: Html, partitions: String)
```

A run's partitions on its page: all of them if few, else `first … last (N partitions)` with the whole list in a fold.

### `code_link`

```mojo
def code_link(mut h: Html, at: CodeRef)
```

A link to a line of code: every one orca shows is drawn by this, so they all look alike and unlike orca's own links.

### `step_cell`

```mojo
def step_cell(mut h: Html, name: String, links: CodeLinks, attempt: Int = Int(-1))
```

A step's name, then a link to its function where the code is known. With `attempt` (0 for none yet), the name shows the step's card (`orca.ui.step_cards`), and that attempt's on a run's page.

### `source_html`

```mojo
def source_html(mut h: Html, v: VersionRow)
```

The commit, linked to its tree where the host is known.

### `pause_button`

```mojo
def pause_button(mut h: Html, name: String, paused: Bool)
```

Resume a paused pipeline, or pause an active one.

### `cancel_tell`

```mojo
def cancel_tell(r: RunRow) -> String
```

What cancelling `r` does, as its Cancel's dialog says it (`orca.actions.cancel_run`).

### `row_actions`

```mojo
def row_actions(mut h: Html, r: RunRow)
```

A runs table row's Cancel (queued or running) or Retry (failed).

### `runs_table_html`

```mojo
def runs_table_html(mut h: Html, runs: List[RunRow], show_pipeline: Bool, pick: Bool = False, code: Dict[Int, RunCode] = Dict())
```

A table of runs; with `pick`, a checkbox before each, for the list's bulk actions (`form="bulk-runs"`, `orca.ui.runs.runs_bulk_html`), and one in the header that ticks the page's (with JavaScript). With a run's `code`, its pipeline's name shows the pipeline's declaration on hover (`data-src`, the page's `_PEEK`) and a failed run names the step that failed, linked to its function, at the commit the run ran.

### `mb_text`

```mojo
def mb_text(mb: Int) -> String
```

`512 MB`, `1.5 GB`.

### `usage_cell`

```mojo
def usage_cell(mut h: Html, u: Usage, limit_mb: Int = Int(0), grant_mb: Int = Int(0))
```

A `<td>` of a peak in memory, with the CPU in its title, and after it the attempt's memory limit (`orca.cgroup`) when it had one.

### `request_text`

```mojo
def request_text(cpus: String, memory_gb: String) -> String
```

`1..16 CPUs, 2..24 GB`; `auto` as `CPUs auto`, `memory auto..24 GB`.

### `limit_facts`

```mojo
def limit_facts(mut h: Html, limit_mb: Int, max_mb: Int, grant_mb: Int = Int(0))
```

A Memory limit fact (`orca.cgroup`), when there was one.

### `grant_facts`

```mojo
def grant_facts(mut h: Html, r: RunResources)
```

A run's Requested and Granted facts (`orca.resources`), when its pipeline asked for any, and its memory limit (`orca.cgroup`) when it had one.

### `usage_facts`

```mojo
def usage_facts(mut h: Html, u: Usage, live: Bool)
```

A run's or an attempt's Peak memory and CPU used facts (`orca.usage`).

### `named_code_link`

```mojo
def named_code_link(mut h: Html, name: String, at: CodeRef)
```

A link to a function's code labelled with its name; where it is (`file.mojo:26`) is in its title, and in the source shown on hover.

## Aliases

### `TRIES`

```mojo
comptime TRIES = "Times the run's process was started: 1 is normal; more means retries, a lost instance or a resume."
```

What a runs table's Tries column counts (`orca.runs.starts`).

### `PEAK_HELP`

```mojo
comptime PEAK_HELP = "The most memory its processes held at once: the run's process and what it started (dista's local workers too), sampled every second by the scheduler or worker that started it, and at the end the largest single process. Not measured on EC2 or Kubernetes."
```

### `CPU_HELP`

```mojo
comptime CPU_HELP = "The CPU time its processes used, user and system, and the most cores they kept busy over one sample's second. macOS gives only the time, and only for a process that made one attempt."
```

### `LIMIT_HELP`

```mojo
comptime LIMIT_HELP = "Its latest start's cgroup (orca.cgroup): past the limit (memory.high, its grant, request or ORCA_RUN_MEMORY_MB) the kernel slows its processes and reclaims their memory; past the kill line (memory.max, ORCA_RUN_MEMORY_MARGIN above) it kills them, and the retry asks for more. None where orca can't make cgroups."
```
