Skip to content

Commit d282a86

Browse files
committed
update inspect command
1 parent 25cf486 commit d282a86

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/anemoi/datasets/commands/inspect/__init__.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,15 @@ class Inspect(Command, InspectZarr):
1717

1818
def add_arguments(self, command_parser):
1919
# g = command_parser.add_mutually_exclusive_group()
20-
command_parser.add_argument("path", metavar="PATH", nargs="+")
20+
command_parser.add_argument("path", metavar="DATASET")
2121
command_parser.add_argument("--detailed", action="store_true")
2222
# command_parser.add_argument("--probe", action="store_true")
2323
command_parser.add_argument("--progress", action="store_true")
2424
command_parser.add_argument("--statistics", action="store_true")
2525
command_parser.add_argument("--size", action="store_true", help="Print size")
2626

2727
def run(self, args):
28-
dic = vars(args)
29-
for path in dic.pop("path"):
30-
if os.path.isdir(path) or path.endswith(".zarr.zip") or path.endswith(".zarr"):
31-
self.inspect_zarr(path=path, **dic)
32-
else:
33-
raise ValueError(f"Unknown file type: {path}")
34-
# self.inspect_checkpoint(path=path, **dic)
28+
self.inspect_zarr(**vars(args))
3529

3630

3731
command = Inspect

src/anemoi/datasets/commands/inspect/zarr.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from anemoi.datasets import open_dataset
2626
from anemoi.datasets.data.stores import open_zarr
27+
from anemoi.datasets.data.stores import zarr_lookup
2728

2829
LOG = logging.getLogger(__name__)
2930

@@ -616,14 +617,7 @@ def inspect_zarr(self, path, **kwargs):
616617
raise
617618

618619
def _info(self, path):
619-
if path.endswith("/"):
620-
path = path[:-1]
621-
622-
try:
623-
z = open_zarr(path)
624-
except Exception as e:
625-
LOG.error("Error opening zarr file '%s': %s", path, e)
626-
raise
620+
z = open_zarr(zarr_lookup(path))
627621

628622
metadata = dict(z.attrs)
629623
version = metadata.get("version", "0.0.0")

0 commit comments

Comments
 (0)