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

Model.Load(path) seems broken with some models #4916

Closed
MingboPeng opened this issue Jun 13, 2023 · 6 comments
Closed

Model.Load(path) seems broken with some models #4916

MingboPeng opened this issue Jun 13, 2023 · 6 comments
Labels
resolution - Works As Expected Triage Issue needs to be assessed and labeled, further information on reported might be needed

Comments

@MingboPeng
Copy link
Contributor

MingboPeng commented Jun 13, 2023

Issue overview

With the CSharp SDK, the method Model.Load(path) seems doesn't work with some models, and no errors are thrown.

Current Behavior

The loaded model seems empty.

Steps to Reproduce

Here is the sample code and test model.
in_IB.zip

var opsFilePath = "in_IB.osm";

// generates an empty osm file
var optModel = OpenStudio.Model.load(OpenStudio.OpenStudioUtilitiesCore.toPath(opsFilePath));
var osModel = optModel.get();
var done = osModel.save(OpenStudio.OpenStudioUtilitiesCore.toPath(opsFilePath + "2.osm"), true); //save

Possible Solution

I couldn't find why it doesn't work for this model.

But I am able to use the VersionTranslator as an alternative.

  // works
var opsFilePath = "in_IB.osm";

var vt = new OpenStudio.VersionTranslator();
vt.setAllowNewerVersions(false);
var optionalModel = vt.loadModel(OpenStudio.OpenStudioUtilitiesCore.toPath(opsFilePath));
var osModel = optionalModel.get();
var done = osModel.save(OpenStudio.OpenStudioUtilitiesCore.toPath(opsFilePath + "2.osm"), true); //save

Environment

  • Platform: Windows 11
  • Version of OpenStudio: 3.5.1 (CSharp)
@MingboPeng MingboPeng added the Triage Issue needs to be assessed and labeled, further information on reported might be needed label Jun 13, 2023
@eringold
Copy link
Contributor

eringold commented Jun 13, 2023

Looks like Model.load(path) needs to find a workflowJSON in the osm's companion folder:

OpenStudio/src/model/Model.cpp

Lines 1876 to 1885 in 872300d

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

@jmarrec
Copy link
Collaborator

jmarrec commented Jun 15, 2023

This is related to #4692, and more likely a duplicate issue.

Model.load plain assumes your model's version is the same as the OS SDK version you use.

Never use Model.load basically until #4692 is addressed.

@MingboPeng
Copy link
Contributor Author

"Model.load plain assumes your model's version is the same as the OS SDK version you use."
Hi @jmarrec not sure if this is really the source of the issue. Because we use to have our own installer that packs a single version of the OpenStudio. So this osm file is generated by the same version of SDK.

"Looks like Model.load(path) needs to find a workflowJSON in the osm's companion folder:"
Hi @eringold This seems unlikely the case, because the same workflow works for some models and some are not. If it is looking for a workflowJson in the same folder, it should not work for all models. Please let me know if I missed anything.

@jmarrec
Copy link
Collaborator

jmarrec commented Jun 19, 2023

@MingboPeng

require '/usr/local/openstudio-3.5.1/Ruby/openstudio'
OpenStudio::openStudioLongVersion
m = OpenStudio::Model::Model.load('in_IB.osm').get
m.objects.size
=> 0
OpenStudio::Logger.instance.standardOutLogger.setLogLevel(OpenStudio::Trace)
m = OpenStudio::Model::Model.load('in_IB.osm').get
[...]
[utilities.idf.Workspace] <-3> Adding object with handle {fd3f404f-7cb4-46ca-aa91-347e4a3f9c73}
[utilities.idf.Workspace] <-1> Unable to add objects to Workspace. The validity report is: 
The collection is INVALID at strictness level 'Draft', because of the errors:
Object     level data error of type NameConflict      .
Error pertains to an object of type 'OS:BuildingStory', named 'First Floor'.
Additional information about the error type: two objects of the same type or with overlapping references also have the same name.
[utilities.idf.Workspace] <-3> Adding object with handle {de69c307-cf38-464d-b809-8214476d1363}
=> #<OpenStudio::Model::Model:0x0000557692385820 @__swigtype__="_p_openstudio__model__Model">

You do have two objects named First Floor. Lines 2813 and 3089

OS:BuildingStory,
  {f33233f1-cff3-466c-bd15-913b65fa6d2b}, !- Handle
  First Floor ,                           !- Name
  ,                                       !- Nominal Z Coordinate {m}
  ,                                       !- Nominal Floor to Floor Height {m}
  ,                                       !- Default Construction Set Name
  ,                                       !- Default Schedule Set Name
  ;                                       !- Group Rendering Name

[...]

OS:BuildingStory,
  {c5315607-9d20-4653-a3e0-68003d6da1a6}, !- Handle
  First Floor,                            !- Name
  ,                                       !- Nominal Z Coordinate {m}
  ,                                       !- Nominal Floor to Floor Height {m}
  ,                                       !- Default Construction Set Name
  ,                                       !- Default Schedule Set Name
  ;                                       !- Group Rendering Name

@jmarrec
Copy link
Collaborator

jmarrec commented Jun 19, 2023

When you use VT,

[utilities.idf.Workspace] <-1> Renamed Object of type 'OS:BuildingStory' and named 'First Floor' to 'First Floor 1' to avoid a name conflict upon WorkspaceObject addition.

@jmarrec
Copy link
Collaborator

jmarrec commented Jun 19, 2023

I'm going to close this one as it's an error in the model itself. The Model::load difference with VT is captured in #4692

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution - Works As Expected Triage Issue needs to be assessed and labeled, further information on reported might be needed
Projects
None yet
Development

No branches or pull requests

3 participants