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

Fix bug after constructing a ModelProcessor from a Model object #3577

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

nickbianco
Copy link
Member

@nickbianco nickbianco commented Oct 12, 2023

Discovered by @mattpetrucci.

Brief summary of changes

  • Added model.finalizeFromProperties() and model.finalizeConnections() after constructing a ModelProcessor from a Model object. Without these calls, some ModelOperators lead to an error complaining that the model had no subcomponents. This now matches the behavior when loading a model from a file.
  • Removed some finalizeFromProperties calls in ModelOperators.h.

Testing I've completed

  • Ran testModelProcessor.cpp without the fix and it failed. Added the fix and it passed.

CHANGELOG.md (choose one)

  • updated.

This change is Reviewable

Copy link
Member

@aymanhab aymanhab left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @nickbianco)

Copy link
Member

@tkuchida tkuchida left a comment

Choose a reason for hiding this comment

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

This PR fixes a bug that was not caught by the current tests. I don't know the context of this change, but perhaps consider adding a test that fails before and passes after the change. @adamkewley has been doing this recently and it's awesome (e.g., #3554). 🦓

@nickbianco
Copy link
Member Author

@tkuchida I totally agree and actually did do this in a sneaky way. By removing the (now redundant) finalizeFromProperties calls from ModelOperators, testModelProcessor will fail if the fix is removed. Essentially, I used the existing tests to replicate the bug and tested with and without the fix, and got failure and pass as expected.

Hopefully that makes sense. Let me know if you were thinking something different.

@tkuchida
Copy link
Member

@nickbianco Thanks. I was bit confused: all the tests pass before this PR, they all still pass after this PR, and no tests were added, so it seemed like something was changing that isn't being tested. But there's no strict requirement about this so no worries. 🐫

@nickbianco nickbianco merged commit fc29aec into main Oct 13, 2023
7 checks passed
@nickbianco nickbianco deleted the model_processor_finalize branch October 13, 2023 18:10
@nickbianco
Copy link
Member Author

@tkuchida, thanks for checking! Perhaps we could include this a recommendation in the contributing guidelines for bug fixes.

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.

3 participants