Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
6

OpenStudio measure interactive debugging

asked 2016-12-12 13:13:48 -0600

antonszilasi's avatar

updated 2016-12-21 12:12:03 -0600

I am writing my OpenStudio measures and then testing them with some test code like shown in the writing openstudio measures guide.

Everything works fine but the time that the code takes to run can be up to 40 seconds, this means that debugging or testing can take a lot longer than it should.

Is it possible to set up the tests in an interactive environment where code snippets can be run one at a time? So that I only need to run the code that I want to test. Is this what Ruby mine does?

Has anyone done this? Any advice would be most appreciated!

edit retag flag offensive close merge delete

Comments

40 seconds sounds like a long time for a measure to run unless it is a reporting measure that runs EnergyPlus or is doing sizing runs. If it is a reporting measure, you can configure the test to save the simulation results so the test can be re-run quickly. We do have a few model measures that can take that longer than a few seconds but only if they are doing more complex operations or are tested on very large models.

David Goldwasser's avatar David Goldwasser  ( 2016-12-12 16:30:38 -0600 )edit

@DavidGoldWasser it is a modified form of the space and construction wizard and it is most certainly taking more than 40 seconds, isn't this to be expected when you are modifying an existing osm model? I've posted the code here:

and the test file can be seen here

antonszilasi's avatar antonszilasi  ( 2016-12-28 11:45:32 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
6

answered 2016-12-12 15:36:58 -0600

you could always run your code bit by bit in interactive ruby. Or save parts of it to a ruby script and run that from terminal. For interactive ruby, irb in the command terminal will take you into ruby. Then:

require 'openstudio'

# Helper to load a model in one line
def osload(path)
  translator = OpenStudio::OSVersion::VersionTranslator.new
  ospath = OpenStudio::Path.new(path)
  model = translator.loadModel(ospath)
  if model.empty?
      raise "Path '#{path}' is not a valid path to an OpenStudio Model.  Did you remember to use backlashes / instead of forward slashes \ ?"
  else
      model = model.get
  end  
  return model
end

load_path = "C:/Users/me/path/to/your/model/with/backslashes.osm"
model = osload(load_path)

and then do whatever modeling you want

edit flag offensive delete link more

Comments

2

This seems like a good place to plug UnmetHours' resident karma kingpin @Julien Marrec's custom OpenStudio Powershell profile (which I haven't used but looks really handy for this stuff).

ericringold's avatar ericringold  ( 2016-12-12 15:52:40 -0600 )edit

nice! looking forward to trying that out.

mdahlhausen's avatar mdahlhausen  ( 2016-12-12 16:24:13 -0600 )edit

Thanks for the plug @Eric Ringold. If you guys try it and hit some roadblocks, don't hesitate to ping me directly or open a github issue.

Julien Marrec's avatar Julien Marrec  ( 2016-12-21 12:11:41 -0600 )edit

@mdahlhausen

it works thanks! a note however make sure you declare model as a global variable otherwise it doesnt show up in the ruby interactive console so change model to $model

antonszilasi's avatar antonszilasi  ( 2016-12-28 14:03:11 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

4 followers

Stats

Asked: 2016-12-12 13:13:48 -0600

Seen: 481 times

Last updated: Dec 21 '16