Skip to content

[MONAI Bundle] Very long errors during config instantiation - Clean up raised errors #7451

Closed

Description

@surajpaib

Is your feature request related to a problem? Please describe.
When there is an error in the monai bundle config during instantiation, and the config is large, the RuntimeError ends up being extremely long.
This is counterproductive for debugging and pollutes the terminal with uninformative error messages.

The root cause of this looks to be the RuntimeError messages generated here:

To Reproduce
Run any relatively large configuration with a wrongly configured argument, and this will occur.
Attached is an example config and the error log below.

The command run for the bundle to run is
python -m monai.bundle run system --config_file config.yaml

error_log.txt
config.json [YAML renamed to JSON as github doesn't allow uploading YAML]

Describe the solution you'd like
A clear and concise error message would be more informative.

I have the following suggestions:

  1. Remove the RuntimeError raised in ConfigComponent as the instantiate call will already raise it. Remove this basically:
    raise RuntimeError(f"Failed to instantiate {self}") from e
  2. It would be ideal if the RuntimeError raised in
    raise RuntimeError(
    shows only the __path and not the full kwargs by default. Maybe this could be moved into debug mode instead?

Activity

  1. surajpaib commented on Feb 8, 2024

    @surajpaib
    ContributorAuthor

    I'm happy to send a PR for this @KumoLiu
    Let me know

  2. KumoLiu commented on Feb 14, 2024

    @KumoLiu
    Contributor

    Hi @surajpaib, sure, welcome for the contribution. Thanks.

  3. added a commit that references this issue on Mar 26, 2024
    97678fa
  4. added a commit that references this issue on Mar 27, 2024
    3f055a9
  5. added a commit that references this issue on Apr 11, 2024
    d26abc8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions