Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BuildResidentialHPXML/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3648,14 +3648,14 @@ def run(model, runner, user_arguments)
# Create HPXML file
hpxml_path = args[:hpxml_path]
unless (Pathname.new hpxml_path).absolute?
hpxml_path = File.expand_path(hpxml_path)
hpxml_path = File.join(runner.workflow.absoluteRootDir.to_s, hpxml_path)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end

# Existing HPXML File
if not args[:existing_hpxml_path].nil?
existing_hpxml_path = args[:existing_hpxml_path]
unless (Pathname.new existing_hpxml_path).absolute?
existing_hpxml_path = File.expand_path(existing_hpxml_path)
existing_hpxml_path = File.join(runner.workflow.absoluteRootDir.to_s, existing_hpxml_path)
end
end

Expand Down
4 changes: 2 additions & 2 deletions BuildResidentialScheduleFile/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ def run(model, runner, user_arguments)

hpxml_path = args[:hpxml_path]
unless (Pathname.new hpxml_path).absolute?
hpxml_path = File.expand_path(hpxml_path)
hpxml_path = File.join(runner.workflow.absoluteRootDir.to_s, hpxml_path)
end
unless File.exist?(hpxml_path) && hpxml_path.downcase.end_with?('.xml')
fail "'#{hpxml_path}' does not exist or is not an .xml file."
end

hpxml_output_path = args[:hpxml_output_path]
unless (Pathname.new hpxml_output_path).absolute?
hpxml_output_path = File.expand_path(hpxml_output_path)
hpxml_output_path = File.join(runner.workflow.absoluteRootDir.to_s, hpxml_output_path)
end
args[:hpxml_output_path] = hpxml_output_path

Expand Down
8 changes: 4 additions & 4 deletions HPXMLtoOpenStudio/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def run(model, runner, user_arguments)
Model.reset(runner, model)

args = runner.getArgumentValues(arguments(model), user_arguments)
set_file_paths(args)
set_file_paths(runner, args)

begin
hpxml = create_hpxml_object(runner, args)
Expand Down Expand Up @@ -177,16 +177,16 @@ def run(model, runner, user_arguments)
#
# @param args [Hash] Map of :argument_name => value
# @return [nil]
def set_file_paths(args)
def set_file_paths(runner, args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to method documentation above

if not (Pathname.new args[:hpxml_path]).absolute?
args[:hpxml_path] = File.expand_path(args[:hpxml_path])
args[:hpxml_path] = File.join(runner.workflow.absoluteRootDir.to_s, args[:hpxml_path])
end
if not File.exist?(args[:hpxml_path]) && args[:hpxml_path].downcase.end_with?('.xml')
fail "'#{args[:hpxml_path]}' does not exist or is not an .xml file."
end

if not (Pathname.new args[:output_dir]).absolute?
args[:output_dir] = File.expand_path(args[:output_dir])
args[:output_dir] = File.join(runner.workflow.absoluteRootDir.to_s, args[:output_dir])
end

if File.extname(args[:annual_output_file_name]).length == 0
Expand Down
2 changes: 1 addition & 1 deletion HPXMLtoOpenStudio/resources/meta_measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def apply_measures(measures_dir, measures, runner, model, show_measure_calls = t
if not osw_out.nil?
# Create a workflow based on the measures we're going to call. Convenient for debugging.
workflowJSON = OpenStudio::WorkflowJSON.new
workflowJSON.setOswPath(File.expand_path("../#{osw_out}"))
workflowJSON.setOswPath(File.join(runner.workflow.absoluteRootDir.to_s, osw_out))
workflowJSON.addMeasurePath('measures')
workflowJSON.addMeasurePath('resources/hpxml-measures')
steps = OpenStudio::WorkflowStepVector.new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"heating_system_heating_capacity": 36000.0,
"heating_system_heating_efficiency": 0.92,
"heating_system_type": "Furnace",
"hpxml_path": "../built.xml",
"hpxml_path": "run/built.xml",
"hvac_control_cooling_weekday_setpoint": "78",
"hvac_control_cooling_weekend_setpoint": "78",
"hvac_control_heating_weekday_setpoint": "68",
Expand Down Expand Up @@ -82,16 +82,16 @@
},
{
"arguments": {
"hpxml_path": "../built.xml",
"hpxml_path": "run/built.xml",
"output_csv_path": "stochastic.csv",
"hpxml_output_path": "../built-stochastic-schedules.xml"
"hpxml_output_path": "run/built-stochastic-schedules.xml"
},
"measure_dir_name": "BuildResidentialScheduleFile"
},
{
"arguments": {
"hpxml_path": "../built-stochastic-schedules.xml",
"output_dir": "..",
"hpxml_path": "run/built-stochastic-schedules.xml",
"output_dir": "run",
"debug": false,
"add_component_loads": false,
"skip_validation": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"steps": [
{
"arguments": {
"hpxml_path": "../../sample_files/base.xml",
"hpxml_path": "sample_files/base.xml",
"output_csv_path": "stochastic.csv",
"hpxml_output_path": "../built-stochastic-schedules.xml",
"hpxml_output_path": "run/built-stochastic-schedules.xml",
"schedules_column_names": "cooking_range, dishwasher, hot_water_dishwasher, clothes_washer, hot_water_clothes_washer, clothes_dryer, hot_water_fixtures"
},
"measure_dir_name": "BuildResidentialScheduleFile"
},
{
"arguments": {
"hpxml_path": "../built-stochastic-schedules.xml",
"output_dir": "..",
"hpxml_path": "run/built-stochastic-schedules.xml",
"output_dir": "run",
"debug": false,
"add_component_loads": false,
"skip_validation": false
Expand Down
8 changes: 4 additions & 4 deletions workflow/template-run-hpxml-with-stochastic-occupancy.osw
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"steps": [
{
"arguments": {
"hpxml_path": "../../sample_files/base.xml",
"hpxml_path": "sample_files/base.xml",
"output_csv_path": "stochastic.csv",
"hpxml_output_path": "../built-stochastic-schedules.xml"
"hpxml_output_path": "run/built-stochastic-schedules.xml"
},
"measure_dir_name": "BuildResidentialScheduleFile"
},
{
"arguments": {
"hpxml_path": "../built-stochastic-schedules.xml",
"output_dir": "..",
"hpxml_path": "run/built-stochastic-schedules.xml",
"output_dir": "run",
"debug": false,
"add_component_loads": false,
"skip_validation": false
Expand Down
4 changes: 2 additions & 2 deletions workflow/template-run-hpxml.osw
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"steps": [
{
"arguments": {
"hpxml_path": "../../sample_files/base.xml",
"output_dir": "..",
"hpxml_path": "sample_files/base.xml",
"output_dir": "run",
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree that the hpxml_path makes much more sense like this.

Can output_dir be anything or does it have to be "run"?

Copy link
Collaborator Author

@rajeee rajeee Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has to match the "run_directory" argument above (in line 2). If run_directory is not specified, it defaults to "run" and output_dir has to be "run" in that case. I think we should just remove this argument from the measure. We can find out the run_directory using runner.workflow.absoluteRunDir.to_s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we should just remove this argument from the measure.

We can't remove it, it is one of the most commonly used arguments (e.g. run_simulation.rb -x foo.xml -o my_output_dir).

Copy link
Collaborator Author

@rajeee rajeee Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can still allow run_simulation.rb to have output dir. Looks like the current behavior is that it creates a my_output_dir/run folder and places the results there. We can replicate this without needing the output_dir parameter for the measure.

"debug": false,
"add_component_loads": false,
"skip_validation": false,
Expand Down