-
Notifications
You must be signed in to change notification settings - Fork 208
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
OS:Version, | ||
{e2190a61-e3f3-4d4b-8c0b-7a9c2342180e}, !- Handle | ||
3.6.1; !- Version Identifier | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"created_at" : "20230704T152451Z", | ||
"seed_file" : "../empty361.osm", | ||
"steps" : [], | ||
"updated_at" : "20230704T152548Z" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,11 @@ | |
#include <utilities/idd/IddEnums.hxx> | ||
#include <utilities/idd/OS_Version_FieldEnums.hxx> | ||
|
||
#include "../osversion/VersionTranslator.hpp" | ||
|
||
#include "../utilities/core/Assert.hpp" | ||
#include "../utilities/core/ContainersMove.hpp" | ||
#include "../utilities/core/Filesystem.hpp" | ||
#include "../utilities/core/PathHelpers.hpp" | ||
|
||
#include "../utilities/idd/IddEnums.hpp" | ||
|
@@ -1840,27 +1843,26 @@ namespace model { | |
} | ||
|
||
boost::optional<Model> Model::load(const path& osmPath) { | ||
OptionalModel result; | ||
OptionalIdfFile oIdfFile = IdfFile::load(osmPath, IddFileType::OpenStudio); | ||
if (oIdfFile) { | ||
try { | ||
result = Model(*oIdfFile); | ||
} catch (...) { | ||
} | ||
} | ||
|
||
if (result) { | ||
// Load the workflow.osw in the model's companion folder | ||
path workflowJSONPath = getCompanionFolder(osmPath) / toPath("workflow.osw"); | ||
if (exists(workflowJSONPath)) { | ||
boost::optional<WorkflowJSON> workflowJSON = WorkflowJSON::load(workflowJSONPath); | ||
if (workflowJSON) { | ||
result->setWorkflowJSON(*workflowJSON); | ||
} | ||
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_; | ||
Comment on lines
+1847
to
+1865
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New load method using the VersionTranslator. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! |
||
} | ||
|
||
boost::optional<Model> Model::load(const path& osmPath, const path& workflowJSONPath) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.