Skip to content

Logging message enhancement #606

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

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open

Conversation

jinningwang
Copy link
Member

@jinningwang jinningwang commented Apr 28, 2025

  • Skip InitChecker logging and limiter adjust for offline devices.
  • When reading files, issue a warning only once per model for the following cases: 1) a NumParam value
    does not meet the expected criteria, or 2) unused data is detected.

@jinningwang jinningwang requested a review from Copilot April 28, 2025 15:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jinningwang jinningwang requested a review from Copilot April 28, 2025 16:01
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jinningwang jinningwang linked an issue Apr 29, 2025 that may be closed by this pull request
2 tasks
@cuihantao
Copy link
Collaborator

cuihantao commented May 2, 2025

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, GEN 1 with inertia H = 0, for example, this should trigger one message so that the user will be able to identify and fix it.

When the second device GEN 2 with H = 0 is added, shouldn't this message be displayed again?

@cuihantao
Copy link
Collaborator

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.

@jinningwang
Copy link
Member Author

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"

@cuihantao
Copy link
Collaborator

cuihantao commented May 2, 2025 via email

@jinningwang
Copy link
Member Author

Thank you for your comment. I agree with your opinion and plan to implement the following enhancements:

  1. Individual Check by Default: This will perform a check on a single device input by default. When reading from a file, this will be turned off, and a model-level check will be conducted instead. Additionally, when users add new devices one by one, this check should be triggered automatically when calling NumParam.add
  2. Model-Level Check: This will perform a check on all devices within a model, identifying which devices have violations and providing the idxes. This one should be triggered automatically after adding all devices from case file.

Change 1 involves System.add, ModelData.add, and NumParam.add

Change 2 involves the three file parsing modules.

Let me know if I miss anything.

@cuihantao
Copy link
Collaborator

cuihantao commented May 11, 2025

When reading from a file, this will be turned off, and a model-level check will be conducted instead

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 system.show_warnings()

(you can decide where to place the function.)

In that output, then provide more information regarding which parameter of which device trigger the warning, and the exact reason. 

Let me know if this makes sense and if you'd like to proceed.

@jinningwang
Copy link
Member Author

Agree with you, but we might skip this feature for now.

@jinningwang
Copy link
Member Author

Now in this PR I only skip the InitChecker logging and limiter adjust for offline devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement on logging message
2 participants