Skip to content

Commit 1905f87

Browse files
committed
display honor priority order
1 parent 33c87f7 commit 1905f87

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

src/herbie/v2/_base.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -666,22 +666,18 @@ def xarray(
666666

667667
return ds
668668

669-
def found(self) -> dict[str, tuple]:
669+
def find(self) -> dict[str, tuple]:
670670
"""
671-
Resolve and return the first available GRIB source and index file.
671+
Resolve the first available GRIB source and index file.
672672
673673
Unlike ``status()``, which fires parallel HEAD requests to *every*
674-
source, ``found()`` walks sources in priority order and stops at the
674+
source, ``find()`` walks sources in priority order and stops at the
675675
first hit — exactly the same logic used by ``inventory()``,
676676
``download()``, and ``xarray()``. Call it to confirm which source
677677
will actually be used before doing any real work.
678678
679679
Results are cached, so repeated calls are free.
680680
"""
681-
# Trigger lazy resolution (cached after the first call)
682-
grib_src, grib_url = self._found_grib
683-
idx_src, idx_url = self._found_index
684-
685681
return {
686682
"grib": self._found_grib,
687683
"index": self._found_index,
@@ -703,16 +699,17 @@ def status(self) -> None:
703699
from rich.console import Group
704700

705701
# ── Categorize sources by type ─────────────────────────────────────
702+
ordered = self._ordered_sources() # respects user priority
706703
grib_srcs: dict = {
707704
n: s
708-
for n, s in self._sources.items()
705+
for n, s in ordered.items()
709706
if isinstance(s, (GribSource, EccodesGribSource))
710707
}
711708
dir_srcs: dict = {
712-
n: s for n, s in self._sources.items() if isinstance(s, DirectorySource)
709+
n: s for n, s in ordered.items() if isinstance(s, DirectorySource)
713710
}
714711
zarr_srcs: dict = {
715-
n: s for n, s in self._sources.items() if isinstance(s, ZarrSource)
712+
n: s for n, s in ordered.items() if isinstance(s, ZarrSource)
716713
}
717714

718715
# ── Parallel HEAD requests ─────────────────────────────────────────
@@ -927,7 +924,7 @@ def _repr_html_(self) -> str:
927924

928925
# Build one row per source in declared priority order
929926
source_rows_html = ""
930-
for name, src in self._sources.items():
927+
for name, src in self._ordered_sources().items():
931928
if isinstance(src, (GribSource, EccodesGribSource)):
932929
url = src.url
933930
idx_url = src.url + src.index_suffixes[0]
@@ -993,11 +990,11 @@ def _repr_html_(self) -> str:
993990
<b>Valid:</b> {self.valid_date:%Y-%b-%d %H:%M UTC}
994991
</p>
995992
<details style="margin-top:8px">
996-
<summary style="cursor:pointer;font-weight:bold"> Parameters</summary>
993+
<summary style="cursor:pointer;font-weight:bold">&#9654; Parameters</summary>
997994
<table style="border-collapse:collapse;margin-top:4px">{params_html}</table>
998995
</details>
999996
<details style="margin-top:4px" open>
1000-
<summary style="cursor:pointer;font-weight:bold"> Sources</summary>
997+
<summary style="cursor:pointer;font-weight:bold">&#9654; Sources</summary>
1001998
<p style="margin:6px 0 4px 0">
1002999
<b>Resolved:</b> {resolved_badge} &nbsp;&nbsp;
10031000
<b>Local:</b> <code style="font-size:0.85em">{self.local_path}</code>

0 commit comments

Comments
 (0)