Skip to content

Commit 7587e03

Browse files
rickynilssonbsipocz
authored andcommitted
Move get_tap_tables() to class.
1 parent 966df0a commit 7587e03

File tree

1 file changed

+10
-2
lines changed
  • astroquery/nasa_exoplanet_archive

1 file changed

+10
-2
lines changed

astroquery/nasa_exoplanet_archive/core.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,17 @@ class NasaExoplanetArchiveClass(BaseQuery):
134134
@property
135135
def TAP_TABLES(self):
136136
if not hasattr(self, '_tap_tables'):
137-
self._tap_tables = get_tap_tables(conf.url_tap)
137+
self._tap_tables = self.get_tap_tables(conf.url_tap)
138138
return self._tap_tables
139139

140+
@class_or_instance
141+
def get_tap_tables(self, url):
142+
"""Tables accessed by API are gradually migrating to TAP service. Generate current list of tables in TAP."""
143+
tap = pyvo.dal.tap.TAPService(baseurl=url)
144+
response = tap.search(query="select * from TAP_SCHEMA.tables", language="ADQL")
145+
tables = [table for table in response["table_name"].data if "TAP_SCHEMA." not in table]
146+
return tables
147+
140148
# Ensures methods can be called either as class methods or instance methods. This is the basic query method.
141149
@class_or_instance
142150
def query_criteria_async(self, table, get_query_payload=False, cache=None, **criteria):
@@ -180,7 +188,7 @@ def query_criteria_async(self, table, get_query_payload=False, cache=None, **cri
180188
# Warn if old table is requested
181189
if table in MAP_TABLEWARNINGS.keys():
182190
# warnings.warn("The '{0}' table is stale and will be depracated in the Archive 2.0 release. Use the 'ps' table. See https://exoplanetarchive.ipac.caltech.edu/docs/ps-pscp_release_notes.html".format(table), InputWarning, )
183-
raise InvalidTableError("The ``{0}`` table is no longer updated and has been replaced by the {1}, which is connected to the Exoplanet Archive TAP service. Although the argument keywords of the called method should still work on the new table, the allowed values could have changed since the database column names have changed; this document contains the current definitions and a mapping between the new and deprecated names: https://exoplanetarchive.ipac.caltech.edu/docs/API_PS_columns.html. You might also want to review the TAP User Guide for help on creating a new query for the most current data: https://exoplanetarchive.ipac.caltech.edu/docs/TAP/usingTAP.html.".format(table, MAP_TABLEWARNINGS[table]))
191+
raise InvalidTableError("The ``{0}`` table is no longer updated and has been replaced by the {1} table, which is connected to the Exoplanet Archive TAP service. Although the argument keywords of the called method should still work on the new table, the allowed values could have changed since the database column names have changed; this document contains the current definitions and a mapping between the new and deprecated names: https://exoplanetarchive.ipac.caltech.edu/docs/API_PS_columns.html. You might also want to review the TAP User Guide for help on creating a new query for the most current data: https://exoplanetarchive.ipac.caltech.edu/docs/TAP/usingTAP.html.".format(table, MAP_TABLEWARNINGS[table]))
184192

185193
# Deal with lists of columns instead of comma separated strings
186194
criteria = copy.copy(criteria)

0 commit comments

Comments
 (0)