Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
surajpaib opened this issue Feb 7, 2024 · 2 comments · Fixed by #7569
Closed
Assignees
Labels
enhancement New feature or request

Comments

@surajpaib
Copy link
Contributor

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?
@KumoLiu KumoLiu added the enhancement New feature or request label Feb 8, 2024
@surajpaib
Copy link
Contributor Author

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

@KumoLiu
Copy link
Contributor

KumoLiu commented Feb 14, 2024

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

KumoLiu pushed a commit that referenced this issue Mar 26, 2024
Fixes #7451

### Description
Reduces the length of error messages and error messages being propagated
twice. This helps debug better when long `ConfigComponent`s are being
instantiated. Refer to issue #7451 for more details

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Suraj Pai <b.pai@maastrichtuniversity.nl>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
NikolasSchmitz pushed a commit to NikolasSchmitz/MONAI that referenced this issue Mar 27, 2024
…ject-MONAI#7569)

Fixes Project-MONAI#7451

### Description
Reduces the length of error messages and error messages being propagated
twice. This helps debug better when long `ConfigComponent`s are being
instantiated. Refer to issue Project-MONAI#7451 for more details

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Suraj Pai <b.pai@maastrichtuniversity.nl>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Yu0610 pushed a commit to Yu0610/MONAI that referenced this issue Apr 11, 2024
…ject-MONAI#7569)

Fixes Project-MONAI#7451

### Description
Reduces the length of error messages and error messages being propagated
twice. This helps debug better when long `ConfigComponent`s are being
instantiated. Refer to issue Project-MONAI#7451 for more details

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Suraj Pai <b.pai@maastrichtuniversity.nl>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Yu0610 <612410030@alum.ccu.edu.tw>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants