openstudio-workflow 1.2.0 → 1.2.1

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 +48 -48
  4. data/Rakefile +36 -36
  5. data/lib/openstudio/workflow/adapters/input/local.rb +240 -240
  6. data/lib/openstudio/workflow/adapters/output/local.rb +95 -95
  7. data/lib/openstudio/workflow/adapters/output/socket.rb +91 -91
  8. data/lib/openstudio/workflow/adapters/output/web.rb +66 -66
  9. data/lib/openstudio/workflow/adapters/output_adapter.rb +147 -147
  10. data/lib/openstudio/workflow/job.rb +22 -22
  11. data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
  12. data/lib/openstudio/workflow/jobs/run_energyplus.rb +49 -49
  13. data/lib/openstudio/workflow/jobs/run_ep_measures.rb +55 -55
  14. data/lib/openstudio/workflow/jobs/run_initialization.rb +167 -167
  15. data/lib/openstudio/workflow/jobs/run_os_measures.rb +69 -69
  16. data/lib/openstudio/workflow/jobs/run_postprocess.rb +53 -53
  17. data/lib/openstudio/workflow/jobs/run_preprocess.rb +69 -69
  18. data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +98 -98
  19. data/lib/openstudio/workflow/jobs/run_translation.rb +61 -61
  20. data/lib/openstudio/workflow/multi_delegator.rb +46 -46
  21. data/lib/openstudio/workflow/registry.rb +137 -137
  22. data/lib/openstudio/workflow/run.rb +299 -299
  23. data/lib/openstudio/workflow/time_logger.rb +53 -53
  24. data/lib/openstudio/workflow/util/energyplus.rb +564 -564
  25. data/lib/openstudio/workflow/util/io.rb +33 -33
  26. data/lib/openstudio/workflow/util/measure.rb +588 -586
  27. data/lib/openstudio/workflow/util/model.rb +100 -100
  28. data/lib/openstudio/workflow/util/post_process.rb +187 -187
  29. data/lib/openstudio/workflow/util/weather_file.rb +108 -108
  30. data/lib/openstudio/workflow/util.rb +14 -14
  31. data/lib/openstudio/workflow/version.rb +24 -24
  32. data/lib/openstudio/workflow_json.rb +426 -426
  33. data/lib/openstudio/workflow_runner.rb +215 -215
  34. data/lib/openstudio-workflow.rb +49 -49
  35. metadata +3 -3
@@ -1,215 +1,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
-
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
+
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,49 +1,49 @@
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 'fileutils'
21
- require 'json'
22
- require 'pathname'
23
-
24
- require_relative 'openstudio/workflow/version'
25
- require_relative 'openstudio/workflow/multi_delegator'
26
- require_relative 'openstudio/workflow/run'
27
- require_relative 'openstudio/workflow/job'
28
- require_relative 'openstudio/workflow/time_logger'
29
- require_relative 'openstudio/workflow/registry'
30
- require_relative 'openstudio/workflow/util'
31
- require 'openstudio'
32
- require_relative 'openstudio/workflow_runner'
33
-
34
- module OpenStudio
35
- module Workflow
36
- extend self
37
-
38
- # Extract an archive to a specific location
39
- #
40
- # @param archive_filename [String] Path and name of the file to extract
41
- # @param destination [String] Path to extract to
42
- # @param overwrite [Boolean] If true, will overwrite any extracted file that may already exist
43
- #
44
- def extract_archive(archive_filename, destination, overwrite = true)
45
- zf = OpenStudio::UnzipFile.new(archive_filename)
46
- zf.extractAllFiles(destination)
47
- end
48
- end
49
- 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 'fileutils'
21
+ require 'json'
22
+ require 'pathname'
23
+
24
+ require_relative 'openstudio/workflow/version'
25
+ require_relative 'openstudio/workflow/multi_delegator'
26
+ require_relative 'openstudio/workflow/run'
27
+ require_relative 'openstudio/workflow/job'
28
+ require_relative 'openstudio/workflow/time_logger'
29
+ require_relative 'openstudio/workflow/registry'
30
+ require_relative 'openstudio/workflow/util'
31
+ require 'openstudio'
32
+ require_relative 'openstudio/workflow_runner'
33
+
34
+ module OpenStudio
35
+ module Workflow
36
+ extend self
37
+
38
+ # Extract an archive to a specific location
39
+ #
40
+ # @param archive_filename [String] Path and name of the file to extract
41
+ # @param destination [String] Path to extract to
42
+ # @param overwrite [Boolean] If true, will overwrite any extracted file that may already exist
43
+ #
44
+ def extract_archive(archive_filename, destination, overwrite = true)
45
+ zf = OpenStudio::UnzipFile.new(archive_filename)
46
+ zf.extractAllFiles(destination)
47
+ end
48
+ end
49
+ end