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

Modify Model::load(path&) to use VersionTranslator by default #4692

Closed
jmarrec opened this issue Sep 23, 2022 · 2 comments · Fixed by #4923
Closed

Modify Model::load(path&) to use VersionTranslator by default #4692

jmarrec opened this issue Sep 23, 2022 · 2 comments · Fixed by #4923

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Sep 23, 2022

Enhancement Request

It's been like this for ever, but it's weird that Model::load just assumes this is at the right version. It's very confusing to new users too, and they struggle with knowing how to load a model.

OpenStudio/src/model/Model.cpp

Lines 1836 to 1858 in 92da27b

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);
}
}
}
return result;
}

It shouldn't be that verbose to load a model

https://github.com/NREL/OpenStudio-workflow-gem/blob/cf99e6096f33b717df79a71c245a4d7aa4ccb7a6/lib/openstudio/workflow/util/model.rb#L51-L70

Detailed Description

At the very least we should provide an override or extra bool parameter.

Possible Implementation

Straightforward

@kbenne
Copy link
Contributor

kbenne commented Nov 2, 2022

Two thumbs up for this. So annoying to version translate first. Love this issue.

@DavidGoldwasser
Copy link
Collaborator

jmarrec added a commit that referenced this issue Jul 4, 2023
jmarrec added a commit that referenced this issue Aug 24, 2023
Fix #4692 - Modify Model::load to use the VersionTranslator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants