openstudio-workflow 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -77
- data/README.md +67 -93
- data/Rakefile +36 -36
- data/lib/openstudio-workflow.rb +65 -65
- data/lib/openstudio/workflow/adapters/input/local.rb +311 -324
- data/lib/openstudio/workflow/adapters/output/local.rb +158 -161
- data/lib/openstudio/workflow/adapters/output/socket.rb +106 -107
- data/lib/openstudio/workflow/adapters/output/web.rb +82 -82
- data/lib/openstudio/workflow/adapters/output_adapter.rb +163 -163
- data/lib/openstudio/workflow/job.rb +57 -57
- data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
- data/lib/openstudio/workflow/jobs/run_energyplus.rb +70 -70
- data/lib/openstudio/workflow/jobs/run_ep_measures.rb +73 -73
- data/lib/openstudio/workflow/jobs/run_initialization.rb +203 -203
- data/lib/openstudio/workflow/jobs/run_os_measures.rb +89 -89
- data/lib/openstudio/workflow/jobs/run_postprocess.rb +73 -73
- data/lib/openstudio/workflow/jobs/run_preprocess.rb +104 -104
- data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +118 -118
- data/lib/openstudio/workflow/jobs/run_translation.rb +84 -84
- data/lib/openstudio/workflow/multi_delegator.rb +62 -62
- data/lib/openstudio/workflow/registry.rb +172 -172
- data/lib/openstudio/workflow/run.rb +342 -328
- data/lib/openstudio/workflow/time_logger.rb +96 -96
- data/lib/openstudio/workflow/util.rb +49 -49
- data/lib/openstudio/workflow/util/energyplus.rb +575 -605
- data/lib/openstudio/workflow/util/io.rb +68 -68
- data/lib/openstudio/workflow/util/measure.rb +658 -650
- data/lib/openstudio/workflow/util/model.rb +151 -151
- data/lib/openstudio/workflow/util/post_process.rb +235 -238
- data/lib/openstudio/workflow/util/weather_file.rb +143 -143
- data/lib/openstudio/workflow/version.rb +40 -40
- data/lib/openstudio/workflow_json.rb +475 -476
- data/lib/openstudio/workflow_runner.rb +263 -268
- metadata +24 -24
@@ -1,268 +1,263 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
3
|
-
# All rights reserved.
|
4
|
-
# Redistribution and use in source and binary forms, with or without
|
5
|
-
# modification, are permitted provided that the following conditions are met:
|
6
|
-
#
|
7
|
-
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer.
|
9
|
-
#
|
10
|
-
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
# this list of conditions and the following disclaimer in the documentation
|
12
|
-
# and/or other materials provided with the distribution.
|
13
|
-
#
|
14
|
-
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
-
# may be used to endorse or promote products derived from this software without
|
16
|
-
# specific prior written permission from the respective party.
|
17
|
-
#
|
18
|
-
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
-
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
-
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
-
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
-
#
|
23
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
35
|
-
|
36
|
-
require_relative 'workflow_json'
|
37
|
-
|
38
|
-
# Extend OS Runner to persist measure information throughout the workflow
|
39
|
-
# Provide shims to support OpenStudio 2.X functionality in OpenStudio 1.X
|
40
|
-
class WorkflowRunner < OpenStudio::Ruleset::OSRunner
|
41
|
-
def initialize(multi_logger, workflow_json, openstudio_2)
|
42
|
-
@multi_logger = multi_logger
|
43
|
-
@workflow_json = workflow_json
|
44
|
-
@openstudio_2 = openstudio_2
|
45
|
-
@datapoint = nil
|
46
|
-
@analysis = nil
|
47
|
-
@halted = false
|
48
|
-
@use_os_halted = OpenStudio::Ruleset::OSRunner.method_defined?(:halted)
|
49
|
-
|
50
|
-
begin
|
51
|
-
# OpenStudio 2.X
|
52
|
-
super(@workflow_json)
|
53
|
-
rescue Exception => e
|
54
|
-
# OpenStudio 1.X
|
55
|
-
@workflow = workflow_json
|
56
|
-
@units_preference = 'SI'
|
57
|
-
@language_preference = 'EN'
|
58
|
-
super()
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def timeString
|
63
|
-
::Time.now.utc.strftime(
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
def analysis
|
75
|
-
@analysis
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
current_step =
|
142
|
-
|
143
|
-
if current_step.
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
current_step.step[:result][:
|
164
|
-
os_result.
|
165
|
-
current_step.step[:result][:
|
166
|
-
end
|
167
|
-
|
168
|
-
current_step.step[:result][:
|
169
|
-
os_result.
|
170
|
-
current_step.step[:result][:
|
171
|
-
end
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
current_step.step[:result][:
|
176
|
-
end
|
177
|
-
|
178
|
-
unless os_result.
|
179
|
-
current_step.step[:result][:
|
180
|
-
current_step.step[:result][:
|
181
|
-
end
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
@
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
def halted
|
265
|
-
return @halted unless @use_os_halted
|
266
|
-
super
|
267
|
-
end
|
268
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
|
+
# All rights reserved.
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
#
|
10
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
#
|
14
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
+
# may be used to endorse or promote products derived from this software without
|
16
|
+
# specific prior written permission from the respective party.
|
17
|
+
#
|
18
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
+
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
# *******************************************************************************
|
35
|
+
|
36
|
+
require_relative 'workflow_json'
|
37
|
+
|
38
|
+
# Extend OS Runner to persist measure information throughout the workflow
|
39
|
+
# Provide shims to support OpenStudio 2.X functionality in OpenStudio 1.X
|
40
|
+
class WorkflowRunner < OpenStudio::Ruleset::OSRunner
|
41
|
+
def initialize(multi_logger, workflow_json, openstudio_2)
|
42
|
+
@multi_logger = multi_logger
|
43
|
+
@workflow_json = workflow_json
|
44
|
+
@openstudio_2 = openstudio_2
|
45
|
+
@datapoint = nil
|
46
|
+
@analysis = nil
|
47
|
+
@halted = false
|
48
|
+
@use_os_halted = OpenStudio::Ruleset::OSRunner.method_defined?(:halted)
|
49
|
+
|
50
|
+
begin
|
51
|
+
# OpenStudio 2.X
|
52
|
+
super(@workflow_json)
|
53
|
+
rescue Exception => e
|
54
|
+
# OpenStudio 1.X
|
55
|
+
@workflow = workflow_json
|
56
|
+
@units_preference = 'SI'
|
57
|
+
@language_preference = 'EN'
|
58
|
+
super()
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def timeString
|
63
|
+
::Time.now.utc.strftime('%Y%m%dT%H%M%SZ')
|
64
|
+
end
|
65
|
+
|
66
|
+
attr_reader :datapoint
|
67
|
+
|
68
|
+
def setDatapoint(datapoint)
|
69
|
+
@datapoint = datapoint
|
70
|
+
end
|
71
|
+
|
72
|
+
attr_reader :analysis
|
73
|
+
|
74
|
+
def setAnalysis(analysis)
|
75
|
+
@analysis = analysis
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns the workflow currently being run. New in OS 2.0.
|
79
|
+
# WorkflowJSON workflow() const;
|
80
|
+
def workflow
|
81
|
+
if @openstudio_2
|
82
|
+
super
|
83
|
+
else
|
84
|
+
@workflow
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns preferred unit system, either 'IP' or 'SI'. New in OS 2.0. */
|
89
|
+
# std::string unitsPreference() const;
|
90
|
+
def unitsPreference
|
91
|
+
if @openstudio_2
|
92
|
+
super
|
93
|
+
else
|
94
|
+
@units_preference
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Returns preferred language, e.g. 'en' or 'fr'. New in OS 2.0. */
|
99
|
+
# std::string languagePreference() const;
|
100
|
+
def languagePreference
|
101
|
+
if @openstudio_2
|
102
|
+
super
|
103
|
+
else
|
104
|
+
@language_preference
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# called right when each measure is run
|
109
|
+
# only called in OpenStudio 1.X
|
110
|
+
# virtual void prepareForUserScriptRun(const UserScript& userScript);
|
111
|
+
def prepareForUserScriptRun(userScript)
|
112
|
+
if @openstudio_2
|
113
|
+
prepareForMeasureRun(userScript)
|
114
|
+
else
|
115
|
+
current_step = @workflow.currentStep
|
116
|
+
|
117
|
+
unless current_step.empty?
|
118
|
+
current_step.get.step[:result] = {}
|
119
|
+
current_step.get.step[:result][:started_at] = timeString
|
120
|
+
end
|
121
|
+
|
122
|
+
# TODO: capture std out and err
|
123
|
+
|
124
|
+
# TODO: get initial list of files
|
125
|
+
|
126
|
+
super
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def result
|
131
|
+
if @openstudio_2
|
132
|
+
super
|
133
|
+
else
|
134
|
+
os_result = super
|
135
|
+
|
136
|
+
current_step = @workflow.currentStep
|
137
|
+
|
138
|
+
if current_step.empty?
|
139
|
+
raise 'Cannot find current_step'
|
140
|
+
end
|
141
|
+
current_step = current_step.get
|
142
|
+
|
143
|
+
if current_step.step[:result].nil?
|
144
|
+
# skipped, prepareForUserScriptRun was not called
|
145
|
+
current_step.step[:result] = {}
|
146
|
+
current_step.step[:result][:started_at] = timeString
|
147
|
+
current_step.step[:result][:step_result] = 'Skip'
|
148
|
+
else
|
149
|
+
current_step.step[:result][:step_result] = os_result.value.valueName
|
150
|
+
end
|
151
|
+
|
152
|
+
current_step.step[:result][:completed_at] = timeString
|
153
|
+
|
154
|
+
# TODO: restore stdout and stderr
|
155
|
+
|
156
|
+
# TODO: check for created files
|
157
|
+
|
158
|
+
current_step.step[:result][:step_errors] = []
|
159
|
+
os_result.errors.each do |error|
|
160
|
+
current_step.step[:result][:step_errors] << error.logMessage
|
161
|
+
end
|
162
|
+
|
163
|
+
current_step.step[:result][:step_warnings] = []
|
164
|
+
os_result.warnings.each do |warning|
|
165
|
+
current_step.step[:result][:step_warnings] << warning.logMessage
|
166
|
+
end
|
167
|
+
|
168
|
+
current_step.step[:result][:step_info] = []
|
169
|
+
os_result.info.each do |info|
|
170
|
+
current_step.step[:result][:step_info] << info.logMessage
|
171
|
+
end
|
172
|
+
|
173
|
+
unless os_result.initialCondition.empty?
|
174
|
+
current_step.step[:result][:initial_condition] = os_result.initialCondition.get.logMessage
|
175
|
+
current_step.step[:result][:step_initial_condition] = os_result.initialCondition.get.logMessage
|
176
|
+
end
|
177
|
+
|
178
|
+
unless os_result.finalCondition.empty?
|
179
|
+
current_step.step[:result][:final_condition] = os_result.finalCondition.get.logMessage
|
180
|
+
current_step.step[:result][:step_final_condition] = os_result.finalCondition.get.logMessage
|
181
|
+
end
|
182
|
+
|
183
|
+
current_step.step[:result][:step_values] = []
|
184
|
+
os_result.attributes.each do |attribute|
|
185
|
+
result = nil
|
186
|
+
if attribute.valueType == 'Boolean'.to_AttributeValueType
|
187
|
+
result = { name: attribute.name, value: attribute.valueAsBoolean, type: 'Boolean' }
|
188
|
+
elsif attribute.valueType == 'Double'.to_AttributeValueType
|
189
|
+
result = { name: attribute.name, value: attribute.valueAsDouble, type: 'Double' }
|
190
|
+
elsif attribute.valueType == 'Integer'.to_AttributeValueType
|
191
|
+
result = { name: attribute.name, value: attribute.valueAsInteger, type: 'Integer' }
|
192
|
+
elsif attribute.valueType == 'Unsigned'.to_AttributeValueType
|
193
|
+
result = { name: attribute.name, value: attribute.valueAsUnsigned, type: 'Integer' }
|
194
|
+
elsif attribute.valueType == 'String'.to_AttributeValueType
|
195
|
+
result = { name: attribute.name, value: attribute.valueAsString, type: 'String' }
|
196
|
+
end
|
197
|
+
|
198
|
+
current_step.step[:result][:step_values] << result unless result.nil?
|
199
|
+
end
|
200
|
+
|
201
|
+
return WorkflowStepResult_Shim.new(current_step.step[:result])
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
# incrementing step copies result to previous results
|
206
|
+
# void incrementStep();
|
207
|
+
def incrementStep
|
208
|
+
if @openstudio_2
|
209
|
+
super
|
210
|
+
else
|
211
|
+
# compute result
|
212
|
+
current_result = result
|
213
|
+
|
214
|
+
@workflow.incrementStep
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# Overload registerInfo
|
219
|
+
def registerInfo(message)
|
220
|
+
super
|
221
|
+
@multi_logger.info message
|
222
|
+
end
|
223
|
+
|
224
|
+
# Overload registerInfo
|
225
|
+
def registerWarning(message)
|
226
|
+
super
|
227
|
+
@multi_logger.warn message
|
228
|
+
end
|
229
|
+
|
230
|
+
# Overload registerError
|
231
|
+
def registerError(message)
|
232
|
+
super
|
233
|
+
@multi_logger.error message
|
234
|
+
end
|
235
|
+
|
236
|
+
# Overload registerInitialCondition
|
237
|
+
def registerInitialCondition(message)
|
238
|
+
super
|
239
|
+
@multi_logger.info message
|
240
|
+
end
|
241
|
+
|
242
|
+
# Overload registerFinalCondition
|
243
|
+
def registerFinalCondition(message)
|
244
|
+
super
|
245
|
+
@multi_logger.info message
|
246
|
+
end
|
247
|
+
|
248
|
+
# Overload haltSimulation
|
249
|
+
def haltWorkflow(completed_status)
|
250
|
+
if @use_os_halted
|
251
|
+
super
|
252
|
+
else
|
253
|
+
@halted = true
|
254
|
+
@workflow_json.setCompletedStatus(completed_status)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
# Overload halted
|
259
|
+
def halted
|
260
|
+
return @halted unless @use_os_halted
|
261
|
+
super
|
262
|
+
end
|
263
|
+
end
|