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"
}