Behavior of Observations.download_products() when given an empty table
- Dominant language
- Python
- Stars
- 791
- Forks
- 451
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 4
Description
I have distilled a situation we have tripped on in our code provided as an example below. Because it is a "distilled" situation, it looks like a silly example, but it gets the point across.
Bug or Feature?
=====
PREVIOUS SITUATION which worked in our code - no fuss and no muss.
astroquery 0.4.6
```
bash-4.2$ python
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:18)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from astroquery.mast import Observations
>>> from astropy.table import Table
>>> t = Table()
>>> manifest = Observations.download_products(t, mrp_only=False)
WARNING: NoResultsWarning: No products to download. [astroquery.mast.observations]
>>>
```
=====
NEW SITUATION which throws an exception.
astroquery 0.4.7.dev8438 dev_0
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50)
```
bash-4.2$ python
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from astroquery.mast import Observations
>>> from astropy.table import Table
>>> t = Table()
>>> manifest = Observations.download_products(t, mrp_only=False)
Traceback (most recent call last):
File "", line 1, in
File "/home/mdelapena/repository/astroquery/astroquery/mast/observations.py", line 725, in download_products
products = self._remove_duplicate_products(products)
File "/home/mdelapena/repository/astroquery/astroquery/mast/observations.py", line 842, in _remove_duplicate_products
unique_products = unique(data_products, keys="dataURI")
File "/home/mdelapena/miniconda3/envs/caldp_20221010/lib/python3.9/site-packages/astropy/table/operations.py", line 841, in unique
col = input_table[key]
File "/home/mdelapena/miniconda3/envs/caldp_20221010/lib/python3.9/site-packages/astropy/table/table.py", line 1872, in __getitem__
return self.columns[item]
File "/home/mdelapena/miniconda3/envs/caldp_20221010/lib/python3.9/site-packages/astropy/table/table.py", line 246, in __getitem__
return OrderedDict.__getitem__(self, item)
KeyError: 'dataURI'
>>>
```
Contributor guide
Research direction
Start in astroquery/mast/observations.py at download_products() and _remove_duplicate_products(), then reproduce the empty astropy Table case shown in the report. Compare the current behavior with astroquery 0.4.6; done means an empty table is handled without a KeyError and follows the reported no-products behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100