Skip to content

Commit 8ce454a

Browse files
committed
Reconfigure locate_data to bypass execute method to create a post request instead of get.
1 parent 8a1f10a commit 8ce454a

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

astroquery/heasarc/core.py

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -518,34 +518,17 @@ def locate_data(self, query_result=None, catalog_name=None):
518518

519519
# datalink url
520520
dlink_url = f'{self.VO_URL}/datalink/{catalog_name}'
521-
def query_func(query_chunk):
522-
return pyvo.dal.adhoc.DatalinkQuery(
523-
baseurl=dlink_url,
524-
id=query_chunk['__row'],
525-
session=self._session
526-
)
521+
query = pyvo.dal.adhoc.DatalinkQuery(
522+
baseurl=dlink_url,
523+
id=query_result['__row'],
524+
session=self._session
525+
)
527526

528-
# Standard URL limit of ~2000 characters for GET
529-
# With query formula https://[urlbase]?ID=###, could get 100 16 digit IDs
530-
URI_MAX = 100
531-
if len(query_result) > URI_MAX:
532-
# execute a set amount at a time
533-
chunks = len(query_result) % URI_MAX
534-
for chunk in range(chunks):
535-
query_chunk = query_result[URI_MAX*chunk: URI_MAX*chunk+URI_MAX]
536-
query = query_func(query_chunk)
537-
dl_result_chunk = query.execute().to_table()
538-
if chunk == 0:
539-
dl_result = dl_result_chunk
540-
else:
541-
dl_result = vstack([dl_result, dl_result_chunk])
542-
query_chunk = query_result[URI_MAX*chunk+URI_MAX:]
543-
query = query_func(query_chunk)
544-
dl_result_chunk = query.execute().to_table()
545-
dl_result = vstack([dl_result, dl_result_chunk])
546-
else:
547-
query = query_func(query_result)
548-
dl_result = query.execute().to_table()
527+
dl_result = pyvo.dal.DALResults(
528+
query.execute_votable(post=True),
529+
url=query.queryurl,
530+
session=query._session
531+
).to_table()
549532

550533
# include rows that have directory links (i.e. data) and those
551534
# that report errors (usually means there are no data products)

0 commit comments

Comments
 (0)