Skip to content

Commit 4c87d7f

Browse files
authored
Merge pull request #2490 from keflavich/alma_downloader_Aug11_2022
BUG: Fix for broken alma downloader
2 parents 85b3937 + 0828aa2 commit 4c87d7f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ alma
3131
- Fixed a regression to handle arrays of string input for the ``query`` methods. [#2094]
3232
- Throws an error when an unsupported ``kwargs`` (or argument) is passed in to a function. [#2475]
3333
- New DataLink API handling. [#2493]
34+
- Fixed bug #2489 in which blank URLs were being sent to the downloader [#2490]
3435

3536

3637
astrometry.net

astroquery/alma/core.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,15 @@ def retrieve_data_from_uid(self, uids, *, cache=True):
828828
raise TypeError("Datasets must be given as a list of strings.")
829829

830830
files = self.get_data_info(uids)
831-
file_urls = files['access_url']
831+
# filter out blank access URLs
832+
# it is possible for there to be length-1 lists
833+
if len(files) == 1:
834+
file_urls = files['access_url']
835+
if isinstance(file_urls, str) and file_urls == '':
836+
raise ValueError(f"Cannot download uid {uid} because it has no file")
837+
else:
838+
file_urls = [url for url in files['access_url'] if url]
839+
832840
totalsize = files['content_length'].sum()*u.B
833841

834842
# each_size, totalsize = self.data_size(files)

astroquery/alma/tests/test_alma_remote.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,18 @@ def test_data_proprietary(self, alma):
149149
with pytest.raises(AttributeError):
150150
alma.is_proprietary('uid://NON/EXI/STING')
151151

152-
@pytest.mark.xfail(reason="Depends on PR 2438 (https://github.com/astropy/astroquery/pull/2438)")
152+
def test_retrieve_data(self, temp_path, alma):
153+
"""
154+
Regression test for issue 2490 (the retrieval step will simply fail if
155+
given a blank line, so all we're doing is testing that it runs)
156+
"""
157+
alma.cache_location = temp_path
158+
159+
# small solar TP-only data set (<1 GB)
160+
uid = 'uid://A001/X87c/X572'
161+
162+
alma.retrieve_data_from_uid([uid])
163+
153164
def test_data_info(self, temp_dir, alma):
154165
alma.cache_location = temp_dir
155166

0 commit comments

Comments
 (0)