Skip to content

Commit

Permalink
fix: protect against NoSearchResults exceptions from intake_esgf
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley authored and johnkit committed Apr 30, 2024
1 parent c4c9dae commit 3654f48
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions pan3d/esgf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://intake-esgf.readthedocs.io/en/latest/quickstart.html
from intake_esgf import ESGFCatalog
from intake_esgf.exceptions import NoSearchResults
from datetime import datetime
from pathlib import Path
import json
Expand Down Expand Up @@ -55,21 +56,25 @@ def get_group_datasets(group_value):
experiment_id, source_id = group_value.split('/')
start = datetime.now()
catalog = ESGFCatalog()
search = catalog.search(
experiment_id=experiment_id,
source_id=source_id,
)
results = [
{
'name': id,
'value': {
'source': 'esgf',
'id': id
results = []
try:
search = catalog.search(
experiment_id=experiment_id,
source_id=source_id,
)
results = [
{
'name': id,
'value': {
'source': 'esgf',
'id': id
}
}
}
# get first dataset for each unique variable
for id in search.df.groupby('variable_id').head(n=1).id
]
# get first dataset for each unique variable
for id in search.df.groupby('variable_id').head(n=1).id
]
except NoSearchResults:
pass

catalog_contents[group_value] = results
with open(CACHED_CATALOG_PATH, 'w') as f:
Expand Down

0 comments on commit 3654f48

Please sign in to comment.