From 37e804402197426d20c2854603e6dd1346e451ea Mon Sep 17 00:00:00 2001 From: Christine Simpson Date: Mon, 30 Oct 2023 14:44:35 -0500 Subject: [PATCH 1/6] fixed warning message thrown when logging in --- balsam/client/requests_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/balsam/client/requests_client.py b/balsam/client/requests_client.py index 902df966..5e918328 100644 --- a/balsam/client/requests_client.py +++ b/balsam/client/requests_client.py @@ -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 == 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 From e7bde0e5112f885a9b6cf8a152e4039f7ef7b7d3 Mon Sep 17 00:00:00 2001 From: Christine Simpson Date: Mon, 30 Oct 2023 14:48:39 -0500 Subject: [PATCH 2/6] fixed warning message thrown when logging in --- balsam/client/requests_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/balsam/client/requests_client.py b/balsam/client/requests_client.py index 5e918328..2be7cca6 100644 --- a/balsam/client/requests_client.py +++ b/balsam/client/requests_client.py @@ -102,7 +102,7 @@ def request( logger.warning(f"Attempt retry ({self._attempt} of {self.retry_count}) of connection: {exc}") self.backoff(exc) except requests.HTTPError as exc: - if authenticating == False: + if authenticating is False: logger.warning(f"Attempt retry ({self._attempt} of {self.retry_count}) of connection: {exc}") self.backoff(exc) else: From 42295f0fcc53914e7672ea15baf890f260683d6a Mon Sep 17 00:00:00 2001 From: Christine Simpson Date: Mon, 30 Oct 2023 17:10:16 -0500 Subject: [PATCH 3/6] updated job rm cli --- balsam/cmdline/job.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/balsam/cmdline/job.py b/balsam/cmdline/job.py index ac8bffd1..f024c7b3 100644 --- a/balsam/cmdline/job.py +++ b/balsam/cmdline/job.py @@ -343,9 +343,12 @@ 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 @@ -357,19 +360,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() From 5696f087fd0a500fa99197db34282ecf11ee7113 Mon Sep 17 00:00:00 2001 From: Christine Simpson Date: Tue, 31 Oct 2023 10:17:07 -0500 Subject: [PATCH 4/6] lint fix --- balsam/cmdline/job.py | 4 ++-- requirements/deploy.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/balsam/cmdline/job.py b/balsam/cmdline/job.py index f024c7b3..a0f029d8 100644 --- a/balsam/cmdline/job.py +++ b/balsam/cmdline/job.py @@ -373,9 +373,9 @@ def rm(job_ids: List[int], site_selector: str, tags: List[str], state: Optional[ balsam job rm --all """ client: RESTClient = load_client() - + jobs = filter_by_sites(client.Job.objects.all(), site_selector) - + if job_ids: jobs = jobs.filter(id=job_ids) elif tags or state or exclude_state: diff --git a/requirements/deploy.txt b/requirements/deploy.txt index bce28e09..1192a884 100644 --- a/requirements/deploy.txt +++ b/requirements/deploy.txt @@ -1,5 +1,5 @@ # Pinned dependencies for server deploy -psycopg2==2.9.4 +#psycopg2==2.9.4 fastapi==0.78.0 orjson==3.8.0 fastapi==0.78.0 From ec62f210d768e27b94287a89a928397b8a3e1ee1 Mon Sep 17 00:00:00 2001 From: Christine Simpson <48525133+cms21@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:18:16 -0500 Subject: [PATCH 5/6] Update deploy.txt --- requirements/deploy.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/deploy.txt b/requirements/deploy.txt index 1192a884..bce28e09 100644 --- a/requirements/deploy.txt +++ b/requirements/deploy.txt @@ -1,5 +1,5 @@ # Pinned dependencies for server deploy -#psycopg2==2.9.4 +psycopg2==2.9.4 fastapi==0.78.0 orjson==3.8.0 fastapi==0.78.0 From fe33dcafbd07096df0cbcb31eaf33650cc66d0a5 Mon Sep 17 00:00:00 2001 From: Christine Simpson Date: Tue, 31 Oct 2023 10:50:13 -0500 Subject: [PATCH 6/6] lint fix --- balsam/cmdline/job.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/balsam/cmdline/job.py b/balsam/cmdline/job.py index a0f029d8..43b7900a 100644 --- a/balsam/cmdline/job.py +++ b/balsam/cmdline/job.py @@ -348,7 +348,15 @@ def modify(job_ids: List[int], tags: List[str], state: JobState) -> None: @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], site_selector: str, tags: List[str], state: Optional[JobState], exclude_state: Optional[JobState], 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