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 #4544 - CoilCoolingDX::clone crashes when called with another model #4576

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Apr 26, 2022

Pull request overview

  • Fix CoilCoolingDX::clone crashes when called with another model #4544
  • CoilCoolingDX::clone crashes when called with another model, because we have an issue where a component has a resourceobject which has a resource object, AND everyone lists them in the children() method.
  • I went around in circles trying to make it work and retain it in the children method, but I decided not to, because really they shouldn't be listed

I don't think this qualifies as an "APIChange" because the API didn't change. It'll require downstream users to update their code (OSapp at least)

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • [x) Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec self-assigned this Apr 26, 2022
@jmarrec jmarrec changed the title #Fix 4544 - CoilCoolingDX::clone crashes when called with another model Fix #4544 - CoilCoolingDX::clone crashes when called with another model Apr 26, 2022
@jmarrec jmarrec requested review from tijcolem and kbenne April 26, 2022 10:03
@tijcolem tijcolem added the Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. label May 9, 2022
@jmarrec jmarrec force-pushed the 4544_CoilCoolingDX_clone_proper branch from 133cdae to 97738a3 Compare July 26, 2022 09:59
@jmarrec jmarrec added this to the OpenStudio SDK 3.5.0 milestone Jul 26, 2022
@jmarrec jmarrec force-pushed the 4544_CoilCoolingDX_clone_proper branch from 97738a3 to c19e317 Compare September 28, 2022 11:29
@tijcolem tijcolem removed this from the OpenStudio SDK 3.5.0 milestone Oct 14, 2022
@@ -85,8 +85,8 @@ namespace model {

std::vector<ModelObject> CoilCoolingDXCurveFitOperatingMode_Impl::children() const {
// These are ResourceObjects, so they shouldn't really be children except for OS App / IG
std::vector<ModelObject> result = subsetCastVector<ModelObject>(speeds());

// std::vector<ModelObject> result = subsetCastVector<ModelObject>(speeds());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just remove this line instead of a comment?

@@ -134,7 +134,7 @@ namespace model {
std::vector<ModelObject> result;

// This is a ResourceObject, so it shouldn't really be a child except for OS App / IG
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the strategy over in the App if performance objects are no longer children? Is there a corresponding change to App to specialize the IG for this type? Or maybe instead it is just ok to not show the performance data? I'm just asking out of curiousity. I agree that the main impact of this PR pertains to the App's inspector.

@@ -99,13 +99,13 @@ namespace model {
std::vector<ModelObject> result;

// These are ResourceObjects, so they shouldn't really be children except for OS App / IG
result.push_back(baseOperatingMode());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I rebased the change(s) onto my codebase and rebuild and cause the failure of serveral tests.

[  FAILED  ] 3 tests, listed below:
[  FAILED  ] ModelFixture.CoilCoolingDX_clone
[  FAILED  ] ModelFixture.CoilCoolingDXCurveFitPerformance_clone
[  FAILED  ] ModelFixture.CoilCoolingDXCurveFitOperatingMode_clone

Do you mind review the tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I'm still not sure how to fix it properly. I need to revisit this at some point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I deep dived into the unittests and find the issue is happening in

  EXPECT_EQ(0u, model.getConcreteModelObjects<CoilCoolingDXCurveFitOperatingMode>().size());

Which the model.getConcreteModelObjects<CoilCoolingDXCurveFitOperatingMode>().size()'s value is 1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have access to Jenkins FYI, so I have access to the failed runs to see the failures.

The solution to having both clone to same model and clone to another is not trivial though. I'll eventually get back to this PR, it's a minor bug with a rather expensive solution: one that requires reimplementing or overriding the internals of ResourceObject and ParentObject (getRecursiveResources / getRecursiveChildren) and how things are added at Workspace level (addObjects). That portion of the sdk is complicated and finicky.
I've converted the PR to draft in the meantime for clarity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If someone is burning to fix this though please go ahead. I think I have a jupyter notebook somewhere where I've rewritten the getRecursiveXXX stuff to be able to test changes, I could try to locate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - Model Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Normal Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CoilCoolingDX::clone crashes when called with another model
5 participants