Enhance Custom Validator Error Messages with Object Names#2618
Conversation
7cd58a2 to
e000a37
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
8c78981 to
4a00197
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
Passing unit tests. |
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
5855eb6 to
b498776
Compare
There was a problem hiding this comment.
2 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile
yaugenst-flex
left a comment
There was a problem hiding this comment.
Thanks @jewettaijfc I think the implementation looks good! Still needs some tests though.
b498776 to
a8c5f14
Compare
|
@jewettaijfc you should be able to catch and match a logged warning using |
Cool! Do you want me to parse the content of the warning messages and error messages (to make sure the message contains the object name)?
Thanks! (I was wondering this too.) |
2552fdb to
fd89436
Compare
|
I guess that wasn't so bad! I added a new test ( |
ac3faa0 to
8c73910
Compare
|
Sorry. I misunderstood what you were asking for. (You were clear. This is my fault.) I will add |
|
Done. |
e0a2c60 to
1ac84e2
Compare
|
Now using |
7c3f338 to
c96de70
Compare
yaugenst-flex
left a comment
There was a problem hiding this comment.
Nice! Some minor test cleanup and this should be good to go!
0cdf4d0 to
929d8ed
Compare
yaugenst-flex
left a comment
There was a problem hiding this comment.
Great! One last nitpick, then we need a changelog entry (under "Changed"), squash & rebase and this is good to go!
c433db9 to
21dba9a
Compare
I can't believe I forgot to update the changelog (again). Sorry about that! All ready now. |
366a33e to
f3b084b
Compare
yaugenst-flex
left a comment
There was a problem hiding this comment.
LGTM! Thanks @jewettaijfc
This PR is an attempt to address issue #2614 .
This PR changes the warnings error messages printed to the user for
Monitor,Source, andStructure. If the user specified a "name" argument when instantiating these classes, the error message will refer to that name instead of the internal expression that refers to it (which means nothing to the user).Example input:
(test file: test_pr2618.ipynb.zip
Before this PR (example error message)
This generates:
Similarly cryptic errors are displayed for Structures and Monitors if you uncomment the
# structures=[structure].and# monitors=[monitor],lines in the code above.After this PR (example error message)
nameargument is omitted from the argument list, then a (vague) error messages is generated. For example:"simulation.sources[0] (no 'name' was specified) is outside of the simulation domain."
To encourage that, a warning messages is generated when a Source is created without a name argument. For example: WARNING: UniformCurrentSource instantiated without a name argument.Greptile Summary
Enhances error message clarity by incorporating user-specified names for Monitor, Source, and Structure objects in validation messages.
named_obj_descrhelper function incomponents/validators.pyto generate more descriptive error strings'source_1' (simulation.sources[0]))components/simulation.pyto use component names when available'(no name was specified)')assert_objects_completely_in_sim_bounds