4

OpenStudio Reporting with Ruby Scripts

I am using the RunAllOSMs.rb Ruby script from the example script files to run an OpenStudio file from the command line. When I do this, the OpenStuido post process Report.xml file is generated, however when I open up OpenStudio after the simulation completes, the OpenStudio Report is not visible. Is there a way that the OpenStudio Report can be shown after running an OSM from the command line?

dpud12's avatar
1.3k
dpud12
asked 2015-03-09 09:02:04 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2017-08-05 13:27:26 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

3

Good question. The report you see out of the OpenStudio application after a simulation is just a reporting measure that we put in the workflow even if the user doesn't request it. That does not happen with the RunAllOSMs example.

If you want to see that report then you can add code for that measure to be run. If you look at the ruby script in the "tests" folder of the measure you an see what that code looks like. Here is a link to the reporting measures on BCL. The default one is named "Standard Reports".

Here is part of the code, it should result in an HTML file. For reference below is the code from the test.

def test_StandardReports

  assert(File.exist?(modelPath()))
  assert(File.exist?(sqlPath()))

  # create an instance of the measure
  measure = StandardReports.new

  # create an instance of a runner
  runner = OpenStudio::Ruleset::OSRunner.new

  # get arguments and test that they are what we are expecting
  arguments = measure.arguments()
  assert_equal(0, arguments.size)

  # set up runner, this will happen automatically when measure is run in PAT
  runner.setLastOpenStudioModelPath(OpenStudio::Path.new(modelPath))
  runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sqlPath))

  # set argument values to good values and run the measure
  argument_map = OpenStudio::Ruleset::OSArgumentMap.new
  measure.run(runner, argument_map)
  result = runner.result
  show_output(result)
  assert(result.value.valueName == "Success")
  assert(result.warnings.size == 0)
  #assert(result.info.size == 1)

  assert(File.exist?(reportPath()))

end
David Goldwasser's avatar
20.4k
David Goldwasser
answered 2015-03-09 09:59:28 -0500
edit flag offensive 0 remove flag delete link

Comments

We really need to clean up the examples around this. Basically, you want to add the reporting measure to the end of the workflow.

This example shows how to use a RubyJobBuilder to add a measure to a Workflow.

You can get the location of the built in reporting measure with this.

macumber's avatar macumber (2015-03-09 10:49:36 -0500) edit

@David Thanks for your help, since the Standard Report test file runs a simulation if the sql file does not yet exist, I was able to eliminate the RunAllOSM code from the workflow entirely (since I am only running one model). @macumber I will try to use the JobBuilder in the next iteration, thanks for the insight.

dpud12's avatar dpud12 (2015-03-10 09:11:58 -0500) edit

Also, FYI there is a typo in the RunAllOSMs code, line 65 should read:

filenames = Dir.glob(osmDir.to_s + "/**/*.osm")

instead of

filenames = Dir.glob(osmDir.to_s + "./**/*.osm")
dpud12's avatar dpud12 (2015-03-10 09:14:31 -0500) edit
add a comment see more comments
0

You can open thereport.html files in any web browser.

aparker's avatar
8.2k
aparker
answered 2015-03-09 09:58:16 -0500
edit flag offensive 0 remove flag delete link

Comments

@aparker, I think the example he is using pre-dates measures and even OpenStudio app, I don't think it makes the report.html.

David Goldwasser's avatar David Goldwasser (2015-03-09 10:15:55 -0500) edit

Oddly enough, the report.html file only opens for me on Google Chrome, not Internet Explorer

dpud12's avatar dpud12 (2015-03-10 09:16:35 -0500) edit
add a comment see more comments