Skip to content

Commit

Permalink
update inspect command
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Jun 8, 2024
1 parent 25cf486 commit d282a86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
10 changes: 2 additions & 8 deletions src/anemoi/datasets/commands/inspect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@ class Inspect(Command, InspectZarr):

def add_arguments(self, command_parser):
# g = command_parser.add_mutually_exclusive_group()
command_parser.add_argument("path", metavar="PATH", nargs="+")
command_parser.add_argument("path", metavar="DATASET")
command_parser.add_argument("--detailed", action="store_true")
# command_parser.add_argument("--probe", action="store_true")
command_parser.add_argument("--progress", action="store_true")
command_parser.add_argument("--statistics", action="store_true")
command_parser.add_argument("--size", action="store_true", help="Print size")

def run(self, args):
dic = vars(args)
for path in dic.pop("path"):
if os.path.isdir(path) or path.endswith(".zarr.zip") or path.endswith(".zarr"):
self.inspect_zarr(path=path, **dic)
else:
raise ValueError(f"Unknown file type: {path}")
# self.inspect_checkpoint(path=path, **dic)
self.inspect_zarr(**vars(args))


command = Inspect
10 changes: 2 additions & 8 deletions src/anemoi/datasets/commands/inspect/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from anemoi.datasets import open_dataset
from anemoi.datasets.data.stores import open_zarr
from anemoi.datasets.data.stores import zarr_lookup

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -616,14 +617,7 @@ def inspect_zarr(self, path, **kwargs):
raise

def _info(self, path):
if path.endswith("/"):
path = path[:-1]

try:
z = open_zarr(path)
except Exception as e:
LOG.error("Error opening zarr file '%s': %s", path, e)
raise
z = open_zarr(zarr_lookup(path))

metadata = dict(z.attrs)
version = metadata.get("version", "0.0.0")
Expand Down

0 comments on commit d282a86

Please sign in to comment.