Logging message enhancement#606
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request enhances logging behavior by skipping warnings for offline devices during initialization checks and ensuring that warning messages for NumParam corrections are issued only once.
- New test cases for online/offline behavior in the initialization checker are added.
- Logging in parameter adjustments now issues warnings at most once.
- Device online status is integrated into condition checks for flag updates and adjustments.
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_services.py | Added tests to verify warning behavior for online and offline devices. |
| tests/test_numparam.py | Introduced tests asserting a single warning issuance for parameter checks. |
| andes/core/service.py | Modified condition checking to work only on online devices. |
| andes/core/param.py | Updated logging messages to include a note that the warning is one-time. |
| andes/core/discrete.py | Adjusted the lower/upper adjustment logic to account for device status. |
Files not reviewed (1)
- docs/source/release-notes.rst: Language not supported
Comments suppressed due to low confidence (1)
tests/test_numparam.py:16
- [nitpick] The test assertion depends on the exact log message text; since the warning now includes additional wording, consider using a regex or substring match that accommodates possible variations in the log output.
assert caplog.text.count("Non-zero parameter Line.x corrected to 1e-08.") == 1
|
I'm not sure why it's better to show the warning message only once for nonconforming inputs. In the input stage, when we add one device, When the second device |
|
A useful enhancement would be to show which device violated the property constraint. I didn't do it, because in order to do it, one parameter needs to access its owner and then access the idx field, which looked messy to me. Maybe we can revisit it. |
|
I add a notebook to explain this, https://github.com/CURENT/demo/blob/master/demo/logging/logging.ipynb:
It seems that when add a model manually after file loading, the property violation is not triggered. Indeed this is a very marginal feature, but I can handle this if helpful "which device violated the property constraint" |
|
In this example, in Input 8, I think a warning is desired, because it will
immediately alert the user to input issues. Suppressing the message creates
the possibility of omission. There should be a warning to each violation,
although I agree the information should be more rich.
Regards,
Hantao Cui
…On Thu, May 1, 2025, 11:06 PM Jinning Wang ***@***.***> wrote:
*jinningwang* left a comment (CURENT/andes#606)
<#606 (comment)>
I add a notebook to explain this,
https://github.com/CURENT/demo/blob/master/demo/logging/logging.ipynb:
- Property violation and auto correction is triggered ONLY in file
loading stage, for PSS/E and JSON files.
- Property violation and auto correction is not triggered for XLSX
file.
It seems that when add a model manually after file loading, the property
violation is not triggered.
Indeed this is a very marginal feature, but I can handle this if helpful
"which device violated the property constraint"
—
Reply to this email directly, view it on GitHub
<#606 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSNZA65JPFJOADPJNZF6NL24LOKRAVCNFSM6AAAAAB4AX3NL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNBWGIYTIOJTGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
Thank you for your comment. I agree with your opinion and plan to implement the following enhancements:
Change 1 involves Change 2 involves the three file parsing modules. Let me know if I miss anything. |
Turning off the warning is not a great idea because some warnings are due to user omissions that need attention. The proposed change falls under the category of "fail silently" and is generally advised against. If the goal is to make the program less verbose, we can store all the warning messages somewhere and output a message at the end like this: ```There are warnings during the data parsing. To see all the warnings, do |
|
Agree with you, but we might skip this feature for now. |
|
Now in this PR I only skip the InitChecker logging and limiter adjust for offline devices. |
|
Tracking the status of this PR against the current Already addressed
Not yet addressed
I'm going to hold on for the common parameters for groups due to some planned overhaul. Also, the models should follow an interface for querying the status instead of assuming the names of the status field. |
Update on "Not yet addressed" itemsThe following items from the tracking list have been addressed in 81a1da9: Now addressed
Additional fixes in the same commit
|
does not meet the expected criteria, or 2) unused data is detected.