3737from sqlalchemy import String , Float , Integer , or_ , func
3838
3939#from .pgvalues import values
40- from .model import Path , Checksum
40+ from .model import Path , Checksum , C6Dataset , C5Dataset , CordexDataset
4141from .exception import ClefException
4242
4343
@@ -167,11 +167,8 @@ def find_checksum_id(query, **kwargs):
167167 raise ESGFException ('No matches found on ESGF, check at %s' % link_to_esgf (query , ** constraints ))
168168
169169 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 )))
175172 # separate records that do not have checksum in response (nosums list) from others (records list)
176173 # we should call local_search for these i.e. a search not based on checksums but is not yet implemented
177174 nosums = []
@@ -189,8 +186,7 @@ def find_checksum_id(query, **kwargs):
189186 records .append (doc )
190187 else :
191188 nosums .append (doc )
192- print (doc )
193-
189+
194190 record_list = [
195191 (doc ['checksum' ][0 ],
196192 doc ['id' ].split ('|' )[0 ], # drop the server name
@@ -202,7 +198,7 @@ def find_checksum_id(query, **kwargs):
202198 nosums_list = [
203199 ('NA' ,
204200 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
206202 doc ['title' ],
207203 doc ['version' ],
208204 doc ['score' ])
@@ -221,7 +217,7 @@ def find_checksum_id(query, **kwargs):
221217 table = sqlalvalues (
222218 column ('checksum' , String ),
223219 column ('id' , String ),
224- # column('dataset_id', String),
220+ column ('dataset_id' , String ),
225221 column ('title' , String ),
226222 column ('version' , Integer ),
227223 column ('score' , Float ),
@@ -259,13 +255,11 @@ def match_query(session, query, latest=None, **kwargs):
259255 .outerjoin (Path ))
260256 else :
261257 # 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)
264258 matches = checksum_table .join (Path , func .regexp_replace (Path .path , '^.*/' , '' ) == checksum_table .c .title )
265259
266260 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+
269263 return matches
270264
271265
0 commit comments