Skip to content

Commit e2f648d

Browse files
authored
Merge pull request #3134 from jd-au/3133-casda-jobs-suspended
CASDA - Add support for SUSPENDED jobs
2 parents 3a207b2 + 5769110 commit e2f648d

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ alma
2626

2727
- Changed the way galactic ranges are used in queries [#3105]
2828

29+
casda
30+
^^^^^
31+
32+
- Support jobs which are in the SUSPENDED state (used when copying data) [#3134]
33+
2934
ehst
3035
^^^^
3136

astroquery/casda/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def _run_job(self, job_location, verbose, *, poll_interval=20):
516516
count = 0
517517
job_details = self._get_job_details_xml(job_location)
518518
status = self._read_job_status(job_details, verbose)
519-
while status == 'EXECUTING' or status == 'QUEUED' or status == 'PENDING':
519+
while status == 'EXECUTING' or status == 'QUEUED' or status == 'PENDING' or status == 'SUSPENDED':
520520
count += 1
521521
if verbose and (status != prev_status or count > 10):
522522
log.info("Job is %s, polling every %d seconds." % (status, poll_interval))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<uws:jobId>
4+
<![CDATA[a7b53da7-1201-46ee-8718-0bf5b64dd5b8]]>
5+
</uws:jobId>
6+
<uws:runId xsi:nil="true" />
7+
<uws:ownerId xsi:nil="true" />
8+
<uws:phase>SUSPENDED</uws:phase>
9+
<uws:quote xsi:nil="true" />
10+
<uws:startTime>2024-04-17T08:10:22.793+0800</uws:startTime>
11+
<uws:endTime xsi:nil="true" />
12+
<uws:executionDuration>0</uws:executionDuration>
13+
<uws:destruction xsi:nil="true" />
14+
<uws:parameters>
15+
<uws:parameter id="id">
16+
<![CDATA[ABCDEF]]>
17+
</uws:parameter>
18+
</uws:parameters>
19+
<uws:results>
20+
</uws:results>
21+
<uws:errorSummary xsi:nil="true" />
22+
</uws:job>

astroquery/casda/tests/test_casda.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
DATA_FILES = {'CIRCLE': 'cone.xml', 'RANGE': 'box.xml', 'DATALINK': 'datalink.xml', 'RUN_JOB': 'run_job.xml',
3030
'COMPLETED_JOB': 'completed_job.xml', 'DATALINK_NOACCESS': 'datalink_noaccess.xml',
3131
'cutout_CIRCLE_333.9092_-45.8418_0.5000': 'cutout_333.9092_-45.8418_0.5000.xml',
32-
'AVAILABILITY': 'availability.xml'}
32+
'AVAILABILITY': 'availability.xml', 'SUSPENDED_JOB': 'suspended_job.xml'}
3333

3434
USERNAME = 'user'
3535
PASSWORD = 'password'
@@ -58,7 +58,7 @@ def get_mockreturn(self, method, url, data=None, timeout=10,
5858
if 'data/async' in str(url):
5959
# Responses for an asynchronous SODA job
6060
if str(url).endswith('data/async'):
61-
self.first_job_pass = True
61+
self.job_pass_num = 1
6262
self.completed_job_key = "COMPLETED_JOB"
6363
return create_soda_create_response('111-000-111-000')
6464
elif str(url).endswith('/phase') and method == 'POST':
@@ -72,8 +72,9 @@ def get_mockreturn(self, method, url, data=None, timeout=10,
7272
float(pos_parts[2]), float(pos_parts[3]))
7373
return create_soda_create_response('111-000-111-000')
7474
elif str(url).endswith('111-000-111-000') and method == 'GET':
75-
key = "RUN_JOB" if self.first_job_pass else self.completed_job_key
76-
self.first_job_pass = False
75+
key = "SUSPENDED_JOB" if self.job_pass_num == 1 else 'RUN_JOB' if self.job_pass_num == 2 \
76+
else self.completed_job_key
77+
self.job_pass_num += 1
7778
else:
7879
raise ValueError("Unexpected SODA async {} call to url {}".format(method, url))
7980
elif 'datalink' in str(url):

0 commit comments

Comments
 (0)