Skip to content

Error catching for failed import of anemoi-transform filter #158

@anaprietonem

Description

@anaprietonem

What happened?

When a anemoi-transform filter is not correctly registered a general error is then showed when trying to use the filter.

ValueError: Unknown step action r-2-q
2025-05-26 10:58:42 ERROR
💣 Unknown step action r-2-q

This error is hiding the failed import that occurs when trying to import the filter at registering time. If the import fails the code should crash with the real error.

As spotted by @flyIchtus 🙌

Each filter is loaded into the registry. The registry is created in the _init_ file of anemoi.transform.filters and used in anemoi.datasets.input.step ; when created, it scans the anemoi.transform.filters directory and attempts to import every file in it (cf [here](https://github.com/ecmwf/anemoi-utils/blob/main/src/anemoi/utils/registry.py#L237)). If the import fails for any reason, the filter is not registered, and the code reports "Error : xxx filter not found in anemoi.transform.filters" ; this does not hint at why the import failed

What are the steps to reproduce the bug?

Try to create a new filter where for example you're missing certain attributes or there is a misspelled variable name

Version

Current

Platform (OS and architecture)

ATOS

Relevant log output

Accompanying data

No response

Organisation

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions