From f56a21d3fc21e365263bcb1c177512ddff4f2f3d Mon Sep 17 00:00:00 2001 From: James Dempsey Date: Wed, 20 Nov 2024 14:55:57 +1100 Subject: [PATCH 1/2] CASDA - Add support for SUSPENDED jobs Fixes #3133 --- CHANGES.rst | 5 +++++ astroquery/casda/core.py | 2 +- astroquery/casda/tests/data/suspended_job.xml | 22 +++++++++++++++++++ astroquery/casda/tests/test_casda.py | 8 +++---- 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 astroquery/casda/tests/data/suspended_job.xml diff --git a/CHANGES.rst b/CHANGES.rst index 1d926ebbea..c3c47e7bbf 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -26,6 +26,11 @@ alma - Changed the way galactic ranges are used in queries [#3105] +casda +^^^^^ + +- Support jobs which are in the SUSPENDED state (used when copying data) [#3133] + ehst ^^^^ diff --git a/astroquery/casda/core.py b/astroquery/casda/core.py index 7e18e1faa5..b78bf27950 100644 --- a/astroquery/casda/core.py +++ b/astroquery/casda/core.py @@ -516,7 +516,7 @@ def _run_job(self, job_location, verbose, *, poll_interval=20): count = 0 job_details = self._get_job_details_xml(job_location) status = self._read_job_status(job_details, verbose) - while status == 'EXECUTING' or status == 'QUEUED' or status == 'PENDING': + while status == 'EXECUTING' or status == 'QUEUED' or status == 'PENDING' or status == 'SUSPENDED': count += 1 if verbose and (status != prev_status or count > 10): log.info("Job is %s, polling every %d seconds." % (status, poll_interval)) diff --git a/astroquery/casda/tests/data/suspended_job.xml b/astroquery/casda/tests/data/suspended_job.xml new file mode 100644 index 0000000000..4e7e14f860 --- /dev/null +++ b/astroquery/casda/tests/data/suspended_job.xml @@ -0,0 +1,22 @@ + + + + + + + + SUSPENDED + + 2024-04-17T08:10:22.793+0800 + + 0 + + + + + + + + + + \ No newline at end of file diff --git a/astroquery/casda/tests/test_casda.py b/astroquery/casda/tests/test_casda.py index 52dd7f15e7..62a15d40ed 100644 --- a/astroquery/casda/tests/test_casda.py +++ b/astroquery/casda/tests/test_casda.py @@ -29,7 +29,7 @@ DATA_FILES = {'CIRCLE': 'cone.xml', 'RANGE': 'box.xml', 'DATALINK': 'datalink.xml', 'RUN_JOB': 'run_job.xml', 'COMPLETED_JOB': 'completed_job.xml', 'DATALINK_NOACCESS': 'datalink_noaccess.xml', 'cutout_CIRCLE_333.9092_-45.8418_0.5000': 'cutout_333.9092_-45.8418_0.5000.xml', - 'AVAILABILITY': 'availability.xml'} + 'AVAILABILITY': 'availability.xml', 'SUSPENDED_JOB': 'suspended_job.xml'} USERNAME = 'user' PASSWORD = 'password' @@ -58,7 +58,7 @@ def get_mockreturn(self, method, url, data=None, timeout=10, if 'data/async' in str(url): # Responses for an asynchronous SODA job if str(url).endswith('data/async'): - self.first_job_pass = True + self.job_pass_num = 1 self.completed_job_key = "COMPLETED_JOB" return create_soda_create_response('111-000-111-000') elif str(url).endswith('/phase') and method == 'POST': @@ -72,8 +72,8 @@ def get_mockreturn(self, method, url, data=None, timeout=10, float(pos_parts[2]), float(pos_parts[3])) return create_soda_create_response('111-000-111-000') elif str(url).endswith('111-000-111-000') and method == 'GET': - key = "RUN_JOB" if self.first_job_pass else self.completed_job_key - self.first_job_pass = False + key = "SUSPENDED_JOB" if self.job_pass_num==1 else 'RUN_JOB' if self.job_pass_num==2 else self.completed_job_key + self.job_pass_num+=1 else: raise ValueError("Unexpected SODA async {} call to url {}".format(method, url)) elif 'datalink' in str(url): From 57691109f7c38c0e1a17814479b5f465905e67aa Mon Sep 17 00:00:00 2001 From: James Dempsey Date: Wed, 20 Nov 2024 15:03:09 +1100 Subject: [PATCH 2/2] Address style issues --- CHANGES.rst | 2 +- astroquery/casda/tests/test_casda.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index c3c47e7bbf..407f73d7c7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -29,7 +29,7 @@ alma casda ^^^^^ -- Support jobs which are in the SUSPENDED state (used when copying data) [#3133] +- Support jobs which are in the SUSPENDED state (used when copying data) [#3134] ehst ^^^^ diff --git a/astroquery/casda/tests/test_casda.py b/astroquery/casda/tests/test_casda.py index 62a15d40ed..79870035cc 100644 --- a/astroquery/casda/tests/test_casda.py +++ b/astroquery/casda/tests/test_casda.py @@ -72,8 +72,9 @@ def get_mockreturn(self, method, url, data=None, timeout=10, float(pos_parts[2]), float(pos_parts[3])) return create_soda_create_response('111-000-111-000') elif str(url).endswith('111-000-111-000') and method == 'GET': - key = "SUSPENDED_JOB" if self.job_pass_num==1 else 'RUN_JOB' if self.job_pass_num==2 else self.completed_job_key - self.job_pass_num+=1 + key = "SUSPENDED_JOB" if self.job_pass_num == 1 else 'RUN_JOB' if self.job_pass_num == 2 \ + else self.completed_job_key + self.job_pass_num += 1 else: raise ValueError("Unexpected SODA async {} call to url {}".format(method, url)) elif 'datalink' in str(url):