cli.meta.ci.roles.runtime package

Submodules

cli.meta.ci.roles.runtime.csvio module

cli.meta.ci.roles.runtime.csvio.dump_csv(records: list[RoleRuntime], fh: IO[str]) → None
cli.meta.ci.roles.runtime.csvio.read_csv(path: str | Path) → list[RoleRuntime]
cli.meta.ci.roles.runtime.csvio.to_csv_string(records: list[RoleRuntime]) → str
cli.meta.ci.roles.runtime.csvio.write_csv(path: str | Path, records: list[RoleRuntime]) → None

cli.meta.ci.roles.runtime.github module

cli.meta.ci.roles.runtime.github.app_for_job(owner: str, repo: str, job: str) → str

Resolve the matrix app id from a deploy job’s display name.

cli.meta.ci.roles.runtime.github.parse_run_ref(url: str) → tuple[str, str, str, str | None]

Return (owner, repo, run_id, job_id|None) from a run/job URL.

cli.meta.ci.roles.runtime.github.records_from_job_url(url: str) → list[RoleRuntime]

Download the role-runtimes-* CSV artifact(s) for a run/job URL.

A job URL narrows the download to that job’s app; a bare run URL pulls every role-runtimes-* artifact in the run.

cli.meta.ci.roles.runtime.logparse module

cli.meta.ci.roles.runtime.logparse.parse_log(log_path: str | Path) → list[RoleRuntime]

Ansible run log -> records.

When the log carries the matrix-deploy round/pass markers, the result is segmented (one block of records per variant round + pass). Otherwise a single combined block is returned. Runtime rows are read from the ROLES RECAP sections only (never TASKS RECAP, whose role-less task rows would double-count); a log without any recap header falls back to reading every profile-shaped line. The recap total line survives as the total row so consumers can cross-check the parsed sum. Per-host task results (ok:, changed:, skipping:, fatal:, failed: under a TASK [role : ...] header) accumulate into each record’s hosts field; delegation targets ([host -> other]) count for the source host. Raises FileNotFoundError when the log is absent (the caller turns that into a hard failure).

cli.meta.ci.roles.runtime.model module

class cli.meta.ci.roles.runtime.model.RoleRuntime(role: str, seconds: float, round: str = '', rounds_total: str = '', pass_num: str = '', pass_mode: str = '', hosts: str = '')

Bases: object

One role’s measured runtime within a deploy segment.

For a non-matrix (combined) deploy with no round markers, the segment fields are empty strings. hosts serializes the per-host outcome of the role’s tasks as space-separated host=status pairs (status: executed | skipped | failed); empty when the log carries no per-host task results for the role (e.g. module aggregate rows).

property host_map: dict[str, str]
hosts: str = ''
pass_mode: str = ''
pass_num: str = ''
role: str
round: str = ''
rounds_total: str = ''
seconds: float
property segment_label: str
property segmented: bool

cli.meta.ci.roles.runtime.render module

cli.meta.ci.roles.runtime.render.render(records: list[RoleRuntime], fmt: str = 'table') → str

cli.meta.ci.roles.runtime.sources module

cli.meta.ci.roles.runtime.sources.load_records(source: str) → list[RoleRuntime]

Load runtime records from a URL, a CSV path, or an Ansible log path.

Module contents

Summarise Ansible profile_roles runtimes per matrix-deploy variant.

Single responsibility per module:

  • model — the RoleRuntime record (one role’s time within a segment).

  • logparse — Ansible run log -> records (splits by matrix round/pass markers).

  • csvio — records <-> CSV (the on-disk metrics schema, a single SPOT).

  • render — records -> text in the format chosen via –format.

  • github — a run/job URL -> records (downloads the CSV artifacts via gh).

  • sources — pick the right loader for a log path, CSV path, or URL.

CLI: python -m cli.meta.ci.roles.runtime <source> [–format …] [–output …].