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, skip_zip_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.
45 46 47 48 49 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 45 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
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 67 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
99 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 99 def communicate_energyplus_stdout(_ = nil, _ = nil); end |
#communicate_failure ⇒ Object
Write to the filesystem that the process has failed
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 81 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
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 107 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
103 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 103 def communicate_measure_result(_ = nil, _ = nil); end |
#communicate_objective_function(objectives, _ = nil) ⇒ Object
Write the objective function results to the filesystem
123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 123 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, skip_zip_results) ⇒ Object
Write the results of the workflow to the filesystem
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 139 def communicate_results(directory, results, skip_zip_results) if !skip_zip_results zip_results(directory) end 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
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 53 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
95 |
# File 'lib/openstudio/workflow/adapters/output/local.rb', line 95 def communicate_transition(_ = nil, _ = nil, _ = nil); end |