Skip to content

Commit cc7b632

Browse files
authored
Merge pull request #167 from coecms/docsaug23
Docsaug23
2 parents efb804c + c7c764e commit cc7b632

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

Makefile

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ENV=module load conda;
1+
ENV=module load conda/analysis3-23.04;
22
SHELL=/bin/bash
33

44
.PHONY: check test package

clef/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def common_esgf_cli(ctx, project, query, latest, replica, distrib,
371371
print(f"{row.Index[0]} / {row.Index[1]} versions: {', '.join([v[0] for v in row.version])}")
372372
ids = get_ids(results)
373373
else:
374-
q = find_checksum_id(' '.join(query),
374+
q, nocksum = find_checksum_id(' '.join(query),
375375
distrib=distrib,
376376
replica=replica,
377377
latest=latest,

clef/esgf.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ESGFException(ClefException):
4747
pass
4848

4949

50-
def esgf_query(query=None, fields=[], otype='File', limit=20000, offset=0, distrib=True, replica=False, latest=None, **kwargs):
50+
def esgf_query(query=None, fields=[], otype='File', limit=10000, offset=0, distrib=True, replica=False, latest=None, **kwargs):
5151
"""Search the ESGF
5252
5353
Searches the ESGF using its `API
@@ -79,16 +79,16 @@ def esgf_query(query=None, fields=[], otype='File', limit=20000, offset=0, dist
7979
'query': query,
8080
'fields': fields,
8181
'offset': offset,
82-
#'limit': 20000,
82+
'limit': limit,
8383
'distrib': distrib,
8484
'replica': replica,
8585
'latest': latest,
8686
'type': otype,
8787
'format': 'application/solr+json',
8888
}
8989
params.update(kwargs)
90-
if otype == 'Dataset': params.pop('type')
91-
print(f"Params: {params}")
90+
if otype == 'Dataset':
91+
params.pop('type')
9292

9393
try:
9494
#r = requests.get('https://esgf-node.llnl.gov/esg-search/search',
@@ -189,6 +189,7 @@ def find_checksum_id(query, **kwargs):
189189
records.append(doc)
190190
else:
191191
nosums.append(doc)
192+
print(doc)
192193

193194
record_list = [
194195
(doc['checksum'][0],
@@ -215,7 +216,7 @@ def find_checksum_id(query, **kwargs):
215216
column('score', Float),
216217
name = 'esgf_table'
217218
).data(record_list)
218-
print(record_list)
219+
nocksum = False
219220
if record_list == []:
220221
table = sqlalvalues(
221222
column('checksum', String),
@@ -226,9 +227,9 @@ def find_checksum_id(query, **kwargs):
226227
column('score', Float),
227228
name = 'esgf_table'
228229
).data(nosums_list)
230+
nocksum = True
229231

230-
print('this is ok')
231-
return table
232+
return table, nocksum
232233

233234

234235
def match_query(session, query, latest=None, **kwargs):
@@ -247,7 +248,7 @@ def match_query(session, query, latest=None, **kwargs):
247248
Returns:
248249
Joined result of :class:`clef.model.Path` and :func:`find_checksum_id`
249250
"""
250-
checksum_table = find_checksum_id(query, latest=latest, **kwargs)
251+
checksum_table, nocksum = find_checksum_id(query, latest=latest, **kwargs)
251252

252253
if latest is True:
253254
# Exact match on checksum
@@ -261,10 +262,13 @@ def match_query(session, query, latest=None, **kwargs):
261262
#return values.outerjoin(Path, Path.path.like('%/'+values.c.title))
262263
#return values.outerjoin(Path, func.regexp_replace(Path.path, '^.*/', '') == values.c.title)
263264
matches = checksum_table.join(Path, func.regexp_replace(Path.path, '^.*/', '') == checksum_table.c.title)
264-
if checksum_table.c.checksum.contains("NA"):
265-
matches = (checksum_table.join(C6Dataset, C6.Dataset.dataset_id == checksum_table.c.dataset_id))
265+
266+
if nocksum is True:
267+
if project == 'CMIP6':
268+
matches = (checksum_table.join(C6Dataset, C6.Dataset.dataset_id == checksum_table.c.dataset_id))
266269
return matches
267270

271+
268272
def find_local_path(session, subq):
269273
"""Find the filesystem paths of ESGF matches
270274

docs/training3.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ this is easy to implement and run. To make **search()** works for a
139139
random number of inputs passed by the command line we set up a function
140140
**call_local_query()** that deals with this more efficiently. The
141141
arguments are very similar to **search()** with the important difference
142-
that we are passing list of values instead of strings:
143-
>call_local_query(s, project, oformat, latest, \**kwargs)
142+
that we are passing list of values instead of strings::
143+
call_local_query(s, project, oformat, latest, \**kwargs)
144144

145145
Let’s look at an example:
146146

test/test_cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def test_cite(runner, prod_cli):
293293
facets = ['--model=NESM3', '--experiment=historical', '--variant_label=r2i1p1f1',
294294
'--table=day', '--variable=tas', '--grid_label=gn', '--cite']
295295
# check that write_cite is called when cite passed with --local and --remote for CMIP6
296-
c = 'Cao, Jian; Wang, Bin (2019). NUIST NESMv3 model output prepared for CMIP6 CMIP historical. Version v20190812. Earth System Grid Federation. https://doi.org/10.22033/ESGF/CMIP6.8769'
296+
c = 'Cao, Jian; Wang, Bin (2019). NUIST NESMv3 model output prepared for CMIP6 CMIP historical. Earth System Grid Federation. doi:https://doi.org/10.22033/ESGF/CMIP6.8769 .'
297297
with mock.patch('clef.cli.write_cite') as write_cite:
298298
r = prod_cli(['--local', 'cmip6', *facets])
299299
write_cite.assert_called_with([c])

test/test_code.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ def test_matching(session):
155155
}
156156
# Errors should print a message and return 'None'
157157
r = matching(session, ['variable','experiment'],['model','ensemble'], **facets)
158-
assert r is None
158+
assert r[0] is None
159+
assert r[1] is None
159160

160161

161162
def test_ids_df(dids6, results6, dids5, results5):

0 commit comments

Comments
 (0)