Skip to content

Commit

Permalink
Merge branch 'feature/registry' of github.com:ecmwf/anemoi-utils into…
Browse files Browse the repository at this point in the history
… feature/registry
  • Loading branch information
b8raoult committed Nov 1, 2024
2 parents 2e161d9 + 15a9591 commit 01e85bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Keep it human-readable, your future self will thank you!
### Added
- Add supporting_arrays to checkpoints
- Add factories registry
- Optional renaming of subcommands via `command` attribute [#34](https://github.com/ecmwf/anemoi-utils/pull/34)


## [0.4.1](https://github.com/ecmwf/anemoi-utils/compare/0.4.0...0.4.1) - 2024-10-23

Expand Down
16 changes: 14 additions & 2 deletions src/anemoi/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,20 @@ def register_commands(here, package, select, fail=None):
continue

obj = select(imported)
if obj is not None:
result[name] = obj
if obj is None:
continue

if hasattr(obj, "command"):
name = obj.command

if name in result:
msg = f"Duplicate command '{name}', please choose a different command name for {type(obj)}"
raise ValueError(msg)
if " " in name:
msg = f"Commands cannot contain spaces: '{name}' in {type(obj)}"
raise ValueError(msg)

result[name] = obj

for name, e in not_available.items():
if fail is None:
Expand Down

0 comments on commit 01e85bf

Please sign in to comment.