Skip to content

Feature/Check subsystem graphs in sanity check - #24

Merged
AlexKocherKIT merged 6 commits into
mainfrom
feature/sanity-check-subsystem-graphs
Aug 19, 2026
Merged

Feature/Check subsystem graphs in sanity check#24
AlexKocherKIT merged 6 commits into
mainfrom
feature/sanity-check-subsystem-graphs

Conversation

@Sriganesh-k

@Sriganesh-k Sriganesh-k commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Updates CoreModel.sanity_check() so that subsystem graphs are checked recursively.

Changes:

  • Checks nested Subsystem graphs recursively
  • Keeps graph, connector, and unique-ID validation
  • Adds tests for valid and invalid subsystem graphs
  • Updates the IEEE39 sanity-check expectations because the known missing connector issue is now detected inside subsystems

Tests:

  • 5 utils tests passed
  • 22 GDF tests passed, 1 skipped

This builds on the sanity-check changes from #15.

Closes #17 and #8 (as it includes changes from #15)

@JohannesWeinbrecht JohannesWeinbrecht left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As stated, I think this PR needs to wait until #25 is done, so we can add some correct models and test the sanity check fix on those as well.

Only having tests of the sanity check on real models were we assert failure is not sufficient IMO.

Comment on lines -339 to -340
:return: True if the model is valid, else False.
"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I do not understand why this doc string was removed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Restored the return documentation and updated the docstring to mention recursive subsystem validation.

data = json.loads(data_str)
core_model = CoreModel.import_dict(data)

self.assertFalse(core_model.sanity_check())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can keep the old models as a regression test just to make sure, but before merging I would like to generate some new, correct GDF models, with the (hopefully soon) fix in #25 (Issue: #16) and add those as tests as well, were the sanity actually correctly approves on a larger model.

The current state of only having sanity check tests on actual models where failure is asserted is IMO not sufficient.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Keeping the old models as regression tests makes sense, but we should also add tests with newly generated, correct GDF models where the sanity check is expected to pass.

At the moment, I’m blocked on generating those models because although my VM is up and running, PowerFactory is no longer working on my side. Once that is resolved, I can generate the new models using the fix from #25 / #16 and add them as additional sanity-check tests.

@Sriganesh-k

Copy link
Copy Markdown
Collaborator Author

Added a fresh PowerFactory-derived IEEE Std 399 GDF as a positive regression case. sanity_check() now passes after reload, while the existing IEEE39 fixtures still cover the failing cases.

Tests: 6 passed in utils, 23 passed, 1 skipped in GDF.

@Sriganesh-k Sriganesh-k self-assigned this Aug 14, 2026

@JohannesWeinbrecht JohannesWeinbrecht left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

For documentation, I tested this sanity check on the following models

(newly converted using #25 and asserting sanity check yields true)

  • IEEE39 clean
  • IEEE39 clean flat
  • IEEE39 pf default
  • IEEE39 pf default flat

(assert sanity check yields false (old models from tests/models))

  • IEEE39 flat
  • IEEE39

@AlexKocherKIT
AlexKocherKIT merged commit 06bb84d into main Aug 19, 2026
1 check passed
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.

Sanity check does check subsystem graphs

3 participants