Skip to content

Commit

Permalink
Merge branch 'main' into aurora
Browse files Browse the repository at this point in the history
  • Loading branch information
cms21 committed Nov 29, 2023
2 parents 4de82ea + 40688ec commit cc930a5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
6 changes: 5 additions & 1 deletion balsam/client/requests_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ def request(
except requests.Timeout as exc:
logger.warning(f"Attempt Retry of Timed-out request {http_method} {absolute_url}")
self.backoff(exc)
except (requests.ConnectionError, requests.HTTPError) as exc:
except requests.ConnectionError as exc:
logger.warning(f"Attempt retry ({self._attempt} of {self.retry_count}) of connection: {exc}")
self.backoff(exc)
except requests.HTTPError as exc:
if authenticating is False:
logger.warning(f"Attempt retry ({self._attempt} of {self.retry_count}) of connection: {exc}")
self.backoff(exc)
else:
try:
return response.json() # type: ignore
Expand Down
39 changes: 34 additions & 5 deletions balsam/cmdline/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,20 @@ def modify(job_ids: List[int], tags: List[str], state: JobState) -> None:
@job.command()
@click.option("-i", "--id", "job_ids", multiple=True, type=int)
@click.option("-t", "--tag", "tags", multiple=True, type=str, callback=validate_tags)
@click.option("-s", "--state", type=str, callback=validate_state)
@click.option("-ns", "--exclude-state", type=str, callback=validate_state)
@click.option("--site", "site_selector", default="")
@click.option("-y", "yes", is_flag=True, default=False)
@click.option("--all", is_flag=True, default=False)
def rm(job_ids: List[int], tags: List[str], yes: bool, all: bool) -> None:
def rm(
job_ids: List[int],
site_selector: str,
tags: List[str],
state: Optional[JobState],
exclude_state: Optional[JobState],
yes: bool,
all: bool,
) -> None:
"""
Remove Jobs
Expand All @@ -357,19 +368,37 @@ def rm(job_ids: List[int], tags: List[str], yes: bool, all: bool) -> None:
balsam job rm --tag workflow=temp-test
3) Remove all jobs (DANGER!)
3) Remove Jobs by State
balsam job rm --state FAILED
4) Filter by Site ID or Path fragments (comma-separated)
balsam job rm --site=123,my-cori-site
5) Remove all jobs (DANGER!)
balsam job rm --all
"""
client: RESTClient = load_client()
jobs = client.Job.objects.all()

jobs = filter_by_sites(client.Job.objects.all(), site_selector)

if job_ids:
jobs = jobs.filter(id=job_ids)
elif tags:
jobs = jobs.filter(tags=tags)
elif tags or state or exclude_state:
if tags:
jobs = jobs.filter(tags=tags)
if state:
jobs = jobs.filter(state=state)
click.echo("filtering by state")
if exclude_state:
jobs = jobs.filter(state__ne=exclude_state)
elif all:
click.echo("THIS WILL DELETE ALL JOBS! CAUTION!")
pass
elif site_selector != "":
pass
else:
raise click.BadParameter("Provide either list of Job ids or tags to delete")
count = jobs.count()
Expand Down

0 comments on commit cc930a5

Please sign in to comment.