Skip to content

Commit

Permalink
allow multiple status options from gantry list
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh committed May 31, 2024
1 parent 4b78c7b commit e5aa48d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Changed what info is displayed by default from `gantry cluster util`. Now only a succinct summary is shown by default, but you can still get node details by adding the flag `--nodes`.
- Allow multiple `--status` options with `gantry list` command.

## [v1.1.0](https://github.com/allenai/beaker-gantry/releases/tag/v1.1.0) - 2024-05-29

Expand Down
13 changes: 7 additions & 6 deletions gantry/commands/list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime, timedelta, timezone
from itertools import islice
from typing import Generator, Optional, Tuple
from typing import Generator, List, Optional, Tuple

import click
from beaker import Beaker, Experiment, Task, Tasks
Expand Down Expand Up @@ -58,6 +58,7 @@ class Defaults:
"--status",
type=click.Choice(list(JobStatus)),
help="Filter by status.",
multiple=True,
)
@click.option(
"--max-age",
Expand All @@ -70,7 +71,7 @@ def list_cmd(
limit: int = Defaults.limit,
author: Optional[str] = None,
me: bool = False,
status: Optional[str] = None,
status: Optional[List[str]] = None,
max_age: int = Defaults.max_age,
):
"""
Expand All @@ -94,7 +95,7 @@ def list_cmd(
task = progress.add_task("Collecting experiments...", total=limit)
for exp, tasks in islice(
iter_experiments(
beaker, workspace=workspace, author=author, status=status, max_age=max_age
beaker, workspace=workspace, author=author, statuses=status, max_age=max_age
),
limit,
):
Expand All @@ -116,7 +117,7 @@ def iter_experiments(
*,
workspace: Optional[str],
author: Optional[str],
status: Optional[str],
statuses: Optional[List[str]],
max_age: int,
) -> Generator[Tuple[Experiment, Tasks], None, None]:
now = datetime.now(tz=timezone.utc).astimezone()
Expand All @@ -142,9 +143,9 @@ def iter_experiments(
tasks = beaker.experiment.tasks(exp)

# Maybe filter by status.
if status is not None:
if statuses:
for task in tasks:
if get_status(task) == status:
if get_status(task) in statuses:
break
else:
continue
Expand Down

0 comments on commit e5aa48d

Please sign in to comment.