37
37
from sqlalchemy import String , Float , Integer , or_ , func
38
38
39
39
#from .pgvalues import values
40
- from .model import Path , Checksum
40
+ from .model import Path , Checksum , C6Dataset , C5Dataset , CordexDataset
41
41
from .exception import ClefException
42
42
43
43
@@ -167,11 +167,8 @@ def find_checksum_id(query, **kwargs):
167
167
raise ESGFException ('No matches found on ESGF, check at %s' % link_to_esgf (query , ** constraints ))
168
168
169
169
if response ['response' ]['numFound' ] > int (response ['responseHeader' ]['params' ]['rows' ]):
170
- print (f"Too many files ({ response ['response' ]['numFound' ]} ), try limiting your search.\n " )
171
- print ("Returning only dataset results, hence a full comparison with local collection is not possible" )
172
- response = esgf_query (query , 'id,dataset_id,title,version' , otype = 'Dataset' , ** constraints )
173
- #raise ESGFException('Too many results (%d), try limiting your search %s'%(response['response']['numFound'],
174
- # link_to_esgf(query, **constraints)))
170
+ raise ESGFException ('Too many results (%d), try limiting your search %s' % (response ['response' ]['numFound' ],
171
+ link_to_esgf (query , ** constraints )))
175
172
# separate records that do not have checksum in response (nosums list) from others (records list)
176
173
# we should call local_search for these i.e. a search not based on checksums but is not yet implemented
177
174
nosums = []
@@ -189,8 +186,7 @@ def find_checksum_id(query, **kwargs):
189
186
records .append (doc )
190
187
else :
191
188
nosums .append (doc )
192
- print (doc )
193
-
189
+
194
190
record_list = [
195
191
(doc ['checksum' ][0 ],
196
192
doc ['id' ].split ('|' )[0 ], # drop the server name
@@ -202,7 +198,7 @@ def find_checksum_id(query, **kwargs):
202
198
nosums_list = [
203
199
('NA' ,
204
200
doc ['id' ].split ('|' )[0 ], # drop the server name
205
- doc ['dataset_id ' ].split ('|' )[0 ], # Drop the server name
201
+ doc ['id ' ].split ('|' )[0 ], # Drop the server name
206
202
doc ['title' ],
207
203
doc ['version' ],
208
204
doc ['score' ])
@@ -221,7 +217,7 @@ def find_checksum_id(query, **kwargs):
221
217
table = sqlalvalues (
222
218
column ('checksum' , String ),
223
219
column ('id' , String ),
224
- # column('dataset_id', String),
220
+ column ('dataset_id' , String ),
225
221
column ('title' , String ),
226
222
column ('version' , Integer ),
227
223
column ('score' , Float ),
@@ -259,13 +255,11 @@ def match_query(session, query, latest=None, **kwargs):
259
255
.outerjoin (Path ))
260
256
else :
261
257
# Match on file name
262
- #return values.outerjoin(Path, Path.path.like('%/'+values.c.title))
263
- #return values.outerjoin(Path, func.regexp_replace(Path.path, '^.*/', '') == values.c.title)
264
258
matches = checksum_table .join (Path , func .regexp_replace (Path .path , '^.*/' , '' ) == checksum_table .c .title )
265
259
266
260
if nocksum is True :
267
- if project == 'CMIP6' :
268
- matches = ( checksum_table . join ( C6Dataset , C6 . Dataset . dataset_id == checksum_table . c . dataset_id ))
261
+ raise ESGFException ( f'Some datasets have incomplete records try --local option' )
262
+
269
263
return matches
270
264
271
265
0 commit comments