0

Creating workflow.osw file in Python

Anyone have any tips for creating workflow.osw files programmatically in Python? I have tried the following, but running into various issues:

1) I used this Notebook for inspiration, but am running into an issue with the following script, with the resulting .osw file being blank. I believe the issue is caused by using .append(), but am not 100% sure:

measure_steps=[]
os_results = openstudio.MeasureStep("measures/AddMonthlyJSONUtilityData")
os_results.setArgument("json", "../../../data/electric.json")
os_results.setArgument("variable_name", "Electricity Bill")
os_results.setArgument("set_runperiod", True)
measure_steps.append(os_results)
'# Set the measure steps in the OSW object
measureType = openstudio.MeasureType('ModelMeasure')
osw.setMeasureSteps(measureType,measure_steps)
print(osw)
{
  "created_at" : "20240416T135449Z",
  "steps" : []
}

2) I then used some of the script from this open issue in Github which somewhat works. The osw file results in the arguments, but I had to adjust the setWorkflowSteps() to only include the measure steps because the function only takes one argument. This makes me concerned that I am not defining the MeasureType there may be another issue further down the line.

wf = openstudio.WorkflowJSON()
measure = openstudio.MeasureStep('Measure1')
measure.setArgument('r_value', '45')
stepVector = openstudio.WorkflowStepVector([measure])
measureType=openstudio.MeasureType("ModelMeasure")
wf.setWorkflowSteps(stepVector)
print(wf)
{
  "created_at" : "20240416T155242Z",
  "steps" : 
  [
     {
        "arguments" : 
        {
           "r_value" : "45"
        },
        "measure_dir_name" : "Measure1"
     }
  ],
  "updated_at" : "20240416T155242Z"
}
codygillmore's avatar
21
codygillmore
asked 2024-04-16 14:13:36 -0500
Aaron Boranian's avatar
14.1k
Aaron Boranian
updated 2024-04-19 09:18:38 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

I think method 2 above works fine. I see the Comstock team is using the same methodology in their analysis for anyone that comes across this: https://github.com/NREL/ComStock/blob...

codygillmore's avatar
21
codygillmore
answered 2024-04-19 06:48:01 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments