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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -72
- data/README.md +93 -93
- data/Rakefile +36 -36
- data/lib/openstudio-workflow.rb +65 -49
- data/lib/openstudio/workflow/adapters/input/local.rb +324 -301
- data/lib/openstudio/workflow/adapters/output/local.rb +161 -97
- data/lib/openstudio/workflow/adapters/output/socket.rb +107 -91
- data/lib/openstudio/workflow/adapters/output/web.rb +82 -66
- data/lib/openstudio/workflow/adapters/output_adapter.rb +163 -147
- data/lib/openstudio/workflow/job.rb +57 -22
- data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
- data/lib/openstudio/workflow/jobs/run_energyplus.rb +70 -54
- data/lib/openstudio/workflow/jobs/run_ep_measures.rb +73 -57
- data/lib/openstudio/workflow/jobs/run_initialization.rb +203 -171
- data/lib/openstudio/workflow/jobs/run_os_measures.rb +89 -73
- data/lib/openstudio/workflow/jobs/run_postprocess.rb +73 -57
- data/lib/openstudio/workflow/jobs/run_preprocess.rb +104 -80
- data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +118 -102
- data/lib/openstudio/workflow/jobs/run_translation.rb +84 -68
- data/lib/openstudio/workflow/multi_delegator.rb +62 -46
- data/lib/openstudio/workflow/registry.rb +172 -137
- data/lib/openstudio/workflow/run.rb +328 -312
- data/lib/openstudio/workflow/time_logger.rb +96 -53
- data/lib/openstudio/workflow/util.rb +49 -14
- data/lib/openstudio/workflow/util/energyplus.rb +605 -570
- data/lib/openstudio/workflow/util/io.rb +68 -33
- data/lib/openstudio/workflow/util/measure.rb +650 -615
- data/lib/openstudio/workflow/util/model.rb +151 -100
- data/lib/openstudio/workflow/util/post_process.rb +238 -187
- data/lib/openstudio/workflow/util/weather_file.rb +143 -108
- data/lib/openstudio/workflow/version.rb +40 -24
- data/lib/openstudio/workflow_json.rb +476 -443
- data/lib/openstudio/workflow_runner.rb +268 -252
- metadata +23 -23
@@ -1,97 +1,161 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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 'openstudio/workflow/adapters/output_adapter'
|
37
|
+
|
38
|
+
# Local file based workflow
|
39
|
+
module OpenStudio
|
40
|
+
module Workflow
|
41
|
+
module OutputAdapter
|
42
|
+
class Local < OutputAdapters
|
43
|
+
def initialize(options = {})
|
44
|
+
raise 'The required :output_directory option was not passed to the local output adapter' unless options[:output_directory]
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
# Write to the filesystem that the process has started
|
49
|
+
#
|
50
|
+
def communicate_started
|
51
|
+
File.open("#{@options[:output_directory]}/started.job", 'w') do |f|
|
52
|
+
f << "Started Workflow #{::Time.now}"
|
53
|
+
# make sure data is written to the disk one way or the other
|
54
|
+
begin
|
55
|
+
f.fsync
|
56
|
+
rescue
|
57
|
+
f.flush
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Write to the filesystem that the process has completed
|
63
|
+
#
|
64
|
+
def communicate_complete
|
65
|
+
File.open("#{@options[:output_directory]}/finished.job", 'w') do |f|
|
66
|
+
f << "Finished Workflow #{::Time.now}"
|
67
|
+
# make sure data is written to the disk one way or the other
|
68
|
+
begin
|
69
|
+
f.fsync
|
70
|
+
rescue
|
71
|
+
f.flush
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Write to the filesystem that the process has failed
|
77
|
+
#
|
78
|
+
def communicate_failure
|
79
|
+
File.open("#{@options[:output_directory]}/failed.job", 'w') do |f|
|
80
|
+
f << "Failed Workflow #{::Time.now}"
|
81
|
+
# make sure data is written to the disk one way or the other
|
82
|
+
begin
|
83
|
+
f.fsync
|
84
|
+
rescue
|
85
|
+
f.flush
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Do nothing on a state transition
|
91
|
+
#
|
92
|
+
def communicate_transition(_ = nil, _ = nil, _ = nil)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Do nothing on EnergyPlus stdout
|
96
|
+
#
|
97
|
+
def communicate_energyplus_stdout(_ = nil, _ = nil)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Do nothing on Measure result
|
101
|
+
#
|
102
|
+
def communicate_measure_result(_ = nil, _ = nil)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Write the measure attributes to the filesystem
|
106
|
+
#
|
107
|
+
def communicate_measure_attributes(measure_attributes, _ = nil)
|
108
|
+
attributes_file = "#{@options[:output_directory]}/measure_attributes.json"
|
109
|
+
FileUtils.rm_f(attributes_file) if File.exist?(attributes_file)
|
110
|
+
File.open(attributes_file, 'w') do |f|
|
111
|
+
f << JSON.pretty_generate(measure_attributes)
|
112
|
+
# make sure data is written to the disk one way or the other
|
113
|
+
begin
|
114
|
+
f.fsync
|
115
|
+
rescue
|
116
|
+
f.flush
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# Write the objective function results to the filesystem
|
122
|
+
#
|
123
|
+
def communicate_objective_function(objectives, _ = nil)
|
124
|
+
obj_fun_file = "#{@options[:output_directory]}/objectives.json"
|
125
|
+
FileUtils.rm_f(obj_fun_file) if File.exist?(obj_fun_file)
|
126
|
+
File.open(obj_fun_file, 'w') do |f|
|
127
|
+
f << JSON.pretty_generate(objectives)
|
128
|
+
# make sure data is written to the disk one way or the other
|
129
|
+
begin
|
130
|
+
f.fsync
|
131
|
+
rescue
|
132
|
+
f.flush
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Write the results of the workflow to the filesystem
|
138
|
+
#
|
139
|
+
def communicate_results(directory, results)
|
140
|
+
zip_results(directory)
|
141
|
+
|
142
|
+
if results.is_a? Hash
|
143
|
+
# DLM: don't we want this in the results zip?
|
144
|
+
# DLM: deprecate in favor of out.osw
|
145
|
+
File.open("#{@options[:output_directory]}/data_point_out.json", 'w') do |f|
|
146
|
+
f << JSON.pretty_generate(results)
|
147
|
+
# make sure data is written to the disk one way or the other
|
148
|
+
begin
|
149
|
+
f.fsync
|
150
|
+
rescue
|
151
|
+
f.flush
|
152
|
+
end
|
153
|
+
end
|
154
|
+
else
|
155
|
+
#puts "Unknown datapoint result type. Please handle #{results.class}"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -1,91 +1,107 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def
|
45
|
-
super
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
@socket.write(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
+
require 'socket'
|
38
|
+
|
39
|
+
# Local file based workflow
|
40
|
+
module OpenStudio
|
41
|
+
module Workflow
|
42
|
+
module OutputAdapter
|
43
|
+
class Socket < Local
|
44
|
+
def initialize(options = {})
|
45
|
+
super
|
46
|
+
raise 'The required :port option was not passed to the socket output adapter' unless options[:port]
|
47
|
+
|
48
|
+
@socket = TCPSocket.open 'localhost', options[:port]
|
49
|
+
end
|
50
|
+
|
51
|
+
def communicate_started
|
52
|
+
super
|
53
|
+
@socket.write("Started\n")
|
54
|
+
end
|
55
|
+
|
56
|
+
def communicate_results(directory, results)
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def communicate_complete
|
61
|
+
super
|
62
|
+
@socket.write("Complete\n")
|
63
|
+
end
|
64
|
+
|
65
|
+
def communicate_failure
|
66
|
+
super
|
67
|
+
@socket.write("Failure\n")
|
68
|
+
end
|
69
|
+
|
70
|
+
def communicate_objective_function(objectives, options = {})
|
71
|
+
super
|
72
|
+
end
|
73
|
+
|
74
|
+
def communicate_transition(message, type, options = {})
|
75
|
+
super
|
76
|
+
@socket.write(message + "\n")
|
77
|
+
end
|
78
|
+
|
79
|
+
def communicate_energyplus_stdout(line, options = {})
|
80
|
+
super
|
81
|
+
@socket.write(line)
|
82
|
+
end
|
83
|
+
|
84
|
+
def communicate_measure_result(result, options = {})
|
85
|
+
super
|
86
|
+
|
87
|
+
step_result = result.stepResult
|
88
|
+
initial_condition = result.stepInitialCondition
|
89
|
+
final_condition = result.stepFinalCondition
|
90
|
+
errors = result.stepErrors
|
91
|
+
warnings = result.stepWarnings
|
92
|
+
infos = result.stepInfo
|
93
|
+
|
94
|
+
# Mirrors WorkflowStepResult::string
|
95
|
+
tab = ' '
|
96
|
+
@socket.write("#{tab}Result: #{step_result.get.valueName}\n") if !step_result.empty?
|
97
|
+
@socket.write("#{tab}Initial Condition: #{initial_condition.get}\n") if !initial_condition.empty?
|
98
|
+
@socket.write("#{tab}Final Condition: #{final_condition.get}\n") if !final_condition.empty?
|
99
|
+
errors.each {|error| @socket.write("#{tab}Error: #{error}\n") }
|
100
|
+
warnings.each {|warning| @socket.write("#{tab}Warn: #{warning}\n") }
|
101
|
+
infos.each {|info| @socket.write("#{tab}Info: #{info}\n") }
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|