Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASDA - Add support for SUSPENDED jobs #3134

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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) [#3134]

ehst
^^^^

Expand Down
2 changes: 1 addition & 1 deletion astroquery/casda/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
22 changes: 22 additions & 0 deletions astroquery/casda/tests/data/suspended_job.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<uws:job xmlns:uws="http://www.ivoa.net/xml/UWS/v1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<uws:jobId>
<![CDATA[a7b53da7-1201-46ee-8718-0bf5b64dd5b8]]>
</uws:jobId>
<uws:runId xsi:nil="true" />
<uws:ownerId xsi:nil="true" />
<uws:phase>SUSPENDED</uws:phase>
<uws:quote xsi:nil="true" />
<uws:startTime>2024-04-17T08:10:22.793+0800</uws:startTime>
<uws:endTime xsi:nil="true" />
<uws:executionDuration>0</uws:executionDuration>
<uws:destruction xsi:nil="true" />
<uws:parameters>
<uws:parameter id="id">
<![CDATA[ABCDEF]]>
</uws:parameter>
</uws:parameters>
<uws:results>
</uws:results>
<uws:errorSummary xsi:nil="true" />
</uws:job>
9 changes: 5 additions & 4 deletions astroquery/casda/tests/test_casda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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':
Expand All @@ -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 = "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):
Expand Down
Loading