openstudio-workflow 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- 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,82 +1,82 @@
|
|
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 '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
|
+
# *******************************************************************************
|
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 '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,163 +1,163 @@
|
|
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
|
-
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
|
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
|
+
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
|