Skip to content

livery.workshop._store_tasks

livery.workshop._store_tasks

fm store.ls and fm store.show: the state store, read by hand.

Every row the workshop keeps is a declared series of the state store (livery.git), gathered in one place (livery.workshop._series). store.ls names each series and family with its scope (local, or remote and mirrored by a sync, or remote and fetched on read), its window, and what it holds; store.show prints a series' rows newest first through the same reader the verdicts use, so what a person reads is what the gate judged. Both only read: the gate's verbs write, and the janitor bounds.

Functions:

Name Description
ls_flow

One line per declared series or family: scope, window, and what it holds.

show_flow

A series' rows newest first, a single row in full, or the rows as JSON.

store_ls

List every series the workshop keeps: its scope, its window, what it holds.

store_show

Print a series' rows newest first, through the reader the verdicts use.

Attributes:

Name Type Description
store

store module-attribute

store = group('store', help='The state store, read by hand')

ls_flow

ls_flow(root: Path) -> list[str]

One line per declared series or family: scope, window, and what it holds.

One listing of the remote namespace and one fetch of what the checkout lacks serve every series, so the call costs two round trips whatever the store holds.

Source code in packages/workshop/src/livery/workshop/_store_tasks.py
def ls_flow(root: Path) -> list[str]:
    """One line per declared series or family: scope, window, and what it holds.

    One listing of the remote namespace and one fetch of what the
    checkout lacks serve every series, so the call costs two round
    trips whatever the store holds.
    """
    with git.remote_snapshot(state_store(root), fetch=git.WHOLE):
        return _ls_lines(root)

show_flow

show_flow(root: Path, name: str, *, key: str = '', row: str = '', run: str = '', item: str = '', differences: bool = False, flaky: bool = False, escapes: bool = False, limit: int = 0, as_json: bool = False) -> list[str]

A series' rows newest first, a single row in full, or the rows as JSON.

Refuses an unknown name (naming the known ones), a negative limit, combining row and limit, a family without its key (listing the keys it holds, unless run, item or differences inspects the proved family), a key of the wrong shape, an unknown or ambiguous row, and a series the store cannot read (with the store's reason). Local series read directly from the checkout's git directory; remote series go through one listing of the remote namespace.

Source code in packages/workshop/src/livery/workshop/_store_tasks.py
def show_flow(
    root: Path,
    name: str,
    *,
    key: str = "",
    row: str = "",
    run: str = "",
    item: str = "",
    differences: bool = False,
    flaky: bool = False,
    escapes: bool = False,
    limit: int = 0,
    as_json: bool = False,
) -> list[str]:
    """A series' rows newest first, a single row in full, or the rows as JSON.

    Refuses an unknown name (naming the known ones), a negative
    *limit*, combining *row* and *limit*, a family without its key
    (listing the keys it holds, unless *run*, *item* or *differences*
    inspects the ``proved`` family), a key of the wrong shape, an unknown
    or ambiguous *row*, and a series the store cannot read (with the
    store's reason). Local series read directly from the checkout's git
    directory; remote series go through one listing of the remote
    namespace.
    """
    if limit < 0:
        fail("limit must be non-negative")
    if row and limit:
        fail("cannot combine --row and --limit")
    declared = _declared(root)
    series_decl = next((each for each in declared if each.name == name), None)
    if series_decl is None:
        fail(
            f"no series named {name!r}; the series are"
            f" {', '.join(each.name for each in declared)}"
        )
    if run and name != "proved":
        fail("--run applies only to the proved family")
    if item and name != "proved":
        fail("--item applies only to the proved family")
    if differences and name != "proved":
        fail("--differences applies only to the proved family")
    if flaky and name != "proved":
        fail("--flaky applies only to the proved family")
    if escapes and name != "proved":
        fail("--escapes applies only to the proved family")
    if differences and (key or row or run or item or flaky or escapes):
        fail(
            "cannot combine --differences with --key, --row, --run, --item,"
            " --flaky, or --escapes"
        )
    if flaky and (key or row or run or item or escapes):
        fail("cannot combine --flaky with --key, --row, --run, --item, or --escapes")
    if escapes and (key or row or run or item):
        fail("cannot combine --escapes with --key, --row, --run, or --item")
    if item and (key or row or run):
        fail("cannot combine --item with --key, --row, or --run")
    if differences:
        from livery.workshop._proved import SHADOW_DIFFS

        with git.remote_snapshot(state_store(root), fetch=(SHADOW_DIFFS.name,)):
            return _show_proved_differences(root, limit=limit, as_json=as_json)
    if flaky:
        with git.remote_snapshot(state_store(root), fetch=(name,)):
            return _show_proved_flaky(root, limit=limit, as_json=as_json)
    if escapes:
        from livery.workshop._proved import ESCAPES

        with git.remote_snapshot(state_store(root), fetch=(ESCAPES.name,)):
            return _show_proved_escapes(root, limit=limit, as_json=as_json)
    if item:
        with git.remote_snapshot(state_store(root), fetch=(name,)):
            return _show_proved_item(root, item, limit=limit, as_json=as_json)
    if name == "measures" and not row and not key:
        with git.remote_snapshot(state_store(root), fetch=(name,)):
            return _show_measures(root, limit=limit, as_json=as_json)
    if series_decl.local:
        return _show_item(
            root,
            series_decl,
            key=key,
            row=row,
            run=run,
            limit=limit,
            as_json=as_json,
        )
    with git.remote_snapshot(state_store(root), fetch=(name,)):
        return _show_item(
            root,
            series_decl,
            key=key,
            row=row,
            run=run,
            limit=limit,
            as_json=as_json,
        )

store_ls

store_ls() -> None

List every series the workshop keeps: its scope, its window, what it holds.

A remote series is read from origin, a local one from this checkout's git directory; a series that cannot be read prints the store's reason in its place.

Source code in packages/workshop/src/livery/workshop/_store_tasks.py
@store.task(name="ls")
def store_ls() -> None:
    """List every series the workshop keeps: its scope, its window, what it holds.

    A remote series is read from origin, a local one from this
    checkout's git directory; a series that cannot be read prints the
    store's reason in its place.
    """
    for line in ls_flow(_root()):
        print(line)

store_show

store_show(series: Annotated[str, doc("the series' name, as store.ls lists it")], key: Annotated[str, doc("a family's key, its parts comma-separated")] = '', row: Annotated[str, doc('one row by name or unique prefix, printed in full')] = '', run: Annotated[str, doc('filter proved rows to one forge run id')] = '', item: Annotated[str, doc('show recorded reads for one proved test item path')] = '', differences: Annotated[bool, doc('list shadow comparison differences for the proved family')] = False, flaky: Annotated[bool, doc('list units flagged flaky (both green and red on one fingerprint)')] = False, escapes: Annotated[bool, doc('list selection escapes caught on scheduled audit runs')] = False, limit: Annotated[int, doc('maximum number of newest rows to show (0 for all)')] = 0, json: Annotated[bool, doc('the rows as JSON, newest first')] = False) -> None

Print a series' rows newest first, through the reader the verdicts use.

Each row prints as its file name and stamp, then its fields on one line with containers by size; --row prints one row in full as JSON (by exact name or unique prefix, as the diagnostics: line names it), --run lists every row written by one run in the proved family, --item lists what one test item read in the proved family, --differences lists shadow comparison disagreements recorded for the proved family, --flaky lists units flagged flaky in the proved family, --escapes lists selection escapes recorded for the proved family, --limit caps how many newest rows print, and --json prints every selected row as JSON. A family (store.ls shows its key parts) is shown one key at a time, and without --key lists the keys it holds.

Source code in packages/workshop/src/livery/workshop/_store_tasks.py
@store.task(name="show")
def store_show(
    series: Annotated[str, doc("the series' name, as store.ls lists it")],
    key: Annotated[str, doc("a family's key, its parts comma-separated")] = "",
    row: Annotated[str, doc("one row by name or unique prefix, printed in full")] = "",
    run: Annotated[str, doc("filter proved rows to one forge run id")] = "",
    item: Annotated[str, doc("show recorded reads for one proved test item path")] = "",
    differences: Annotated[
        bool, doc("list shadow comparison differences for the proved family")
    ] = False,
    flaky: Annotated[
        bool, doc("list units flagged flaky (both green and red on one fingerprint)")
    ] = False,
    escapes: Annotated[
        bool, doc("list selection escapes caught on scheduled audit runs")
    ] = False,
    limit: Annotated[int, doc("maximum number of newest rows to show (0 for all)")] = 0,
    json: Annotated[bool, doc("the rows as JSON, newest first")] = False,
) -> None:
    """Print a series' rows newest first, through the reader the verdicts use.

    Each row prints as its file name and stamp, then its fields on one
    line with containers by size; ``--row`` prints one row in full as
    JSON (by exact name or unique prefix, as the ``diagnostics:`` line
    names it), ``--run`` lists every row written by one run in the
    ``proved`` family, ``--item`` lists what one test item read in the
    ``proved`` family, ``--differences`` lists shadow comparison
    disagreements recorded for the ``proved`` family, ``--flaky`` lists
    units flagged flaky in the ``proved`` family, ``--escapes`` lists
    selection escapes recorded for the ``proved`` family, ``--limit``
    caps how many newest rows print, and ``--json`` prints every
    selected row as JSON. A family (``store.ls`` shows its key parts) is
    shown one key at a time, and without ``--key`` lists the keys it
    holds.
    """
    for line in show_flow(
        _root(),
        series,
        key=key,
        row=row,
        run=run,
        item=item,
        differences=differences,
        flaky=flaky,
        escapes=escapes,
        limit=limit,
        as_json=json,
    ):
        print(line)