openstudio-workflow 1.3.3 → 1.3.4

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 +77 -72
  3. data/README.md +93 -93
  4. data/Rakefile +36 -36
  5. data/lib/openstudio-workflow.rb +65 -49
  6. data/lib/openstudio/workflow/adapters/input/local.rb +324 -301
  7. data/lib/openstudio/workflow/adapters/output/local.rb +161 -97
  8. data/lib/openstudio/workflow/adapters/output/socket.rb +107 -91
  9. data/lib/openstudio/workflow/adapters/output/web.rb +82 -66
  10. data/lib/openstudio/workflow/adapters/output_adapter.rb +163 -147
  11. data/lib/openstudio/workflow/job.rb +57 -22
  12. data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
  13. data/lib/openstudio/workflow/jobs/run_energyplus.rb +70 -54
  14. data/lib/openstudio/workflow/jobs/run_ep_measures.rb +73 -57
  15. data/lib/openstudio/workflow/jobs/run_initialization.rb +203 -171
  16. data/lib/openstudio/workflow/jobs/run_os_measures.rb +89 -73
  17. data/lib/openstudio/workflow/jobs/run_postprocess.rb +73 -57
  18. data/lib/openstudio/workflow/jobs/run_preprocess.rb +104 -80
  19. data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +118 -102
  20. data/lib/openstudio/workflow/jobs/run_translation.rb +84 -68
  21. data/lib/openstudio/workflow/multi_delegator.rb +62 -46
  22. data/lib/openstudio/workflow/registry.rb +172 -137
  23. data/lib/openstudio/workflow/run.rb +328 -312
  24. data/lib/openstudio/workflow/time_logger.rb +96 -53
  25. data/lib/openstudio/workflow/util.rb +49 -14
  26. data/lib/openstudio/workflow/util/energyplus.rb +605 -570
  27. data/lib/openstudio/workflow/util/io.rb +68 -33
  28. data/lib/openstudio/workflow/util/measure.rb +650 -615
  29. data/lib/openstudio/workflow/util/model.rb +151 -100
  30. data/lib/openstudio/workflow/util/post_process.rb +238 -187
  31. data/lib/openstudio/workflow/util/weather_file.rb +143 -108
  32. data/lib/openstudio/workflow/version.rb +40 -24
  33. data/lib/openstudio/workflow_json.rb +476 -443
  34. data/lib/openstudio/workflow_runner.rb +268 -252
  35. metadata +23 -23
@@ -1,66 +1,82 @@
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 'local'
21
-
22
- # Local file based workflow
23
- module OpenStudio
24
- module Workflow
25
- module OutputAdapter
26
- class Web < Local
27
- def initialize(options = {})
28
- super
29
- raise 'The required :url option was not passed to the web output adapter' unless options[:url]
30
- end
31
-
32
- def communicate_started
33
- super
34
- end
35
-
36
- def communicate_results(directory, results)
37
- super
38
- end
39
-
40
- def communicate_complete
41
- super
42
- end
43
-
44
- def communicate_failure
45
- super
46
- end
47
-
48
- def communicate_objective_function(objectives, options = {})
49
- super
50
- end
51
-
52
- def communicate_transition(message, type, options = {})
53
- super
54
- end
55
-
56
- def communicate_energyplus_stdout(line, options = {})
57
- super
58
- end
59
-
60
- def communicate_measure_result(result, options = {})
61
- super
62
- end
63
- end
64
- end
65
- end
66
- end
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2018, 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 'local'
37
+
38
+ # Local file based workflow
39
+ module OpenStudio
40
+ module Workflow
41
+ module OutputAdapter
42
+ class Web < Local
43
+ def initialize(options = {})
44
+ super
45
+ raise 'The required :url option was not passed to the web output adapter' unless options[:url]
46
+ end
47
+
48
+ def communicate_started
49
+ super
50
+ end
51
+
52
+ def communicate_results(directory, results)
53
+ super
54
+ end
55
+
56
+ def communicate_complete
57
+ super
58
+ end
59
+
60
+ def communicate_failure
61
+ super
62
+ end
63
+
64
+ def communicate_objective_function(objectives, options = {})
65
+ super
66
+ end
67
+
68
+ def communicate_transition(message, type, options = {})
69
+ super
70
+ end
71
+
72
+ def communicate_energyplus_stdout(line, options = {})
73
+ super
74
+ end
75
+
76
+ def communicate_measure_result(result, options = {})
77
+ super
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -1,147 +1,163 @@
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
- module OpenStudio
21
- module Workflow
22
- # Base class for all output adapters. These methods define the expected return behavior of the adapter instance
23
- class OutputAdapters
24
- attr_accessor :options
25
-
26
- def initialize(options = {})
27
- @options = options
28
- end
29
-
30
- def communicate_started
31
- instance.communicate_started
32
- end
33
-
34
- def communicate_transition(message, type, options = {})
35
- instance.communicate_transition message, type, options
36
- end
37
-
38
- def communicate_energyplus_stdout(line, options = {})
39
- instance.communicate_energyplus_stdout line, options
40
- end
41
-
42
- def communicate_measure_result(result, options = {})
43
- instance.communicate_measure_result result, options
44
- end
45
-
46
- def communicate_measure_attributes(measure_attributes, options = {})
47
- instance.communicate_measure_attributes measure_attributes, options
48
- end
49
-
50
- def communicate_objective_function(objectives, options = {})
51
- instance.communicate_objective_function objectives, options
52
- end
53
-
54
- def communicate_results(directory, results)
55
- instance.communicate_results directory, results
56
- end
57
-
58
- def communicate_complete
59
- instance.communicate_complete
60
- end
61
-
62
- def communicate_failure
63
- instance.communicate_failure
64
- end
65
-
66
- protected
67
-
68
- # Zip up a folder and it's contents
69
- def zip_directory(directory, zip_filename, pattern = '*')
70
- # Submethod for adding the directory to the zip folder.
71
- def add_directory_to_zip(zip_file, local_directory, root_directory)
72
- Dir[File.join(local_directory.to_s, '**', '**')].each do |file|
73
- # remove the base directory from the zip file
74
- rel_dir = local_directory.sub("#{root_directory}/", '')
75
- zip_file_to_add = file.gsub(local_directory.to_s, rel_dir.to_s)
76
- if File.directory?(file)
77
- zip_file.addDirectory(file, zip_file_to_add)
78
- else
79
- zip_file.addFile(file, zip_file_to_add)
80
- end
81
- end
82
-
83
- zip_file
84
- end
85
-
86
- FileUtils.rm_f(zip_filename) if File.exist?(zip_filename)
87
-
88
- zf = OpenStudio::ZipFile.new(zip_filename, false)
89
-
90
- Dir[File.join(directory, pattern)].each do |file|
91
- if File.directory?(file)
92
- # skip a few directory that should not be zipped as they are inputs
93
- if File.basename(file) =~ /seed|measures|weather/
94
- next
95
- end
96
- # skip x-large directory
97
- if File.size?(file)
98
- next if File.size?(file) >= 15000000
99
- end
100
- add_directory_to_zip(zf, file, directory)
101
- else
102
- next if File.extname(file) =~ /\.rb.*/
103
- next if File.extname(file) =~ /\.zip.*/
104
- # skip large non-osm/idf files
105
- if File.size(file)
106
- if File.size(file) >= 100000000
107
- next unless File.extname(file) == '.osm' || File.extname(file) == '.idf'
108
- end
109
- end
110
-
111
- zip_file_to_add = file.gsub("#{directory}/", '')
112
- zf.addFile(file, zip_file_to_add)
113
- end
114
- end
115
-
116
- zf = nil
117
- GC.start
118
-
119
- File.chmod(0o664, zip_filename)
120
- end
121
-
122
- # Main method to zip up the results of the simulation results. This will append the UUID of the data point
123
- # if it exists. This method will create two zip files. One for the reports and one for the entire data point. The
124
- # Data Point ZIP will also contain the reports.
125
- #
126
- # @param directory [String] The data point directory to zip up.
127
- # @return nil
128
- #
129
- def zip_results(directory)
130
- # create zip file using a system call
131
- if Dir.exist?(directory) && File.directory?(directory)
132
- zip_filename = @datapoint ? "data_point_#{@datapoint.uuid}.zip" : 'data_point.zip'
133
- zip_filename = File.join(directory, zip_filename)
134
- zip_directory directory, zip_filename
135
- end
136
-
137
- # zip up only the reports folder
138
- report_dir = File.join(directory, 'reports')
139
- if Dir.exist?(report_dir) && File.directory?(report_dir)
140
- zip_filename = @datapoint ? "data_point_#{@datapoint.uuid}_reports.zip" : 'data_point_reports.zip'
141
- zip_filename = File.join(directory, zip_filename)
142
- zip_directory directory, zip_filename, 'reports'
143
- end
144
- end
145
- end
146
- end
147
- end
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2018, 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
+ module OpenStudio
37
+ module Workflow
38
+ # Base class for all output adapters. These methods define the expected return behavior of the adapter instance
39
+ class OutputAdapters
40
+ attr_accessor :options
41
+
42
+ def initialize(options = {})
43
+ @options = options
44
+ end
45
+
46
+ def communicate_started
47
+ instance.communicate_started
48
+ end
49
+
50
+ def communicate_transition(message, type, options = {})
51
+ instance.communicate_transition message, type, options
52
+ end
53
+
54
+ def communicate_energyplus_stdout(line, options = {})
55
+ instance.communicate_energyplus_stdout line, options
56
+ end
57
+
58
+ def communicate_measure_result(result, options = {})
59
+ instance.communicate_measure_result result, options
60
+ end
61
+
62
+ def communicate_measure_attributes(measure_attributes, options = {})
63
+ instance.communicate_measure_attributes measure_attributes, options
64
+ end
65
+
66
+ def communicate_objective_function(objectives, options = {})
67
+ instance.communicate_objective_function objectives, options
68
+ end
69
+
70
+ def communicate_results(directory, results)
71
+ instance.communicate_results directory, results
72
+ end
73
+
74
+ def communicate_complete
75
+ instance.communicate_complete
76
+ end
77
+
78
+ def communicate_failure
79
+ instance.communicate_failure
80
+ end
81
+
82
+ protected
83
+
84
+ # Zip up a folder and it's contents
85
+ def zip_directory(directory, zip_filename, pattern = '*')
86
+ # Submethod for adding the directory to the zip folder.
87
+ def add_directory_to_zip(zip_file, local_directory, root_directory)
88
+ Dir[File.join(local_directory.to_s, '**', '**')].each do |file|
89
+ # remove the base directory from the zip file
90
+ rel_dir = local_directory.sub("#{root_directory}/", '')
91
+ zip_file_to_add = file.gsub(local_directory.to_s, rel_dir.to_s)
92
+ if File.directory?(file)
93
+ zip_file.addDirectory(file, zip_file_to_add)
94
+ else
95
+ zip_file.addFile(file, zip_file_to_add)
96
+ end
97
+ end
98
+
99
+ zip_file
100
+ end
101
+
102
+ FileUtils.rm_f(zip_filename) if File.exist?(zip_filename)
103
+
104
+ zf = OpenStudio::ZipFile.new(zip_filename, false)
105
+
106
+ Dir[File.join(directory, pattern)].each do |file|
107
+ if File.directory?(file)
108
+ # skip a few directory that should not be zipped as they are inputs
109
+ if File.basename(file) =~ /seed|measures|weather/
110
+ next
111
+ end
112
+ # skip x-large directory
113
+ if File.size?(file)
114
+ next if File.size?(file) >= 15000000
115
+ end
116
+ add_directory_to_zip(zf, file, directory)
117
+ else
118
+ next if File.extname(file) =~ /\.rb.*/
119
+ next if File.extname(file) =~ /\.zip.*/
120
+ # skip large non-osm/idf files
121
+ if File.size(file)
122
+ if File.size(file) >= 100000000
123
+ next unless File.extname(file) == '.osm' || File.extname(file) == '.idf'
124
+ end
125
+ end
126
+
127
+ zip_file_to_add = file.gsub("#{directory}/", '')
128
+ zf.addFile(file, zip_file_to_add)
129
+ end
130
+ end
131
+
132
+ zf = nil
133
+ GC.start
134
+
135
+ File.chmod(0o664, zip_filename)
136
+ end
137
+
138
+ # Main method to zip up the results of the simulation results. This will append the UUID of the data point
139
+ # if it exists. This method will create two zip files. One for the reports and one for the entire data point. The
140
+ # Data Point ZIP will also contain the reports.
141
+ #
142
+ # @param directory [String] The data point directory to zip up.
143
+ # @return nil
144
+ #
145
+ def zip_results(directory)
146
+ # create zip file using a system call
147
+ if Dir.exist?(directory) && File.directory?(directory)
148
+ zip_filename = @datapoint ? "data_point_#{@datapoint.uuid}.zip" : 'data_point.zip'
149
+ zip_filename = File.join(directory, zip_filename)
150
+ zip_directory directory, zip_filename
151
+ end
152
+
153
+ # zip up only the reports folder
154
+ report_dir = File.join(directory, 'reports')
155
+ if Dir.exist?(report_dir) && File.directory?(report_dir)
156
+ zip_filename = @datapoint ? "data_point_#{@datapoint.uuid}_reports.zip" : 'data_point_reports.zip'
157
+ zip_filename = File.join(directory, zip_filename)
158
+ zip_directory directory, zip_filename, 'reports'
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end