Skip to content

Commit

Permalink
Merge pull request #92 from CHIMEFRB/91-make-the-scout-command-take-t…
Browse files Browse the repository at this point in the history
…he-scope-and-name-in-the-same-order-as-other-commands

fix(scout): change order of the args
  • Loading branch information
tjzegmott committed Jun 14, 2024
2 parents ed5fd1a + 797eeac commit d5c33b8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
22 changes: 12 additions & 10 deletions docs/scout.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# 🕵️ Investigating a dataset with scout

<!-- termynal -->

```bash
❯ datatrail scout --help
Usage: datatrail scout [OPTIONS] DATASET [SCOPES]...
Usage: datatrail scout [OPTIONS] [SCOPES]... DATASET

Scout a dataset.

Expand All @@ -28,14 +29,14 @@ filtered to only show information for the `chime.event.baseband.raw` scope
and unfiltered.

!!! note
The output below does not show the correct colouring. The rows of the table
are colour-coded to indicate if it is observed or expected. Observed
values are displayed in blue and expected values are in yellow.
The output below does not show the correct colouring. The rows of the table
are colour-coded to indicate if it is observed or expected. Observed
values are displayed in blue and expected values are in yellow.

=== "Filtering by scope"

```bash
❯ datatrail scout 382085503 chime.event.baseband.raw
❯ datatrail scout chime.event.baseband.raw 382085503
Scout Results for 382085503
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━━┓
┃ Scope ┃ chime ┃ baseband_buffer ┃ kko ┃ gbo ┃ hco ┃ minoc ┃
Expand All @@ -48,7 +49,7 @@ and unfiltered.
this may be due to the file type filtering when querying each site. This is a
known limitation of the current implementation.
```

1. The Observed number of files.
2. The Expected number of files.

Expand Down Expand Up @@ -76,18 +77,19 @@ and unfiltered.
```

!!! failure "Negative files"
If the server encounters an error it is represented as a negative number.
Which can occur when communicating with the mini-servers running at each
storage element.
If the server encounters an error it is represented as a negative number.
Which can occur when communicating with the mini-servers running at each
storage element.

### Healing at Minoc

In some cases, the number of files expected at minoc may be less than the number
that actually exist there. This can occur when API requests drop, leading to an
inconsistent state in the database. When this is seen by `scout`, the command
offers to remedy the situation by adding the missing replicas.

```bash
❯ datatrail scout 383577603 chime.event.baseband.raw
❯ datatrail scout chime.event.baseband.raw 383577603
Scout Results for 383577603
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━━┓
┃ Scope ┃ chime ┃ baseband_buffer ┃ kko ┃ gbo ┃ hco ┃ minoc ┃
Expand Down
8 changes: 4 additions & 4 deletions dtcli/scout.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@


@click.command(name="scout", help="Scout a dataset.")
@click.argument("dataset", required=True, type=click.STRING, nargs=1)
@click.argument("scopes", required=False, type=click.STRING, nargs=-1)
@click.argument("dataset", required=True, type=click.STRING, nargs=1)
@click.option("-v", "--verbose", count=True, help="Verbosity: v=INFO, vv=DEBUG.")
@click.option("-q", "--quiet", is_flag=True, help="Set log level to ERROR.")
@click.pass_context
def scout( # noqa: C901
ctx: click.Context,
dataset: str,
scopes: List[str],
dataset: str,
verbose: int,
quiet: bool,
):
"""Scout a dataset.
Args:
ctx (click.Context): Click context.
dataset (str): Name of dataset.
scopes (List[str]): Scopes of dataset.
dataset (str): Name of dataset.
verbose (int): Verbosity: v=INFO, vv=DUBUG.
quiet (bool): Set log level to ERROR.
Expand All @@ -49,8 +49,8 @@ def scout( # noqa: C901
# Set logging level.
set_log_level(logger, verbose, quiet)
logger.debug("`scout` called with:")
logger.debug(f"dataset: {dataset} [{type(dataset)}]")
logger.debug(f"scopes: {scopes} [{type(scopes)}]")
logger.debug(f"dataset: {dataset} [{type(dataset)}]")
logger.debug(f"verbose: {verbose} [{type(verbose)}]")
logger.debug(f"quiet: {quiet} [{type(quiet)}]")

Expand Down
19 changes: 19 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,25 @@ def test_cli_pull_help(runner: CliRunner) -> None:
assert result.output == expected_response


def test_cli_scout_help(runner: CliRunner) -> None:
"""Test CLI scout help page.
Args:
runner (CliRunner): Click runner.
"""
result = runner.invoke(datatrail, ["scout", "--help"])
expected_response = """Usage: cli scout [OPTIONS] [SCOPES]... DATASET
Scout a dataset.
Options:
-v, --verbose Verbosity: v=INFO, vv=DEBUG.
-q, --quiet Set log level to ERROR.
--help Show this message and exit.
"""
assert result.exit_code == 0
assert result.output == expected_response


def test_cli_clear_help(runner: CliRunner) -> None:
"""Test CLI clear help page.
Expand Down

0 comments on commit d5c33b8

Please sign in to comment.