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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -72
  3. data/README.md +93 -48
  4. data/Rakefile +36 -36
  5. data/lib/openstudio-workflow.rb +49 -49
  6. data/lib/openstudio/workflow/adapters/input/local.rb +244 -240
  7. data/lib/openstudio/workflow/adapters/output/local.rb +95 -95
  8. data/lib/openstudio/workflow/adapters/output/socket.rb +91 -91
  9. data/lib/openstudio/workflow/adapters/output/web.rb +66 -66
  10. data/lib/openstudio/workflow/adapters/output_adapter.rb +147 -147
  11. data/lib/openstudio/workflow/job.rb +22 -22
  12. data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
  13. data/lib/openstudio/workflow/jobs/run_energyplus.rb +49 -49
  14. data/lib/openstudio/workflow/jobs/run_ep_measures.rb +55 -55
  15. data/lib/openstudio/workflow/jobs/run_initialization.rb +169 -167
  16. data/lib/openstudio/workflow/jobs/run_os_measures.rb +69 -69
  17. data/lib/openstudio/workflow/jobs/run_postprocess.rb +53 -53
  18. data/lib/openstudio/workflow/jobs/run_preprocess.rb +69 -69
  19. data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +98 -98
  20. data/lib/openstudio/workflow/jobs/run_translation.rb +61 -61
  21. data/lib/openstudio/workflow/multi_delegator.rb +46 -46
  22. data/lib/openstudio/workflow/registry.rb +137 -137
  23. data/lib/openstudio/workflow/run.rb +299 -299
  24. data/lib/openstudio/workflow/time_logger.rb +53 -53
  25. data/lib/openstudio/workflow/util.rb +14 -14
  26. data/lib/openstudio/workflow/util/energyplus.rb +566 -564
  27. data/lib/openstudio/workflow/util/io.rb +33 -33
  28. data/lib/openstudio/workflow/util/measure.rb +588 -588
  29. data/lib/openstudio/workflow/util/model.rb +100 -100
  30. data/lib/openstudio/workflow/util/post_process.rb +187 -187
  31. data/lib/openstudio/workflow/util/weather_file.rb +108 -108
  32. data/lib/openstudio/workflow/version.rb +24 -24
  33. data/lib/openstudio/workflow_json.rb +426 -426
  34. data/lib/openstudio/workflow_runner.rb +233 -215
  35. 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
- begin
31
- # OpenStudio 2.X
32
- super(@workflow_json)
33
- rescue Exception => e
34
- # OpenStudio 1.X
35
- @workflow = workflow_json
36
- @units_preference = 'SI'
37
- @language_preference = 'EN'
38
- super()
39
- end
40
- end
41
-
42
- def timeString
43
- ::Time.now.utc.strftime("%Y%m%dT%H%M%SZ")
44
- end
45
-
46
- # Returns the workflow currently being run. New in OS 2.0.
47
- # WorkflowJSON workflow() const;
48
- def workflow
49
- if @openstudio_2
50
- super
51
- else
52
- @workflow
53
- end
54
- end
55
-
56
- # Returns preferred unit system, either 'IP' or 'SI'. New in OS 2.0. */
57
- # std::string unitsPreference() const;
58
- def unitsPreference
59
- if @openstudio_2
60
- super
61
- else
62
- @units_preference
63
- end
64
- end
65
-
66
- # Returns preferred language, e.g. 'en' or 'fr'. New in OS 2.0. */
67
- # std::string languagePreference() const;
68
- def languagePreference
69
- if @openstudio_2
70
- super
71
- else
72
- @language_preference
73
- end
74
- end
75
-
76
- # called right when each measure is run
77
- # only called in OpenStudio 1.X
78
- # virtual void prepareForUserScriptRun(const UserScript& userScript);
79
- def prepareForUserScriptRun(userScript)
80
- if @openstudio_2
81
- prepareForMeasureRun(userScript)
82
- else
83
- current_step = @workflow.currentStep
84
-
85
- unless current_step.empty?
86
- current_step.get.step[:result] = {}
87
- current_step.get.step[:result][:started_at] = timeString
88
- end
89
-
90
- # TODO: capture std out and err
91
-
92
- # TODO: get initial list of files
93
-
94
- super
95
- end
96
- end
97
-
98
- def result
99
- if @openstudio_2
100
- super
101
- else
102
- os_result = super
103
-
104
- current_step = @workflow.currentStep
105
-
106
- if current_step.empty?
107
- raise 'Cannot find current_step'
108
- end
109
- current_step = current_step.get
110
-
111
- if current_step.step[:result].nil?
112
- # skipped, prepareForUserScriptRun was not called
113
- current_step.step[:result] = {}
114
- current_step.step[:result][:started_at] = timeString
115
- current_step.step[:result][:step_result] = 'Skip'
116
- else
117
- current_step.step[:result][:step_result] = os_result.value.valueName
118
- end
119
-
120
- current_step.step[:result][:completed_at] = timeString
121
-
122
- # TODO: restore stdout and stderr
123
-
124
- # TODO: check for created files
125
-
126
- current_step.step[:result][:step_errors] = []
127
- os_result.errors.each do |error|
128
- current_step.step[:result][:step_errors] << error.logMessage
129
- end
130
-
131
- current_step.step[:result][:step_warnings] = []
132
- os_result.warnings.each do |warning|
133
- current_step.step[:result][:step_warnings] << warning.logMessage
134
- end
135
-
136
- current_step.step[:result][:step_info] = []
137
- os_result.info.each do |info|
138
- current_step.step[:result][:step_info] << info.logMessage
139
- end
140
-
141
- unless os_result.initialCondition.empty?
142
- current_step.step[:result][:initial_condition] = os_result.initialCondition.get.logMessage
143
- current_step.step[:result][:step_initial_condition] = os_result.initialCondition.get.logMessage
144
- end
145
-
146
- unless os_result.finalCondition.empty?
147
- current_step.step[:result][:final_condition] = os_result.finalCondition.get.logMessage
148
- current_step.step[:result][:step_final_condition] = os_result.finalCondition.get.logMessage
149
- end
150
-
151
- current_step.step[:result][:step_values] = []
152
- os_result.attributes.each do |attribute|
153
- result = nil
154
- if attribute.valueType == 'Boolean'.to_AttributeValueType
155
- result = { name: attribute.name, value: attribute.valueAsBoolean, type: 'Boolean' }
156
- elsif attribute.valueType == 'Double'.to_AttributeValueType
157
- result = { name: attribute.name, value: attribute.valueAsDouble, type: 'Double' }
158
- elsif attribute.valueType == 'Integer'.to_AttributeValueType
159
- result = { name: attribute.name, value: attribute.valueAsInteger, type: 'Integer' }
160
- elsif attribute.valueType == 'Unsigned'.to_AttributeValueType
161
- result = { name: attribute.name, value: attribute.valueAsUnsigned, type: 'Integer' }
162
- elsif attribute.valueType == 'String'.to_AttributeValueType
163
- result = { name: attribute.name, value: attribute.valueAsString, type: 'String' }
164
- end
165
-
166
- current_step.step[:result][:step_values] << result unless result.nil?
167
- end
168
-
169
- return WorkflowStepResult_Shim.new(current_step.step[:result])
170
- end
171
- end
172
-
173
- # incrementing step copies result to previous results
174
- # void incrementStep();
175
- def incrementStep
176
- if @openstudio_2
177
- super
178
- else
179
- # compute result
180
- current_result = result
181
-
182
- @workflow.incrementStep
183
- end
184
- end
185
-
186
- # Overload registerInfo
187
- def registerInfo(message)
188
- super
189
- @multi_logger.info message
190
- end
191
-
192
- # Overload registerInfo
193
- def registerWarning(message)
194
- super
195
- @multi_logger.warn message
196
- end
197
-
198
- # Overload registerError
199
- def registerError(message)
200
- super
201
- @multi_logger.error message
202
- end
203
-
204
- # Overload registerInitialCondition
205
- def registerInitialCondition(message)
206
- super
207
- @multi_logger.info message
208
- end
209
-
210
- # Overload registerFinalCondition
211
- def registerFinalCondition(message)
212
- super
213
- @multi_logger.info message
214
- end
215
- end
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.1
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-03-28 00:00:00.000000000 Z
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.11
103
+ rubygems_version: 2.6.10
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: OpenStudio Workflow Manager