Skip to content

Commit

Permalink
fix(buckets): added cli to delete works
Browse files Browse the repository at this point in the history
  • Loading branch information
shinybrar committed Jan 9, 2023
1 parent df6da44 commit c72c61d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion chime_frb_api/workflow/cli.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
""" Workflow command line interface """
"""Workflow command line interface."""

import click

from chime_frb_api.workflow.pipeline import run
from chime_frb_api.workflow.utils import prune_work


@click.group()
def cli():
"""Workflow Command Line Interface."""
pass


cli.add_command(run)
cli.add_command(prune_work)

if __name__ == "__main__":
cli()
27 changes: 27 additions & 0 deletions chime_frb_api/workflow/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Common Workflow Utilities."""
from typing import List, Optional

import click

from chime_frb_api.modules.buckets import Buckets


@click.command("prune", help="Prune work[s] from a workflow backend.")
@click.option("bucket", "--bucket", type=str, required=True, help="Name of the bucket.")
@click.option("event", "--event", type=int, required=False, help="CHIME/FRB Event ID.")
@click.option(
"status", "--status", type=str, required=False, help="Status of the work."
)
def prune_work(bucket: str, event: Optional[int] = None, status: Optional[str] = None):
"""Prune work[s] from the workflow backend.
Args:
bucket (str): Name of the bucket.
event (Optional[int], optional): CHIME/FRB Event ID. Defaults to None.
status (Optional[str], optional): Status of work[s] to prune. Defaults to None.
"""
events: Optional[List[int]] = None
if event is not None:
events = [event]
buckets = Buckets()
buckets.delete_many(pipeline=bucket, status=status, events=events)

0 comments on commit c72c61d

Please sign in to comment.