Skip to content

Commit 6c3b03f

Browse files
snbiancobsipocz
authored andcommitted
Changelog
1 parent f58c957 commit 6c3b03f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ mast
7575

7676
- Corrected parameter checking in ``MastMissions`` to ensure case-sensitive comparisons. [#3260]
7777

78+
- Add batching to ``MastMissions.get_product_list`` to avoid server errors and allow for a larger number of input datasets. [#3230]
79+
80+
7881
simbad
7982
^^^^^^
8083

astroquery/mast/missions.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,18 @@ def get_product_list_async(self, datasets):
392392
dataset_chunks = list(utils.split_list_into_chunks(datasets, max_batch))
393393

394394
results = [] # list to store responses from each batch
395-
with ProgressBarOrSpinner(len(dataset_chunks), f'Fetching products for {num_datasets} unique datasets '
395+
with ProgressBarOrSpinner(num_datasets, f'Fetching products for {num_datasets} unique datasets '
396396
f'in {len(dataset_chunks)} batches ...') as pb:
397-
for i, chunk in enumerate(dataset_chunks):
398-
pb.update(i)
397+
datasets_fetched = 0
398+
pb.update(0)
399+
for chunk in dataset_chunks:
400+
# Send request for each chunk and add response to list
399401
params = {'dataset_ids': chunk}
400402
results.append(self._service_api_connection.missions_request_async(self.service, params))
403+
404+
# Update progress bar with the number of datasets that have had products fetched
405+
datasets_fetched += len(chunk)
406+
pb.update(datasets_fetched)
401407
return results
402408
else:
403409
# Single batch request

0 commit comments

Comments
 (0)