openstudio-workflow 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +72 -72
- data/README.md +93 -48
- data/Rakefile +36 -36
- data/lib/openstudio-workflow.rb +49 -49
- data/lib/openstudio/workflow/adapters/input/local.rb +244 -240
- data/lib/openstudio/workflow/adapters/output/local.rb +95 -95
- data/lib/openstudio/workflow/adapters/output/socket.rb +91 -91
- data/lib/openstudio/workflow/adapters/output/web.rb +66 -66
- data/lib/openstudio/workflow/adapters/output_adapter.rb +147 -147
- data/lib/openstudio/workflow/job.rb +22 -22
- data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
- data/lib/openstudio/workflow/jobs/run_energyplus.rb +49 -49
- data/lib/openstudio/workflow/jobs/run_ep_measures.rb +55 -55
- data/lib/openstudio/workflow/jobs/run_initialization.rb +169 -167
- data/lib/openstudio/workflow/jobs/run_os_measures.rb +69 -69
- data/lib/openstudio/workflow/jobs/run_postprocess.rb +53 -53
- data/lib/openstudio/workflow/jobs/run_preprocess.rb +69 -69
- data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +98 -98
- data/lib/openstudio/workflow/jobs/run_translation.rb +61 -61
- data/lib/openstudio/workflow/multi_delegator.rb +46 -46
- data/lib/openstudio/workflow/registry.rb +137 -137
- data/lib/openstudio/workflow/run.rb +299 -299
- data/lib/openstudio/workflow/time_logger.rb +53 -53
- data/lib/openstudio/workflow/util.rb +14 -14
- data/lib/openstudio/workflow/util/energyplus.rb +566 -564
- data/lib/openstudio/workflow/util/io.rb +33 -33
- data/lib/openstudio/workflow/util/measure.rb +588 -588
- data/lib/openstudio/workflow/util/model.rb +100 -100
- data/lib/openstudio/workflow/util/post_process.rb +187 -187
- data/lib/openstudio/workflow/util/weather_file.rb +108 -108
- data/lib/openstudio/workflow/version.rb +24 -24
- data/lib/openstudio/workflow_json.rb +426 -426
- data/lib/openstudio/workflow_runner.rb +233 -215
- metadata +3 -3
@@ -1,215 +1,233 @@
|
|
1
|
-
######################################################################
|
2
|
-
# Copyright (c) 2008-2014, Alliance for Sustainable Energy.
|
3
|
-
# All rights reserved.
|
4
|
-
#
|
5
|
-
# This library is free software; you can redistribute it and/or
|
6
|
-
# modify it under the terms of the GNU Lesser General Public
|
7
|
-
# License as published by the Free Software Foundation; either
|
8
|
-
# version 2.1 of the License, or (at your option) any later version.
|
9
|
-
#
|
10
|
-
# This library is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
# Lesser General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU Lesser General Public
|
16
|
-
# License along with this library; if not, write to the Free Software
|
17
|
-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
-
######################################################################
|
19
|
-
|
20
|
-
require_relative 'workflow_json'
|
21
|
-
|
22
|
-
# Extend OS Runner to persist measure information throughout the workflow
|
23
|
-
# Provide shims to support OpenStudio 2.X functionality in OpenStudio 1.X
|
24
|
-
class WorkflowRunner < OpenStudio::Ruleset::OSRunner
|
25
|
-
def initialize(multi_logger, workflow_json, openstudio_2)
|
26
|
-
@multi_logger = multi_logger
|
27
|
-
@workflow_json = workflow_json
|
28
|
-
@openstudio_2 = openstudio_2
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
@
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
current_step.step[:result][:
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
current_step.step[:result][:
|
167
|
-
end
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
#
|
193
|
-
def
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
end
|
203
|
-
|
204
|
-
# Overload
|
205
|
-
def
|
206
|
-
super
|
207
|
-
@multi_logger.info message
|
208
|
-
end
|
209
|
-
|
210
|
-
# Overload
|
211
|
-
def
|
212
|
-
super
|
213
|
-
@multi_logger.
|
214
|
-
end
|
215
|
-
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2014, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
require_relative 'workflow_json'
|
21
|
+
|
22
|
+
# Extend OS Runner to persist measure information throughout the workflow
|
23
|
+
# Provide shims to support OpenStudio 2.X functionality in OpenStudio 1.X
|
24
|
+
class WorkflowRunner < OpenStudio::Ruleset::OSRunner
|
25
|
+
def initialize(multi_logger, workflow_json, openstudio_2)
|
26
|
+
@multi_logger = multi_logger
|
27
|
+
@workflow_json = workflow_json
|
28
|
+
@openstudio_2 = openstudio_2
|
29
|
+
@datapoint = nil
|
30
|
+
@analysis = nil
|
31
|
+
|
32
|
+
begin
|
33
|
+
# OpenStudio 2.X
|
34
|
+
super(@workflow_json)
|
35
|
+
rescue Exception => e
|
36
|
+
# OpenStudio 1.X
|
37
|
+
@workflow = workflow_json
|
38
|
+
@units_preference = 'SI'
|
39
|
+
@language_preference = 'EN'
|
40
|
+
super()
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def timeString
|
45
|
+
::Time.now.utc.strftime("%Y%m%dT%H%M%SZ")
|
46
|
+
end
|
47
|
+
|
48
|
+
def datapoint
|
49
|
+
@datapoint
|
50
|
+
end
|
51
|
+
|
52
|
+
def setDatapoint(datapoint)
|
53
|
+
@datapoint = datapoint
|
54
|
+
end
|
55
|
+
|
56
|
+
def analysis
|
57
|
+
@analysis
|
58
|
+
end
|
59
|
+
|
60
|
+
def setAnalysis(analysis)
|
61
|
+
@analysis = analysis
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns the workflow currently being run. New in OS 2.0.
|
65
|
+
# WorkflowJSON workflow() const;
|
66
|
+
def workflow
|
67
|
+
if @openstudio_2
|
68
|
+
super
|
69
|
+
else
|
70
|
+
@workflow
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns preferred unit system, either 'IP' or 'SI'. New in OS 2.0. */
|
75
|
+
# std::string unitsPreference() const;
|
76
|
+
def unitsPreference
|
77
|
+
if @openstudio_2
|
78
|
+
super
|
79
|
+
else
|
80
|
+
@units_preference
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Returns preferred language, e.g. 'en' or 'fr'. New in OS 2.0. */
|
85
|
+
# std::string languagePreference() const;
|
86
|
+
def languagePreference
|
87
|
+
if @openstudio_2
|
88
|
+
super
|
89
|
+
else
|
90
|
+
@language_preference
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# called right when each measure is run
|
95
|
+
# only called in OpenStudio 1.X
|
96
|
+
# virtual void prepareForUserScriptRun(const UserScript& userScript);
|
97
|
+
def prepareForUserScriptRun(userScript)
|
98
|
+
if @openstudio_2
|
99
|
+
prepareForMeasureRun(userScript)
|
100
|
+
else
|
101
|
+
current_step = @workflow.currentStep
|
102
|
+
|
103
|
+
unless current_step.empty?
|
104
|
+
current_step.get.step[:result] = {}
|
105
|
+
current_step.get.step[:result][:started_at] = timeString
|
106
|
+
end
|
107
|
+
|
108
|
+
# TODO: capture std out and err
|
109
|
+
|
110
|
+
# TODO: get initial list of files
|
111
|
+
|
112
|
+
super
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def result
|
117
|
+
if @openstudio_2
|
118
|
+
super
|
119
|
+
else
|
120
|
+
os_result = super
|
121
|
+
|
122
|
+
current_step = @workflow.currentStep
|
123
|
+
|
124
|
+
if current_step.empty?
|
125
|
+
raise 'Cannot find current_step'
|
126
|
+
end
|
127
|
+
current_step = current_step.get
|
128
|
+
|
129
|
+
if current_step.step[:result].nil?
|
130
|
+
# skipped, prepareForUserScriptRun was not called
|
131
|
+
current_step.step[:result] = {}
|
132
|
+
current_step.step[:result][:started_at] = timeString
|
133
|
+
current_step.step[:result][:step_result] = 'Skip'
|
134
|
+
else
|
135
|
+
current_step.step[:result][:step_result] = os_result.value.valueName
|
136
|
+
end
|
137
|
+
|
138
|
+
current_step.step[:result][:completed_at] = timeString
|
139
|
+
|
140
|
+
# TODO: restore stdout and stderr
|
141
|
+
|
142
|
+
# TODO: check for created files
|
143
|
+
|
144
|
+
current_step.step[:result][:step_errors] = []
|
145
|
+
os_result.errors.each do |error|
|
146
|
+
current_step.step[:result][:step_errors] << error.logMessage
|
147
|
+
end
|
148
|
+
|
149
|
+
current_step.step[:result][:step_warnings] = []
|
150
|
+
os_result.warnings.each do |warning|
|
151
|
+
current_step.step[:result][:step_warnings] << warning.logMessage
|
152
|
+
end
|
153
|
+
|
154
|
+
current_step.step[:result][:step_info] = []
|
155
|
+
os_result.info.each do |info|
|
156
|
+
current_step.step[:result][:step_info] << info.logMessage
|
157
|
+
end
|
158
|
+
|
159
|
+
unless os_result.initialCondition.empty?
|
160
|
+
current_step.step[:result][:initial_condition] = os_result.initialCondition.get.logMessage
|
161
|
+
current_step.step[:result][:step_initial_condition] = os_result.initialCondition.get.logMessage
|
162
|
+
end
|
163
|
+
|
164
|
+
unless os_result.finalCondition.empty?
|
165
|
+
current_step.step[:result][:final_condition] = os_result.finalCondition.get.logMessage
|
166
|
+
current_step.step[:result][:step_final_condition] = os_result.finalCondition.get.logMessage
|
167
|
+
end
|
168
|
+
|
169
|
+
current_step.step[:result][:step_values] = []
|
170
|
+
os_result.attributes.each do |attribute|
|
171
|
+
result = nil
|
172
|
+
if attribute.valueType == 'Boolean'.to_AttributeValueType
|
173
|
+
result = { name: attribute.name, value: attribute.valueAsBoolean, type: 'Boolean' }
|
174
|
+
elsif attribute.valueType == 'Double'.to_AttributeValueType
|
175
|
+
result = { name: attribute.name, value: attribute.valueAsDouble, type: 'Double' }
|
176
|
+
elsif attribute.valueType == 'Integer'.to_AttributeValueType
|
177
|
+
result = { name: attribute.name, value: attribute.valueAsInteger, type: 'Integer' }
|
178
|
+
elsif attribute.valueType == 'Unsigned'.to_AttributeValueType
|
179
|
+
result = { name: attribute.name, value: attribute.valueAsUnsigned, type: 'Integer' }
|
180
|
+
elsif attribute.valueType == 'String'.to_AttributeValueType
|
181
|
+
result = { name: attribute.name, value: attribute.valueAsString, type: 'String' }
|
182
|
+
end
|
183
|
+
|
184
|
+
current_step.step[:result][:step_values] << result unless result.nil?
|
185
|
+
end
|
186
|
+
|
187
|
+
return WorkflowStepResult_Shim.new(current_step.step[:result])
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# incrementing step copies result to previous results
|
192
|
+
# void incrementStep();
|
193
|
+
def incrementStep
|
194
|
+
if @openstudio_2
|
195
|
+
super
|
196
|
+
else
|
197
|
+
# compute result
|
198
|
+
current_result = result
|
199
|
+
|
200
|
+
@workflow.incrementStep
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Overload registerInfo
|
205
|
+
def registerInfo(message)
|
206
|
+
super
|
207
|
+
@multi_logger.info message
|
208
|
+
end
|
209
|
+
|
210
|
+
# Overload registerInfo
|
211
|
+
def registerWarning(message)
|
212
|
+
super
|
213
|
+
@multi_logger.warn message
|
214
|
+
end
|
215
|
+
|
216
|
+
# Overload registerError
|
217
|
+
def registerError(message)
|
218
|
+
super
|
219
|
+
@multi_logger.error message
|
220
|
+
end
|
221
|
+
|
222
|
+
# Overload registerInitialCondition
|
223
|
+
def registerInitialCondition(message)
|
224
|
+
super
|
225
|
+
@multi_logger.info message
|
226
|
+
end
|
227
|
+
|
228
|
+
# Overload registerFinalCondition
|
229
|
+
def registerFinalCondition(message)
|
230
|
+
super
|
231
|
+
@multi_logger.info message
|
232
|
+
end
|
233
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstudio-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Long
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.6.
|
103
|
+
rubygems_version: 2.6.10
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: OpenStudio Workflow Manager
|