Skip to content

Commit 27967f7

Browse files
committed
Changelog, raise error if no dataset kwd found in MastMissions, coverage
1 parent 1cc43e8 commit 27967f7

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ mast
3030

3131
- Switch to use HTTP continuation for partial downloads. [#3448]
3232

33+
- Add ``batch_size`` parameter to ``MastMissions.get_product_list``, ``Observations.get_product_list``,
34+
and ``utils.resolve_object`` to allow controlling the number of items sent in each batch request to the server.
35+
This can help avoid timeouts or connection errors for large requests. [#3454]
36+
3337

3438
Infrastructure, Utility and Other Changes and Additions
3539
-------------------------------------------------------

astroquery/mast/missions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ def get_product_list_async(self, datasets, batch_size=1000):
409409
if isinstance(datasets, Table) or isinstance(datasets, Row):
410410
dataset_kwd = self.get_dataset_kwd()
411411
if not dataset_kwd:
412-
log.warning(f'Dataset keyword not found for mission {self.mission}. '
413-
'Please input dataset IDs as a string, list of strings, or `~astropy.table.Column`.')
414-
return None
412+
error_msg = (f'Dataset keyword not found for mission "{self.mission}". '
413+
'Please input dataset IDs as a string, list of strings, or `~astropy.table.Column`.')
414+
raise InvalidQueryError(error_msg)
415415

416416
# Extract dataset IDs based on input type and mission
417417
if isinstance(datasets, Table):

astroquery/mast/observations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ def get_product_list_async(self, observations, batch_size=500):
537537
observations = observations['obsid'].tolist()
538538

539539
# Clean and validate
540-
observations = [str(obs).strip() for obs in observations if str(obs).strip()]
540+
observations = [str(obs).strip() for obs in observations]
541+
observations = [obs for obs in observations if obs]
541542
if not observations:
542543
raise InvalidQueryError('Observation list is empty, no associated products.')
543544

astroquery/mast/tests/test_mast.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ def test_missions_get_product_list_async(patch_post):
330330
mast.MastMissions.get_product_list_async([' '])
331331
assert 'Dataset list is empty' in str(err_empty.value)
332332

333+
# No dataset keyword
334+
with pytest.raises(InvalidQueryError, match='Dataset keyword not found for mission "invalid"'):
335+
missions = mast.MastMissions(mission='invalid')
336+
missions.get_product_list_async(Table({'a': [1, 2, 3]}))
337+
333338

334339
def test_missions_get_product_list(patch_post):
335340
# String input

0 commit comments

Comments
 (0)