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 #4692 - Modify Model::load to use the VersionTranslator #4923

Merged
merged 4 commits into from
Aug 24, 2023

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Jul 4, 2023

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • 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 added component - Model Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. APIChange A motivated non-backward compatible change that breaks the existing API and needs to be communicated labels Jul 4, 2023
@jmarrec jmarrec self-assigned this Jul 4, 2023
@@ -21,8 +21,11 @@
#include <utilities/idd/IddEnums.hxx>
#include <utilities/idd/OS_Version_FieldEnums.hxx>

#include "../osversion/VersionTranslator.hpp"
Copy link
Collaborator Author

@jmarrec jmarrec Jul 4, 2023

Choose a reason for hiding this comment

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

So, there's one thing I'm not sure about here. This ends up referencing the osversion::VersionTranslator, when the osversion::VersionTranslator itself references the model/Schedule.hpp (for some 0.8.x translation). osversion depends on model at the model. But all of them are OBJECT libraries anyways, so that looks to link just fine in the end (locally at least, we'll see on CI)... @kbenne thoughts please?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I actually mentioned this circular thing at our last iteration meeting. I said I thought this feature was straightforward except for this little ciruclar wrinkle, but I think it is fine. So I say if we don't have any linking issues then great, it works for me.

Comment on lines +1847 to +1865
if (!openstudio::filesystem::is_regular_file(osmPath)) {
LOG(Warn, "Path is not a valid file: " << osmPath);
return boost::none;
}
openstudio::osversion::VersionTranslator vt;
boost::optional<openstudio::model::Model> model_ = vt.loadModel(osmPath);
if (!model_) {
LOG(Warn, "Failed to load model at " << osmPath);
return boost::none;
}
// Load the workflow.osw in the model's companion folder
const openstudio::path workflowJSONPath = getCompanionFolder(osmPath) / toPath("workflow.osw");
if (exists(workflowJSONPath)) {
if (boost::optional<WorkflowJSON> workflowJSON_ = WorkflowJSON::load(workflowJSONPath)) {
model_->setWorkflowJSON(*workflowJSON_);
}
}

return result;
return model_;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New load method using the VersionTranslator.

Copy link
Contributor

Choose a reason for hiding this comment

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

It sure was annoying to not have this feature all of these years. Thank you for fixing it!

@@ -21,8 +21,11 @@
#include <utilities/idd/IddEnums.hxx>
#include <utilities/idd/OS_Version_FieldEnums.hxx>

#include "../osversion/VersionTranslator.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I actually mentioned this circular thing at our last iteration meeting. I said I thought this feature was straightforward except for this little ciruclar wrinkle, but I think it is fine. So I say if we don't have any linking issues then great, it works for me.

Comment on lines +1847 to +1865
if (!openstudio::filesystem::is_regular_file(osmPath)) {
LOG(Warn, "Path is not a valid file: " << osmPath);
return boost::none;
}
openstudio::osversion::VersionTranslator vt;
boost::optional<openstudio::model::Model> model_ = vt.loadModel(osmPath);
if (!model_) {
LOG(Warn, "Failed to load model at " << osmPath);
return boost::none;
}
// Load the workflow.osw in the model's companion folder
const openstudio::path workflowJSONPath = getCompanionFolder(osmPath) / toPath("workflow.osw");
if (exists(workflowJSONPath)) {
if (boost::optional<WorkflowJSON> workflowJSON_ = WorkflowJSON::load(workflowJSONPath)) {
model_->setWorkflowJSON(*workflowJSON_);
}
}

return result;
return model_;
Copy link
Contributor

Choose a reason for hiding this comment

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

It sure was annoying to not have this feature all of these years. Thank you for fixing it!

@jmarrec jmarrec merged commit 3a24207 into develop Aug 24, 2023
2 checks passed
@jmarrec jmarrec deleted the 4692_Model_load branch August 24, 2023 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APIChange A motivated non-backward compatible change that breaks the existing API and needs to be communicated component - Model Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modify Model::load(path&) to use VersionTranslator by default
3 participants