Skip to content

Commit

Permalink
add check for empty list of stores (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored May 15, 2024
1 parent 92f6d5f commit ce30eae
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions leap_data_management_utils/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def is_store_public(store) -> bool:

def is_geospatial(store) -> bool:
url = get_http_url(store)
ds = xr.open_dataset(url, engine='zarr', chunks={})
ds = xr.open_dataset(url, engine='zarr', chunks={}, decode_cf=False)
cf_axes = ds.cf.axes

# Regex patterns that match 'lat', 'latitude', 'lon', 'longitude' and also allow prefixes
Expand All @@ -195,16 +195,19 @@ def validate_feedstocks(*, feedstocks: list[upath.UPath]) -> list[Feedstock]:
for feedstock in feedstocks:
try:
feed = Feedstock.from_yaml(convert_to_raw_github_url(feedstock))
print('πŸ”„ Checking stores')
for index, store in enumerate(feed.stores):
print(f' 🚦 {store.id} ({index + 1}/{len(feed.stores)})')
is_public = is_store_public(store.rechunking or store.url)
feed.stores[index].public = is_public
if is_public:
# check if the store is geospatial
# print('🌍 Checking geospatial')
is_geospatial_store = is_geospatial(store.rechunking or store.url)
feed.stores[index].geospatial = is_geospatial_store
if feed.stores:
print('πŸ”„ Checking stores')
for index, store in enumerate(feed.stores):
print(f' 🚦 {store.id} ({index + 1}/{len(feed.stores)})')
is_public = is_store_public(store.rechunking or store.url)
feed.stores[index].public = is_public
if is_public:
# check if the store is geospatial
# print('🌍 Checking geospatial')
is_geospatial_store = is_geospatial(store.rechunking or store.url)
feed.stores[index].geospatial = is_geospatial_store
else:
print('πŸš€ No stores found.')
valid.append({'feedstock': str(feedstock), 'status': 'valid'})
catalog.append(feed)
except Exception:
Expand Down

0 comments on commit ce30eae

Please sign in to comment.