From 2f97dab1cd9e2876eda7a0cf1497c09c240199b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 3 Feb 2025 18:15:21 -0800 Subject: [PATCH 1/5] ENH: async_mode is added to TAP queries --- astroquery/ipac/irsa/core.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/astroquery/ipac/irsa/core.py b/astroquery/ipac/irsa/core.py index 1adf93437c..1836fe4b91 100644 --- a/astroquery/ipac/irsa/core.py +++ b/astroquery/ipac/irsa/core.py @@ -47,7 +47,7 @@ def tap(self): self._tap = TAPService(baseurl=self.tap_url, session=self._session) return self._tap - def query_tap(self, query, *, maxrec=None): + def query_tap(self, query, *, async_mode=False, maxrec=None): """ Send query to IRSA TAP. Results in `~pyvo.dal.TAPResults` format. result.to_qtable in `~astropy.table.QTable` format @@ -69,8 +69,12 @@ def query_tap(self, query, *, maxrec=None): TAP query result as `~astropy.table.QTable` """ - log.debug(f'TAP query: {query}') - return self.tap.search(query, language='ADQL', maxrec=maxrec) + log.debug(f'Query is run in async mode: {async_mode}\n TAP query: {query}') + + if async_mode: + return self.tap.run_async(query, language='ADQL', maxrec=maxrec) + else: + return self.tap.run_sync(query, language='ADQL', maxrec=maxrec) def query_sia(self, *, pos=None, band=None, time=None, pol=None, field_of_view=None, spatial_resolution=None, From cf385c7391b2a95d28b4b39a4ded40305527c558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 3 Feb 2025 18:37:00 -0800 Subject: [PATCH 2/5] DOC: adding async docs --- docs/ipac/irsa/irsa.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/ipac/irsa/irsa.rst b/docs/ipac/irsa/irsa.rst index b6b103ffc6..946c8151c9 100644 --- a/docs/ipac/irsa/irsa.rst +++ b/docs/ipac/irsa/irsa.rst @@ -183,6 +183,21 @@ star HIP 12 with just the ra, dec and w1mpro columns would be: --------- ----------- ------ 0.0407905 -35.9602605 4.837 +Async queries +-------------- + +For bigger queries it is recommended using the ``async_mode`` keyword option. When used, +the query is send in asyncronous mode. + +.. doctest-remote-data:: + + >>> from astroquery.ipac.irsa import Irsa + >>> table = Irsa.query_region("HIP 12", catalog="allwise_p3as_psd", spatial="Cone", async_mode=True) + >>> print(table) + designation ra dec sigra ... y z spt_ind htm20 + deg deg arcsec ... + ------------------- --------- ----------- ------ ... ------------------ ------------------- --------- ------------- + J000009.78-355736.9 0.0407905 -35.9602605 0.0454 ... 0.0005762523295116 -0.5872239888098030 100102010 8873706189183 Direct TAP query to the IRSA server ----------------------------------- From bc0ea97613b1234ab6be5d5a5c5aeba9c3b4039b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 3 Feb 2025 18:37:59 -0800 Subject: [PATCH 3/5] Adding async mode to query_region, too --- astroquery/ipac/irsa/core.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/astroquery/ipac/irsa/core.py b/astroquery/ipac/irsa/core.py index 1836fe4b91..e07267a091 100644 --- a/astroquery/ipac/irsa/core.py +++ b/astroquery/ipac/irsa/core.py @@ -56,7 +56,9 @@ def query_tap(self, query, *, async_mode=False, maxrec=None): ---------- query : str ADQL query to be executed - maxrec : int + async_mode : bool, optional + if True query is run as an async job + maxrec : int, optional maximum number of records to return Returns @@ -159,7 +161,7 @@ def list_collections(self, servicetype=None): @deprecated_renamed_argument(("selcols", "cache", "verbose"), ("columns", None, None), since="0.4.7") def query_region(self, coordinates=None, *, catalog=None, spatial='Cone', radius=10 * u.arcsec, width=None, polygon=None, - get_query_payload=False, columns='*', + get_query_payload=False, columns='*', async_mode=False, verbose=False, cache=True): """ Queries the IRSA TAP server around a coordinate and returns a `~astropy.table.Table` object. @@ -194,6 +196,8 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone', Defaults to `False`. columns : str, optional Target column list with value separated by a comma(,) + async_mode : bool, optional + if True query is run as an async job Returns ------- @@ -243,7 +247,7 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone', if get_query_payload: return adql - response = self.query_tap(query=adql) + response = self.query_tap(query=adql, async_mode=async_mode) return response.to_table() From b2b8346c2850031e0352443e4da5ed9a2213184e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 3 Feb 2025 18:52:07 -0800 Subject: [PATCH 4/5] rename kwarg to be consistent with existing API in the ESA modules --- astroquery/ipac/irsa/core.py | 18 +++++++++--------- docs/ipac/irsa/irsa.rst | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/astroquery/ipac/irsa/core.py b/astroquery/ipac/irsa/core.py index e07267a091..28523ba222 100644 --- a/astroquery/ipac/irsa/core.py +++ b/astroquery/ipac/irsa/core.py @@ -47,7 +47,7 @@ def tap(self): self._tap = TAPService(baseurl=self.tap_url, session=self._session) return self._tap - def query_tap(self, query, *, async_mode=False, maxrec=None): + def query_tap(self, query, *, async_job=False, maxrec=None): """ Send query to IRSA TAP. Results in `~pyvo.dal.TAPResults` format. result.to_qtable in `~astropy.table.QTable` format @@ -56,8 +56,8 @@ def query_tap(self, query, *, async_mode=False, maxrec=None): ---------- query : str ADQL query to be executed - async_mode : bool, optional - if True query is run as an async job + async_job : bool, optional + if True query is run in asynchronous mode maxrec : int, optional maximum number of records to return @@ -71,9 +71,9 @@ def query_tap(self, query, *, async_mode=False, maxrec=None): TAP query result as `~astropy.table.QTable` """ - log.debug(f'Query is run in async mode: {async_mode}\n TAP query: {query}') + log.debug(f'Query is run in async mode: {async_job}\n TAP query: {query}') - if async_mode: + if async_job: return self.tap.run_async(query, language='ADQL', maxrec=maxrec) else: return self.tap.run_sync(query, language='ADQL', maxrec=maxrec) @@ -161,7 +161,7 @@ def list_collections(self, servicetype=None): @deprecated_renamed_argument(("selcols", "cache", "verbose"), ("columns", None, None), since="0.4.7") def query_region(self, coordinates=None, *, catalog=None, spatial='Cone', radius=10 * u.arcsec, width=None, polygon=None, - get_query_payload=False, columns='*', async_mode=False, + get_query_payload=False, columns='*', async_job=False, verbose=False, cache=True): """ Queries the IRSA TAP server around a coordinate and returns a `~astropy.table.Table` object. @@ -196,8 +196,8 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone', Defaults to `False`. columns : str, optional Target column list with value separated by a comma(,) - async_mode : bool, optional - if True query is run as an async job + async_job : bool, optional + if True query is run in asynchronous mode Returns ------- @@ -247,7 +247,7 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone', if get_query_payload: return adql - response = self.query_tap(query=adql, async_mode=async_mode) + response = self.query_tap(query=adql, async_job=async_job) return response.to_table() diff --git a/docs/ipac/irsa/irsa.rst b/docs/ipac/irsa/irsa.rst index 946c8151c9..61c2a74145 100644 --- a/docs/ipac/irsa/irsa.rst +++ b/docs/ipac/irsa/irsa.rst @@ -186,13 +186,13 @@ star HIP 12 with just the ra, dec and w1mpro columns would be: Async queries -------------- -For bigger queries it is recommended using the ``async_mode`` keyword option. When used, -the query is send in asyncronous mode. +For bigger queries it is recommended using the ``async_job`` keyword option. When used, +the query is send in asynchronous mode. .. doctest-remote-data:: >>> from astroquery.ipac.irsa import Irsa - >>> table = Irsa.query_region("HIP 12", catalog="allwise_p3as_psd", spatial="Cone", async_mode=True) + >>> table = Irsa.query_region("HIP 12", catalog="allwise_p3as_psd", spatial="Cone", async_job=True) >>> print(table) designation ra dec sigra ... y z spt_ind htm20 deg deg arcsec ... From 29ba7725a7229fe68d06d6c97712a311dd964814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 3 Feb 2025 18:55:50 -0800 Subject: [PATCH 5/5] DOC: adding changelog --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 73bdabdaf2..fa180f8f02 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -27,6 +27,9 @@ ipac.irsa - Adding the "servicetype" kwarg to ``list_collections`` to be able to list SIA and SSA collections separately. [#3200] +- Adding support for asynchronous queries using the new ``async_job`` + keyword. [#3201] + ipac.nexsci.nasa_exoplanet_archive ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^