NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
494 stars 188 forks source link

C++ CLI: unable to update ReportingMeasure with 3.7.0-rc3 #5045

Closed jmarrec closed 9 months ago

jmarrec commented 9 months ago

Issue overview

Reported by @shorowit

I'm using the OS rc3 and it's giving an error when I try to update a reporting measure:

Current Behavior

shorowit@SHOROWIT-36132S:/mnt/c/git/openstudio-hpxml$ ~/OpenStudio-3.7.0-rc3+37087fd612-Ubuntu-20.04-x86_64/usr/local/openstudio-3.7.0-rc3/bin/openstudio measure -u ReportUtilityBills/
Attempting to load measure 'ReportUtilityBills/'
Successfully loaded measure 'ReportUtilityBills/'
Changes detected, updating 'ReportUtilityBills/'
className=ReportUtilityBills
measureType=ReportingMeasure
numArgs=-1
SWIG director method error. NameError: undefined local variable or method `e' for #<OpenStudio::Measure::RubyMeasureInfoBinding:0x00007fffdd27ccb8>

Traceback (most recent call last):
eval:211:in `rescue in renderFile'
eval:205:in `renderFile'

Expected Behavior

It should work, like the classic subcommand does

Steps to Reproduce

You can presumably reproduce it by cloning https://github.com/NREL/OpenStudio-HPXML/tree/os370rc2 (I get the same error if I try the other reporting measure in that repo -- ReportSimulationOutput)

Possible Solution

Details

Environment

Some additional details about your environment for this issue (if relevant):

Context

jmarrec commented 9 months ago

https://github.com/NREL/OpenStudio/blob/37087fd6127a8a50077d956192dffb373f778b04/ruby/bindings/InitRubyBindings.cpp#L410

Should be rescue => e. Still fails to produce an ERB though, tracking it down...

jmarrec commented 9 months ago

Ok I see, I removed the begin / rescue so I could see the error. We should do that by default, but I don't want to break the old CLI.

SWIG director method error. NoMethodError: undefined method `join' for nil:NilClass

Traceback (most recent call last):
(erb):25:in `block in renderFile'
(erb):13:in `each'
(erb):13:in `renderFile'
:/ruby/2.7.0/erb.rb:905:in `eval'
:/ruby/2.7.0/erb.rb:905:in `result'
eval:209:in `renderFile'

Pretty sure this is happening here: https://github.com/NREL/OpenStudio-HPXML/blob/56d57315544662843cdd46de72f61d684ae8fa1f/ReportUtilityBills/README.md.erb#L24-L26

<% if argument[:type] == "Choice" %>
- **Choices:** `<%= argument[:choice_values].join("`, `") %>`
<% end %>

FWIW, the BCL template if our repo does it differently, so that's probably why I haven't caught this one before.

https://github.com/NREL/OpenStudio/blob/37087fd6127a8a50077d956192dffb373f778b04/src/utilities/bcl/templates/common/README.md.erb#L29-L31

jmarrec commented 9 months ago

TL;DR: the winner is: A TYPO!

https://github.com/NREL/OpenStudio/blob/37087fd6127a8a50077d956192dffb373f778b04/src/measure/OSArgument.cpp#L1125