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

Ensure AsyncTAPJob.result strictly follows TAP spec result ID requirement #644

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Enhancements and Fixes

- Make deletion of TAP jobs optional via a new ``delete`` kwarg. [#640]

- Change AsyncTAPJob.result to return None if no result is found explicitly [#644]


Deprecations and Removals
-------------------------

Expand Down
15 changes: 12 additions & 3 deletions pyvo/dal/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,14 +861,14 @@
@property
def result(self):
"""
The job result if exists
Returns the UWS result with id='result' if it exists, otherwise None.
"""
try:
for r in self._job.results:
if r.id_ == 'result':
return r

return self._job.results[0]
return None

Check warning on line 871 in pyvo/dal/tap.py

View check run for this annotation

Codecov / codecov/patch

pyvo/dal/tap.py#L871

Added line #L871 was not covered by tests
except IndexError:
return None

Expand All @@ -885,7 +885,10 @@
the uri of the result
"""
try:
uri = self.result.href
result = self.result
if result is None:
return None

Check warning on line 890 in pyvo/dal/tap.py

View check run for this annotation

Codecov / codecov/patch

pyvo/dal/tap.py#L890

Added line #L890 was not covered by tests
uri = result.href
if not urlparse(uri).netloc:
uri = urljoin(self.url, uri)
return uri
Expand Down Expand Up @@ -1007,6 +1010,12 @@
"""
returns the result votable if query is finished
"""
result_uri = self.result_uri
if result_uri is None:
self._update()
self.raise_if_error()
raise DALServiceError("No result URI available", self.url)

Check warning on line 1017 in pyvo/dal/tap.py

View check run for this annotation

Codecov / codecov/patch

pyvo/dal/tap.py#L1015-L1017

Added lines #L1015 - L1017 were not covered by tests

try:
response = self._session.get(self.result_uri, stream=True)
response.raise_for_status()
Expand Down
Loading