Skip to content

Commit

Permalink
Add --json flag
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed May 25, 2024
1 parent cff547e commit abb6714
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/anemoi/inference/checkpoint/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class Metadata:
def __init__(self, metadata):
self._metadata = metadata

def to_dict(self):
return self._metadata

@classmethod
def from_metadata(cls, metadata):
if isinstance(metadata["dataset"], list):
Expand Down
8 changes: 8 additions & 0 deletions src/anemoi/inference/commands/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#


import json

from ..checkpoint import Checkpoint
from . import Command

Expand All @@ -18,12 +20,18 @@ class CheckpointCmd(Command):
need_logging = False

def add_arguments(self, command_parser):
command_parser.add_argument("--json", action="store_true", help="Output in JSON format")
command_parser.add_argument("path", help="Path to the checkpoint.")

def run(self, args):
from anemoi.utils.text import dotted_line

c = Checkpoint(args.path)

if args.json:
print(json.dumps(c.to_dict(), indent=4, sort_keys=True))
return

print("num_input_features:", c.num_input_features)
print("hour_steps:", c.hour_steps)
result = list(range(0, c.multi_step))
Expand Down

0 comments on commit abb6714

Please sign in to comment.