Class: OpenStudio::Workflow::OutputAdapter::Local
- Inherits:
-
OpenStudio::Workflow::OutputAdapters
- Object
- OpenStudio::Workflow::OutputAdapters
- OpenStudio::Workflow::OutputAdapter::Local
- Defined in:
- lib/openstudio/workflow/adapters/output/local.rb
Instance Attribute Summary
Attributes inherited from OpenStudio::Workflow::OutputAdapters
Instance Method Summary collapse
-
#communicate_complete ⇒ Object
Write to the filesystem that the process has completed.
-
#communicate_energyplus_stdout(_ = nil, _ = nil) ⇒ Object
Do nothing on EnergyPlus stdout.
-
#communicate_failure ⇒ Object
Write to the filesystem that the process has failed.
-
#communicate_measure_attributes(measure_attributes, _ = nil) ⇒ Object
Write the measure attributes to the filesystem.
-
#communicate_measure_result(_ = nil, _ = nil) ⇒ Object
Do nothing on Measure result.
-
#communicate_objective_function(objectives, _ = nil) ⇒ Object
Write the objective function results to the filesystem.
-
#communicate_results(directory, results) ⇒ Object
Write the results of the workflow to the filesystem.
-
#communicate_started ⇒ Object
Write to the filesystem that the process has started.
-
#communicate_transition(_ = nil, _ = nil, _ = nil) ⇒ Object
Do nothing on a state transition.
-
#initialize(options = {}) ⇒ Local
constructor
A new instance of Local.
Methods inherited from OpenStudio::Workflow::OutputAdapters
Constructor Details
#initialize(options = {}) ⇒ Local
Returns a new instance of Local.
43 44 45 46 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 43 def initialize( = {}) raise 'The required :output_directory option was not passed to the local output adapter' unless [:output_directory] super end |
Instance Method Details
#communicate_complete ⇒ Object
Write to the filesystem that the process has completed
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 64 def communicate_complete File.open("#{@options[:output_directory]}/finished.job", 'w') do |f| f << "Finished Workflow #{::Time.now}" # make sure data is written to the disk one way or the other begin f.fsync rescue StandardError f.flush end end end |
#communicate_energyplus_stdout(_ = nil, _ = nil) ⇒ Object
Do nothing on EnergyPlus stdout
96 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 96 def communicate_energyplus_stdout(_ = nil, _ = nil); end |
#communicate_failure ⇒ Object
Write to the filesystem that the process has failed
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 78 def communicate_failure File.open("#{@options[:output_directory]}/failed.job", 'w') do |f| f << "Failed Workflow #{::Time.now}" # make sure data is written to the disk one way or the other begin f.fsync rescue StandardError f.flush end end end |
#communicate_measure_attributes(measure_attributes, _ = nil) ⇒ Object
Write the measure attributes to the filesystem
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 104 def communicate_measure_attributes(measure_attributes, _ = nil) attributes_file = "#{@options[:output_directory]}/measure_attributes.json" FileUtils.rm_f(attributes_file) if File.exist?(attributes_file) File.open(attributes_file, 'w') do |f| f << JSON.pretty_generate(measure_attributes) # make sure data is written to the disk one way or the other begin f.fsync rescue StandardError f.flush end end end |
#communicate_measure_result(_ = nil, _ = nil) ⇒ Object
Do nothing on Measure result
100 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 100 def communicate_measure_result(_ = nil, _ = nil); end |
#communicate_objective_function(objectives, _ = nil) ⇒ Object
Write the objective function results to the filesystem
120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 120 def communicate_objective_function(objectives, _ = nil) obj_fun_file = "#{@options[:output_directory]}/objectives.json" FileUtils.rm_f(obj_fun_file) if File.exist?(obj_fun_file) File.open(obj_fun_file, 'w') do |f| f << JSON.pretty_generate(objectives) # make sure data is written to the disk one way or the other begin f.fsync rescue StandardError f.flush end end end |
#communicate_results(directory, results) ⇒ Object
Write the results of the workflow to the filesystem
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 136 def communicate_results(directory, results) zip_results(directory) if results.is_a? Hash # DLM: don't we want this in the results zip? # DLM: deprecate in favor of out.osw File.open("#{@options[:output_directory]}/data_point_out.json", 'w') do |f| f << JSON.pretty_generate(results) # make sure data is written to the disk one way or the other begin f.fsync rescue StandardError f.flush end end else # puts "Unknown datapoint result type. Please handle #{results.class}" end end |
#communicate_started ⇒ Object
Write to the filesystem that the process has started
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 50 def communicate_started File.open("#{@options[:output_directory]}/started.job", 'w') do |f| f << "Started Workflow #{::Time.now}" # make sure data is written to the disk one way or the other begin f.fsync rescue StandardError f.flush end end end |
#communicate_transition(_ = nil, _ = nil, _ = nil) ⇒ Object
Do nothing on a state transition
92 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 92 def communicate_transition(_ = nil, _ = nil, _ = nil); end |