Module: OpenStudio::Workflow
- Extended by:
- Workflow
- Included in:
- Workflow
- Defined in:
- lib/openstudio-workflow.rb,
lib/openstudio/workflow/run.rb,
lib/openstudio/workflow/adapter.rb,
lib/openstudio/workflow/version.rb,
lib/openstudio/workflow/adapters/local.rb,
lib/openstudio/workflow/adapters/mongo.rb,
lib/openstudio/workflow/jobs/lib/apply_measures.rb
Defined Under Namespace
Modules: Adapters, ApplyMeasures Classes: Adapter, Run
Constant Summary collapse
- VERSION =
'0.1.1'
Instance Method Summary collapse
-
#extract_archive(archive_filename, destination, overwrite = true) ⇒ Object
Extract an archive to a specific location.
-
#load(adapter_name, run_directory, options = {}) ⇒ Object
Create a new workflow instance using the defined adapter and UUID.
-
#run_energyplus(adapter_name, run_directory, options = {}) ⇒ Object
predefined method that simply runs EnergyPlus in the specified directory.
Instance Method Details
#extract_archive(archive_filename, destination, overwrite = true) ⇒ Object
Extract an archive to a specific location
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/openstudio-workflow.rb', line 130 def extract_archive(archive_filename, destination, overwrite = true) Zip::File.open(archive_filename) do |zf| zf.each do |f| f_path = File.join(destination, f.name) FileUtils.mkdir_p(File.dirname(f_path)) if File.exist?(f_path) && overwrite FileUtils.rm_rf(f_path) zf.extract(f, f_path) elsif !File.exist? f_path zf.extract(f, f_path) end end end end |
#load(adapter_name, run_directory, options = {}) ⇒ Object
Create a new workflow instance using the defined adapter and UUID
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/openstudio-workflow.rb', line 66 def load(adapter_name, run_directory, = {}) defaults = { adapter_options: {} } = defaults.merge() # Convert various paths to absolute paths if [:adapter_options] && [:adapter_options][:mongoid_path] && (Pathname.new [:adapter_options][:mongoid_path]).absolute? == false [:adapter_options][:mongoid_path] = File. [:adapter_options][:mongoid_path] end if [:analysis_root_path] && (Pathname.new [:analysis_root_path]).absolute? == false [:analysis_root_path] = File. [:analysis_root_path] end unless (Pathname.new run_directory).absolute? # relative to wherever you are running the script run_directory = File. run_directory end adapter = load_adapter adapter_name, [:adapter_options] run_klass = OpenStudio::Workflow::Run.new(adapter, run_directory, ) # return the run class run_klass end |
#run_energyplus(adapter_name, run_directory, options = {}) ⇒ Object
predefined method that simply runs EnergyPlus in the specified directory. It does not apply any workflow steps such as preprocessing / postprocessing. The directory must have the IDF and EPW file in the folder. The simulations will run in the directory/run path
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/openstudio-workflow.rb', line 96 def run_energyplus(adapter_name, run_directory, = {}) unless (Pathname.new run_directory).absolute? # relative to wherever you are running the script run_directory = File. run_directory end transitions = [ { from: :queued, to: :preflight }, { from: :preflight, to: :energyplus }, { from: :energyplus, to: :finished } ] states = [ { state: :queued, options: { initial: true } }, { state: :preflight, options: { after_enter: :run_preflight } }, { state: :energyplus, options: { after_enter: :run_energyplus } }, { state: :finished }, { state: :errored } ] = { transitions: transitions, states: states } adapter = load_adapter adapter_name, [:adapter_options] run_klass = OpenStudio::Workflow::Run.new(adapter, run_directory, ) run_klass end |