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,95 +1,95 @@
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 'openstudio/workflow/adapters/output_adapter'
21
-
22
- # Local file based workflow
23
- module OpenStudio
24
- module Workflow
25
- module OutputAdapter
26
- class Local < OutputAdapters
27
- def initialize(options = {})
28
- raise 'The required :output_directory option was not passed to the local output adapter' unless options[:output_directory]
29
- super
30
- end
31
-
32
- # Write to the filesystem that the process has started
33
- #
34
- def communicate_started
35
- File.open("#{@options[:output_directory]}/started.job", 'w') { |f| f << "Started Workflow #{::Time.now}" }
36
- end
37
-
38
- # Write to the filesystem that the process has completed
39
- #
40
- def communicate_complete
41
- File.open("#{@options[:output_directory]}/finished.job", 'w') { |f| f << "Finished Workflow #{::Time.now}" }
42
- end
43
-
44
- # Write to the filesystem that the process has failed
45
- #
46
- def communicate_failure
47
- File.open("#{@options[:output_directory]}/failed.job", 'w') { |f| f << "Failed Workflow #{::Time.now}" }
48
- end
49
-
50
- # Do nothing on a state transition
51
- #
52
- def communicate_transition(_ = nil, _ = nil, _ = nil)
53
- end
54
-
55
- # Do nothing on EnergyPlus stdout
56
- #
57
- def communicate_energyplus_stdout(_ = nil, _ = nil)
58
- end
59
-
60
- # Do nothing on Measure result
61
- #
62
- def communicate_measure_result(_ = nil, _ = nil)
63
- end
64
-
65
- # Write the measure attributes to the filesystem
66
- #
67
- def communicate_measure_attributes(measure_attributes, _ = nil)
68
- File.open("#{@options[:output_directory]}/measure_attributes.json", 'w') do |f|
69
- f << JSON.pretty_generate(measure_attributes)
70
- end
71
- end
72
-
73
- # Write the objective function results to the filesystem
74
- #
75
- def communicate_objective_function(objectives, _ = nil)
76
- obj_fun_file = "#{@options[:output_directory]}/objectives.json"
77
- FileUtils.rm_f(obj_fun_file) if File.exist?(obj_fun_file)
78
- File.open(obj_fun_file, 'w') { |f| f << JSON.pretty_generate(objectives) }
79
- end
80
-
81
- # Write the results of the workflow to the filesystem
82
- #
83
- def communicate_results(directory, results)
84
- zip_results(directory)
85
-
86
- if results.is_a? Hash
87
- File.open("#{@options[:output_directory]}/data_point_out.json", 'w') { |f| f << JSON.pretty_generate(results) }
88
- else
89
- puts "Unknown datapoint result type. Please handle #{results.class}"
90
- end
91
- end
92
- end
93
- end
94
- end
95
- 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 'openstudio/workflow/adapters/output_adapter'
21
+
22
+ # Local file based workflow
23
+ module OpenStudio
24
+ module Workflow
25
+ module OutputAdapter
26
+ class Local < OutputAdapters
27
+ def initialize(options = {})
28
+ raise 'The required :output_directory option was not passed to the local output adapter' unless options[:output_directory]
29
+ super
30
+ end
31
+
32
+ # Write to the filesystem that the process has started
33
+ #
34
+ def communicate_started
35
+ File.open("#{@options[:output_directory]}/started.job", 'w') { |f| f << "Started Workflow #{::Time.now}" }
36
+ end
37
+
38
+ # Write to the filesystem that the process has completed
39
+ #
40
+ def communicate_complete
41
+ File.open("#{@options[:output_directory]}/finished.job", 'w') { |f| f << "Finished Workflow #{::Time.now}" }
42
+ end
43
+
44
+ # Write to the filesystem that the process has failed
45
+ #
46
+ def communicate_failure
47
+ File.open("#{@options[:output_directory]}/failed.job", 'w') { |f| f << "Failed Workflow #{::Time.now}" }
48
+ end
49
+
50
+ # Do nothing on a state transition
51
+ #
52
+ def communicate_transition(_ = nil, _ = nil, _ = nil)
53
+ end
54
+
55
+ # Do nothing on EnergyPlus stdout
56
+ #
57
+ def communicate_energyplus_stdout(_ = nil, _ = nil)
58
+ end
59
+
60
+ # Do nothing on Measure result
61
+ #
62
+ def communicate_measure_result(_ = nil, _ = nil)
63
+ end
64
+
65
+ # Write the measure attributes to the filesystem
66
+ #
67
+ def communicate_measure_attributes(measure_attributes, _ = nil)
68
+ File.open("#{@options[:output_directory]}/measure_attributes.json", 'w') do |f|
69
+ f << JSON.pretty_generate(measure_attributes)
70
+ end
71
+ end
72
+
73
+ # Write the objective function results to the filesystem
74
+ #
75
+ def communicate_objective_function(objectives, _ = nil)
76
+ obj_fun_file = "#{@options[:output_directory]}/objectives.json"
77
+ FileUtils.rm_f(obj_fun_file) if File.exist?(obj_fun_file)
78
+ File.open(obj_fun_file, 'w') { |f| f << JSON.pretty_generate(objectives) }
79
+ end
80
+
81
+ # Write the results of the workflow to the filesystem
82
+ #
83
+ def communicate_results(directory, results)
84
+ zip_results(directory)
85
+
86
+ if results.is_a? Hash
87
+ File.open("#{@options[:output_directory]}/data_point_out.json", 'w') { |f| f << JSON.pretty_generate(results) }
88
+ else
89
+ puts "Unknown datapoint result type. Please handle #{results.class}"
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -1,91 +1,91 @@
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
- require 'socket'
22
-
23
- # Local file based workflow
24
- module OpenStudio
25
- module Workflow
26
- module OutputAdapter
27
- class Socket < Local
28
- def initialize(options = {})
29
- super
30
- raise 'The required :port option was not passed to the socket output adapter' unless options[:port]
31
-
32
- @socket = TCPSocket.open 'localhost', options[:port]
33
- end
34
-
35
- def communicate_started
36
- super
37
- @socket.write("Started\n")
38
- end
39
-
40
- def communicate_results(directory, results)
41
- super
42
- end
43
-
44
- def communicate_complete
45
- super
46
- @socket.write("Complete\n")
47
- end
48
-
49
- def communicate_failure
50
- super
51
- @socket.write("Failure\n")
52
- end
53
-
54
- def communicate_objective_function(objectives, options = {})
55
- super
56
- end
57
-
58
- def communicate_transition(message, type, options = {})
59
- super
60
- @socket.write(message + "\n")
61
- end
62
-
63
- def communicate_energyplus_stdout(line, options = {})
64
- super
65
- @socket.write(line)
66
- end
67
-
68
- def communicate_measure_result(result, options = {})
69
- super
70
-
71
- step_result = result.stepResult
72
- initial_condition = result.stepInitialCondition
73
- final_condition = result.stepFinalCondition
74
- errors = result.stepErrors
75
- warnings = result.stepWarnings
76
- infos = result.stepInfo
77
-
78
- # Mirrors WorkflowStepResult::string
79
- tab = ' '
80
- @socket.write("#{tab}Result: #{step_result.get.valueName}\n") if !step_result.empty?
81
- @socket.write("#{tab}Initial Condition: #{initial_condition.get}\n") if !initial_condition.empty?
82
- @socket.write("#{tab}Final Condition: #{final_condition.get}\n") if !final_condition.empty?
83
- errors.each {|error| @socket.write("#{tab}Error: #{error}\n") }
84
- warnings.each {|warning| @socket.write("#{tab}Warn: #{warning}\n") }
85
- infos.each {|info| @socket.write("#{tab}Info: #{info}\n") }
86
- end
87
-
88
- end
89
- end
90
- end
91
- 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 'local'
21
+ require 'socket'
22
+
23
+ # Local file based workflow
24
+ module OpenStudio
25
+ module Workflow
26
+ module OutputAdapter
27
+ class Socket < Local
28
+ def initialize(options = {})
29
+ super
30
+ raise 'The required :port option was not passed to the socket output adapter' unless options[:port]
31
+
32
+ @socket = TCPSocket.open 'localhost', options[:port]
33
+ end
34
+
35
+ def communicate_started
36
+ super
37
+ @socket.write("Started\n")
38
+ end
39
+
40
+ def communicate_results(directory, results)
41
+ super
42
+ end
43
+
44
+ def communicate_complete
45
+ super
46
+ @socket.write("Complete\n")
47
+ end
48
+
49
+ def communicate_failure
50
+ super
51
+ @socket.write("Failure\n")
52
+ end
53
+
54
+ def communicate_objective_function(objectives, options = {})
55
+ super
56
+ end
57
+
58
+ def communicate_transition(message, type, options = {})
59
+ super
60
+ @socket.write(message + "\n")
61
+ end
62
+
63
+ def communicate_energyplus_stdout(line, options = {})
64
+ super
65
+ @socket.write(line)
66
+ end
67
+
68
+ def communicate_measure_result(result, options = {})
69
+ super
70
+
71
+ step_result = result.stepResult
72
+ initial_condition = result.stepInitialCondition
73
+ final_condition = result.stepFinalCondition
74
+ errors = result.stepErrors
75
+ warnings = result.stepWarnings
76
+ infos = result.stepInfo
77
+
78
+ # Mirrors WorkflowStepResult::string
79
+ tab = ' '
80
+ @socket.write("#{tab}Result: #{step_result.get.valueName}\n") if !step_result.empty?
81
+ @socket.write("#{tab}Initial Condition: #{initial_condition.get}\n") if !initial_condition.empty?
82
+ @socket.write("#{tab}Final Condition: #{final_condition.get}\n") if !final_condition.empty?
83
+ errors.each {|error| @socket.write("#{tab}Error: #{error}\n") }
84
+ warnings.each {|warning| @socket.write("#{tab}Warn: #{warning}\n") }
85
+ infos.each {|info| @socket.write("#{tab}Info: #{info}\n") }
86
+ end
87
+
88
+ end
89
+ end
90
+ end
91
+ end
@@ -1,66 +1,66 @@
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
+ # 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