24
24
25
25
import astropy .table
26
26
import astropy .utils .data
27
- import astropy .units as u
28
27
import keyring
29
28
import requests .exceptions
30
29
from astropy .table import Table , Column
31
30
from astropy .utils .decorators import deprecated_renamed_argument
32
31
from bs4 import BeautifulSoup
33
32
import pyvo
34
33
35
- from astroquery import log , cache_conf
34
+ from astroquery import log
36
35
from . import conf
37
36
from ..exceptions import RemoteServiceError , LoginError , \
38
37
NoResultsWarning , MaxResultsWarning
39
38
from ..query import QueryWithLogin
40
39
from ..utils import schema
41
40
from .utils import py2adql , _split_str_as_list_of_str , \
42
- adql_sanitize_val , to_cache , eso_hash , are_coords_valid , \
43
- read_table_from_file , is_file_expired
41
+ adql_sanitize_val , are_coords_valid
44
42
45
43
__doctest_skip__ = ['EsoClass.*' ]
46
44
@@ -87,25 +85,13 @@ class EsoClass(QueryWithLogin):
87
85
AUTH_URL = "https://www.eso.org/sso/oidc/token"
88
86
GUNZIP = "gunzip"
89
87
90
- def __init__ (self , timeout = None ):
88
+ def __init__ (self ):
91
89
super ().__init__ ()
92
90
self ._instruments : Optional [List [str ]] = None
93
91
self ._collections : Optional [List [str ]] = None
94
92
self ._auth_info : Optional [AuthInfo ] = None
95
- self .timeout = timeout # TODO: Is this timeout for login?
96
93
self ._hash = None
97
- self .USE_DEV_TAP = False
98
-
99
- @property
100
- def timeout (self ):
101
- return self ._timeout
102
-
103
- @timeout .setter
104
- def timeout (self , value ):
105
- if hasattr (value , 'to' ):
106
- self ._timeout = value .to (u .s ).value
107
- else :
108
- self ._timeout = value
94
+ self .USE_DEV_TAP = True
109
95
110
96
def tap_url (self ) -> str :
111
97
url = conf .tap_url
@@ -120,37 +106,6 @@ def tap_url(self) -> str:
120
106
log .info (logmsg )
121
107
return url
122
108
123
- def request_file (self , query_str : str ):
124
- h = eso_hash (query_str = query_str , url = self .tap_url ())
125
- fn = self .cache_location .joinpath (h + ".pickle" )
126
- return fn
127
-
128
- def from_cache (self , query_str , cache_timeout ):
129
- table_file = self .request_file (query_str )
130
- expired = is_file_expired (table_file , cache_timeout )
131
- cached_table = None
132
- if not expired :
133
- cached_table = self .read_cached_table (table_file )
134
- else :
135
- logmsg = (f"Cache expired for { table_file } ..." )
136
- log .debug (logmsg )
137
- return cached_table
138
-
139
- def read_cached_table (self , table_file ):
140
- try :
141
- cached_table = read_table_from_file (table_file )
142
- except FileNotFoundError :
143
- cached_table = None
144
-
145
- if not isinstance (cached_table , Table ):
146
- cached_table = None
147
-
148
- if cached_table :
149
- logmsg = (f"Retrieved data from { table_file } ..." )
150
- log .debug (logmsg )
151
-
152
- return cached_table
153
-
154
109
def _authenticate (self , * , username : str , password : str ) -> bool :
155
110
"""
156
111
Get the access token from ESO SSO provider
@@ -237,7 +192,7 @@ def _get_auth_header(self) -> Dict[str, str]:
237
192
238
193
def query_tap_service (self ,
239
194
query_str : str ,
240
- cache : Optional [ bool ] = None ) -> Optional [astropy .table .Table ]:
195
+ ) -> Optional [astropy .table .Table ]:
241
196
"""
242
197
returns an astropy.table.Table from an adql query string
243
198
Example use:
@@ -248,22 +203,12 @@ def query_tap_service(self,
248
203
if self .ROW_LIMIT > 0 :
249
204
maxrec = self .ROW_LIMIT
250
205
251
- if cache is None : # Global caching not overridden
252
- cache = cache_conf .cache_active
253
-
254
206
tap = pyvo .dal .TAPService (self .tap_url ())
255
207
table_to_return = None
256
208
logmsg = f"querystr = { query_str } "
257
209
log .debug (logmsg )
258
210
try :
259
- if not cache :
260
- with cache_conf .set_temp ("cache_active" , False ):
261
- table_to_return = tap .search (query_str , maxrec = maxrec ).to_table ()
262
- else :
263
- table_to_return = self .from_cache (query_str , cache_conf .cache_timeout )
264
- if not table_to_return :
265
- table_to_return = tap .search (query_str , maxrec = maxrec ).to_table ()
266
- to_cache (table_to_return , self .request_file (query_str = query_str ))
211
+ table_to_return = tap .search (query_str , maxrec = maxrec ).to_table ()
267
212
268
213
except pyvo .dal .exceptions .DALQueryError as e :
269
214
raise pyvo .dal .exceptions .DALQueryError (
@@ -287,16 +232,12 @@ def query_tap_service(self,
287
232
288
233
return table_to_return
289
234
290
- def list_instruments (self , * , cache = True ) -> List [str ]:
235
+ def list_instruments (self ) -> List [str ]:
291
236
""" List all the available instrument-specific queries offered by the ESO archive.
292
237
293
238
Returns
294
239
-------
295
240
instrument_list : list of strings
296
- cache : bool
297
- Defaults to True. If set overrides global caching behavior.
298
- See :ref:`caching documentation <astroquery_cache>`.
299
-
300
241
"""
301
242
tmpvar = self .ROW_LIMIT
302
243
self .ROW_LIMIT = sys .maxsize
@@ -305,13 +246,13 @@ def list_instruments(self, *, cache=True) -> List[str]:
305
246
self ._instruments = []
306
247
query_str = ("select table_name from TAP_SCHEMA.tables "
307
248
"where schema_name='ist' order by table_name" )
308
- res = self .query_tap_service (query_str , cache = cache )["table_name" ].data
249
+ res = self .query_tap_service (query_str )["table_name" ].data
309
250
self ._instruments = list (map (lambda x : x .split ("." )[1 ], res ))
310
251
finally :
311
252
self .ROW_LIMIT = tmpvar
312
253
return self ._instruments
313
254
314
- def list_collections (self , * , cache = True ) -> List [str ]:
255
+ def list_collections (self ) -> List [str ]:
315
256
""" List all the available collections (phase 3) in the ESO archive.
316
257
317
258
Returns
@@ -329,7 +270,7 @@ def list_collections(self, *, cache=True) -> List[str]:
329
270
t = EsoNames .phase3_table
330
271
c = EsoNames .phase3_collections_column
331
272
query_str = f"select distinct { c } from { t } "
332
- res = self .query_tap_service (query_str , cache = cache )[c ].data
273
+ res = self .query_tap_service (query_str )[c ].data
333
274
334
275
self ._collections = list (res )
335
276
finally :
@@ -361,7 +302,6 @@ def _query_on_allowed_values(
361
302
top : int = None ,
362
303
count_only : bool = False ,
363
304
print_help : bool = False ,
364
- cache : bool = True ,
365
305
** kwargs ) -> Union [astropy .table .Table , int ]:
366
306
"""
367
307
Query instrument- or collection-specific data contained in the ESO archive.
@@ -402,7 +342,7 @@ def _query_on_allowed_values(
402
342
count_only = count_only ,
403
343
top = top )
404
344
405
- table_to_return = self .query_tap_service (query_str = query , cache = cache )
345
+ table_to_return = self .query_tap_service (query_str = query )
406
346
407
347
if count_only : # this below is an int, not a table
408
348
table_to_return = list (table_to_return [0 ].values ())[0 ]
@@ -416,7 +356,7 @@ def query_collections(
416
356
columns : Union [List , str ] = None ,
417
357
top : int = None ,
418
358
count_only : bool = False ,
419
- print_help = False , cache = True ,
359
+ print_help = False ,
420
360
** kwargs ) -> Union [astropy .table .Table , int ]:
421
361
return self ._query_on_allowed_values (table_name = EsoNames .phase3_table ,
422
362
column_name = EsoNames .phase3_collections_column ,
@@ -425,7 +365,7 @@ def query_collections(
425
365
columns = columns ,
426
366
top = top ,
427
367
count_only = count_only ,
428
- print_help = print_help , cache = cache ,
368
+ print_help = print_help ,
429
369
** kwargs )
430
370
431
371
def query_main (
@@ -435,7 +375,7 @@ def query_main(
435
375
columns : Union [List , str ] = None ,
436
376
top : int = None ,
437
377
count_only : bool = False ,
438
- print_help = False , cache = True ,
378
+ print_help = False ,
439
379
** kwargs ) -> Union [astropy .table .Table , int ]:
440
380
return self ._query_on_allowed_values (table_name = EsoNames .raw_table ,
441
381
column_name = EsoNames .raw_instruments_column ,
@@ -444,7 +384,7 @@ def query_main(
444
384
columns = columns ,
445
385
top = top ,
446
386
count_only = count_only ,
447
- print_help = print_help , cache = cache ,
387
+ print_help = print_help ,
448
388
** kwargs )
449
389
450
390
# ex query_instrument
@@ -455,7 +395,7 @@ def query_instrument(
455
395
columns : Union [List , str ] = None ,
456
396
top : int = None ,
457
397
count_only : bool = False ,
458
- print_help = False , cache = True ,
398
+ print_help = False ,
459
399
** kwargs ) -> Union [astropy .table .Table , int ]:
460
400
return self ._query_on_allowed_values (table_name = EsoNames .ist_table (instrument ),
461
401
column_name = None ,
@@ -464,7 +404,7 @@ def query_instrument(
464
404
columns = columns ,
465
405
top = top ,
466
406
count_only = count_only ,
467
- print_help = print_help , cache = cache ,
407
+ print_help = print_help ,
468
408
** kwargs )
469
409
470
410
def get_headers (self , product_ids , * , cache = True ):
@@ -790,7 +730,7 @@ def retrieve_data(self, datasets, *, continuation=False, destination=None,
790
730
@deprecated_renamed_argument (('open_form' , 'help' ), (None , 'print_help' ),
791
731
since = ['0.4.8' , '0.4.8' ])
792
732
def query_apex_quicklooks (self , * , project_id = None , print_help = False ,
793
- open_form = False , cache = True , ** kwargs ):
733
+ open_form = False , ** kwargs ):
794
734
"""
795
735
APEX data are distributed with quicklook products identified with a
796
736
different name than other ESO products. This query tool searches by
@@ -803,11 +743,7 @@ def query_apex_quicklooks(self, *, project_id=None, print_help=False,
803
743
"""
804
744
# TODO All this function
805
745
_ = project_id , print_help , open_form , kwargs
806
- if cache :
807
- query = "APEX_QUERY_PLACEHOLDER"
808
- return self .query_tap_service (query_str = query , cache = cache )
809
- else :
810
- raise NotImplementedError
746
+ raise NotImplementedError
811
747
812
748
813
749
Eso = EsoClass ()
0 commit comments