Fix set string index 1 for ModelObjects#4211
Conversation
| ASSERT_TRUE(space2); | ||
| auto surfaces2 = space2->surfaces(); | ||
| auto floorSurfaceIt2 = std::find_if(std::begin(surfaces), std::end(surfaces), [](const auto& surface) { return surface.surfaceType() == "Floor"; }); | ||
| auto floorSurfaceIt2 = std::find_if(std::begin(surfaces2), std::end(surfaces2), [](const auto& surface) { return surface.surfaceType() == "Floor"; }); |
There was a problem hiding this comment.
This is a bug in this test unrelated to this pull request
| } | ||
|
|
||
| // regular field -- name or data | ||
| if ((index == 0) && (iddObject().hasNameField())) { |
There was a problem hiding this comment.
Could add additional check if this field is a handle here and route that to setName as well to preserve existing behavior.
|
|
||
| // check collection NameConflict | ||
| if (!uniquelyIdentifiableByName()) { | ||
| if (!newName.empty() && iddObject().isRequiredField(*index) && !uniquelyIdentifiableByName()) { |
There was a problem hiding this comment.
This change is mostly to support OutputMeter having an empty name on construction. If we change to OutputMeter Meter Name we can revert this line.
There was a problem hiding this comment.
This change created #4247
OS:Coil:Heating:Electric does not have \required-field on its Name field, and now unicity of name isn't enforced anymore.
|
|
||
| // do not set if would violate field NullAndRequired | ||
| if ((level > StrictnessLevel::Draft) && newName.empty() && iddObject().isRequiredField(*index)) { | ||
| if ((level >= StrictnessLevel::Draft) && newName.empty() && iddObject().isRequiredField(*index)) { |
There was a problem hiding this comment.
I thought this was enforced at Draft strictness, we don't use Final strictness for anything that I know of
| == newSurface.construction().get().cast<LayeredConstruction>().layers()); | ||
| } | ||
|
|
||
| TEST_F(ModelFixture, ModelObject_SetString) { |
There was a problem hiding this comment.
This is a new test to verify the bug fix
There was a problem hiding this comment.
Merge from #4206 adds a very similar one for at Workspace level, I think both are relevant and I don't see a problem testing twice.
|
Looks like the Python bindings might have issues accessing PyPi, possibly due to not allowing access to secrets on a pull request from a fork? https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/ BTW, it is so cool to be able to see the build output in GitHub Actions! |
…ames to empty string because it is wrongly assuming that the name string for WorkspaceObject's is always index 0. For ModelObject's the index is 1 because handle is 0. Changing this results in some breakage of OutputMeter which uses/abuses the name field to be the E+ meter name. We may want to change OutputMeter's `Name` field to be `Meter Name`. That seems clear to me but it might break any measure that depends on `meter.name` to give the E+ name. In this commit I kept OutputMeter's `Name` field but marked it as not required (since it is empty) when a meter is first constructed. This might not be ideal though, we may want to change the field to `Meter Name` to prevent Workspace naming logic from introducing further bugs. Finally, the Workspace naming logic was protecting the handle field of ModelObjects. By moving this protection to the name field we may be losing some protection of the handle field. We may want to add functionality to consider both handle and name fields if they exist? As with any change to this Workspace level stuff a good review is required.
141d728 to
53bfdb7
Compare
| if (iddObject().hasNameField()) { | ||
| boost::optional<unsigned> nameIndex = iddObject().nameFieldIndex(); | ||
| if (nameIndex && (*nameIndex == index)) { | ||
| return setName(value, checkValidity).has_value(); | ||
| } |
There was a problem hiding this comment.
| if (iddObject().hasNameField()) { | |
| boost::optional<unsigned> nameIndex = iddObject().nameFieldIndex(); | |
| if (nameIndex && (*nameIndex == index)) { | |
| return setName(value, checkValidity).has_value(); | |
| } | |
| // regular field -- name or data | |
| if ((iddObject().hasNameField()) && (index == iddObject().nameFieldIndex().get())) { | |
| return setName(value, checkValidity).has_value(); | |
| } // name |
if hasNameField, I don't think you also need to check if nameIndex exits.
The repo/fork is the one that should have the proper TESTPYPI_TOKEN, so it's expected that it fails. don't worry about it. |
|
oops, seems like this never got built by CI and didn't notice it broke https://github.com/NREL/OpenStudio/blob/3650208f2f09905ba612ea122737035bc6577f56/src/utilities/idf/Test/WorkspaceObject_GTest.cpp#L578-L581 |
Pull request overview
Please read OpenStudio Pull Requests to better understand the OpenStudio Pull Request protocol.
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
src/openstudio_lib/library/OpenStudioPolicy.xml)Labels:
IDDChangeAPIChangePull Request - Ready for CIso that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.