openstudio-workflow 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ac6a1a269c8cf860bd9ed5e5e7b2e0f530a2e55
4
- data.tar.gz: fec2ff61cf6032460af81428d03614871a987bcb
3
+ metadata.gz: 4d9ae4b703c92eef60ef68cb61114502b4b0e2c3
4
+ data.tar.gz: 1387f3ab160a42eb9403d8c62958622fe374baef
5
5
  SHA512:
6
- metadata.gz: a51e1394e0447d54ec727a23eb29ff2f47b3449d2e5b12ca4139920feb0695d587edec4201b6813b919de4a20a818190c015525607e8c313d0f93d29bdc13a59
7
- data.tar.gz: 160979c7c35fc78bfd390c8e8bf1a5d63ec856008356823b1691c568b70abe4bbd608f431932e6be53cd488207f58f7d61349206cf6ec9881f7a34ea38892eda
6
+ metadata.gz: f0a94a722672ef570e6819f89702605922fa3a585e2058ad976444571818fc1962ef14f42d0ff0949978a8965f1e305472ada3d2ec0566184794db5a20d699c6
7
+ data.tar.gz: 470ba2ed0e0a832256f5cc564a3bbf2fd4bbfe7449037de128230411360b9a09c58a3795188c4e24d5f19899cfe934fad58c32245ed6c87b31671d1b0de93204
@@ -30,13 +30,9 @@ class RunEnergyPlus < OpenStudio::Workflow::Job
30
30
  @logger.debug "Calling #{__method__} in the #{self.class} class"
31
31
 
32
32
  # skip if halted
33
- begin
34
- # method added in 2.1.2
35
- halted = @registry[:runner].halted
36
- @logger.info 'Workflow halted, skipping the EnergyPlus simulation'
37
- return nil if halted
38
- rescue NameError
39
- end
33
+ halted = @registry[:runner].halted
34
+ @logger.info 'Workflow halted, skipping the EnergyPlus simulation' if halted
35
+ return nil if halted
40
36
 
41
37
  # Checks and configuration
42
38
  raise 'No run_dir specified in the registry' unless @registry[:run_dir]
@@ -45,6 +45,11 @@ class RunPreprocess < OpenStudio::Workflow::Job
45
45
  apply_measures('ReportingMeasure'.to_MeasureType, @registry, @options, energyplus_output_requests)
46
46
  @logger.info('Finished collect output requests from Reporting measures.')
47
47
 
48
+ # Skip the pre-processor if halted
49
+ halted = @registry[:runner].halted
50
+ @logger.info 'Workflow halted, skipping the EnergyPlus pre-processor' if halted
51
+ return nil if halted
52
+
48
53
  # Perform pre-processing on in.idf to capture logic in RunManager
49
54
  @registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
50
55
  energyplus_preprocess(@registry[:model_idf], @logger)
@@ -46,37 +46,39 @@ class RunReportingMeasures < OpenStudio::Workflow::Job
46
46
  @registry.register(:output_attributes) { {} } unless @registry[:output_attributes]
47
47
 
48
48
  # Load simulation files as required
49
- if @registry[:model].nil?
50
- osm_path = File.absolute_path(File.join(@registry[:run_dir], 'in.osm'))
51
- @logger.debug "Attempting to load #{osm_path}"
52
- @registry.register(:model) { load_osm('.', osm_path) }
53
- raise "Unable to load #{osm_path}" unless @registry[:model]
54
- @logger.debug "Successfully loaded #{osm_path}"
55
- end
56
- if @registry[:model_idf].nil?
57
- idf_path = File.absolute_path(File.join(@registry[:run_dir], 'in.idf'))
58
- @logger.debug "Attempting to load #{idf_path}"
59
- @registry.register(:model_idf) { load_idf(idf_path, @logger) }
60
- raise "Unable to load #{idf_path}" unless @registry[:model_idf]
61
- @logger.debug "Successfully loaded #{idf_path}"
62
- end
63
- if @registry[:sql].nil?
64
- sql_path = File.absolute_path(File.join(@registry[:run_dir], 'eplusout.sql'))
65
- if File.exists?(sql_path)
66
- @registry.register(:sql) { sql_path }
67
- @logger.debug "Registered the sql filepath as #{@registry[:sql]}"
49
+ unless @registry[:runner].halted
50
+ if @registry[:model].nil?
51
+ osm_path = File.absolute_path(File.join(@registry[:run_dir], 'in.osm'))
52
+ @logger.debug "Attempting to load #{osm_path}"
53
+ @registry.register(:model) { load_osm('.', osm_path) }
54
+ raise "Unable to load #{osm_path}" unless @registry[:model]
55
+ @logger.debug "Successfully loaded #{osm_path}"
68
56
  end
69
- #raise "Unable to load #{sql_path}" unless @registry[:sql]
70
- end
71
- if @registry[:wf].nil?
72
- epw_path = File.absolute_path(File.join(@registry[:run_dir], 'in.epw'))
73
- if File.exists?(epw_path)
74
- @registry.register(:wf) { epw_path }
75
- @logger.debug "Registered the wf filepath as #{@registry[:wf]}"
57
+ if @registry[:model_idf].nil?
58
+ idf_path = File.absolute_path(File.join(@registry[:run_dir], 'in.idf'))
59
+ @logger.debug "Attempting to load #{idf_path}"
60
+ @registry.register(:model_idf) { load_idf(idf_path, @logger) }
61
+ raise "Unable to load #{idf_path}" unless @registry[:model_idf]
62
+ @logger.debug "Successfully loaded #{idf_path}"
63
+ end
64
+ if @registry[:sql].nil?
65
+ sql_path = File.absolute_path(File.join(@registry[:run_dir], 'eplusout.sql'))
66
+ if File.exists?(sql_path)
67
+ @registry.register(:sql) { sql_path }
68
+ @logger.debug "Registered the sql filepath as #{@registry[:sql]}"
69
+ end
70
+ #raise "Unable to load #{sql_path}" unless @registry[:sql]
71
+ end
72
+ if @registry[:wf].nil?
73
+ epw_path = File.absolute_path(File.join(@registry[:run_dir], 'in.epw'))
74
+ if File.exists?(epw_path)
75
+ @registry.register(:wf) { epw_path }
76
+ @logger.debug "Registered the wf filepath as #{@registry[:wf]}"
77
+ end
78
+ #raise "Unable to load #{epw_path}" unless @registry[:wf]
76
79
  end
77
- #raise "Unable to load #{epw_path}" unless @registry[:wf]
78
80
  end
79
-
81
+
80
82
  # Apply reporting measures
81
83
  @options[:output_adapter] = @output_adapter
82
84
  @logger.info 'Beginning to execute Reporting measures.'
@@ -30,14 +30,12 @@ class RunTranslation < OpenStudio::Workflow::Job
30
30
  @logger.debug "Calling #{__method__} in the #{self.class} class"
31
31
 
32
32
  # skip if halted
33
- begin
34
- # method added in 2.1.2
35
- halted = @registry[:runner].halted
36
- @logger.info 'Workflow halted, skipping EnergyPlus translation'
37
- return nil if halted
38
- rescue NameError
33
+ if @registry[:runner].halted
34
+ @logger.info 'Workflow halted, skipping OSM to IDF translation'
35
+ @registry.register(:model_idf) { OpenStudio::Workspace.new } # This allows model arguments to still be calculated
36
+ return nil
39
37
  end
40
-
38
+
41
39
  # Ensure that the run directory is created
42
40
  FileUtils.mkdir_p(@registry[:run_dir])
43
41
 
@@ -223,6 +223,8 @@ module OpenStudio
223
223
  # completed status will already be set if workflow was halted
224
224
  if @registry[:workflow_json].completedStatus.empty?
225
225
  @registry[:workflow_json].setCompletedStatus('Success')
226
+ else
227
+ @current_state = :errored if @registry[:workflow_json].completedStatus.get == 'Fail'
226
228
  end
227
229
  end
228
230
 
@@ -58,19 +58,17 @@ module OpenStudio
58
58
  else
59
59
  logger.info "Found measure #{class_name} of type #{measure_type.valueName}. Applying now."
60
60
 
61
- # fast forward current step index to this index, skips any previous steps
62
- while workflow_json.currentStepIndex < step_index
63
- workflow_json.incrementStep
64
- end
65
-
66
61
  # check if simulation has been halted
67
- halted = false
68
- begin
69
- # method added in 2.1.2
70
- halted = runner.halted
71
- rescue NameError
62
+ halted = runner.halted
63
+
64
+ # fast forward current step index to this index, skips any previous steps
65
+ # DLM: this is needed when running reporting measures only
66
+ if !halted
67
+ while workflow_json.currentStepIndex < step_index
68
+ workflow_json.incrementStep
69
+ end
72
70
  end
73
-
71
+
74
72
  # DLM: why is output_adapter in options instead of registry?
75
73
  options[:output_adapter].communicate_transition("Applying #{class_name}", :measure) if options[:output_adapter]
76
74
  apply_measure(registry, step, options, energyplus_output_requests, halted)
@@ -416,19 +414,24 @@ module OpenStudio
416
414
 
417
415
  if skip_measure || halted
418
416
  if !energyplus_output_requests
419
- # just increment
420
- logger.debug "Skipping measure '#{measure_dir_name}'"
421
-
422
- # required to update current step
423
- runner.prepareForUserScriptRun(measure_object)
424
-
425
- # don't want to log errors about arguments passed to skipped measures
426
- #runner.validateUserArguments(arguments, argument_map)
417
+ if halted
418
+ # if halted then this measure will not get run, there are no results, not even "Skip"
419
+ logger.info "Skipping measure '#{measure_dir_name}' because simulation halted"
420
+
421
+ else
422
+ logger.info "Skipping measure '#{measure_dir_name}'"
423
+
424
+ # required to update current step, will do nothing if halted
425
+ runner.prepareForUserScriptRun(measure_object)
426
+
427
+ # don't want to log errors about arguments passed to skipped measures
428
+ #runner.validateUserArguments(arguments, argument_map
427
429
 
428
- current_result = runner.result
429
- runner.incrementStep
430
- add_result_measure_info(current_result, measure)
431
- current_result.setStepResult('Skip'.to_StepResult)
430
+ current_result = runner.result
431
+ runner.incrementStep
432
+ add_result_measure_info(current_result, measure)
433
+ current_result.setStepResult('Skip'.to_StepResult)
434
+ end
432
435
  end
433
436
  else
434
437
 
@@ -578,7 +581,7 @@ module OpenStudio
578
581
 
579
582
  end
580
583
 
581
- rescue => e
584
+ rescue ScriptError, StandardError, NoMemoryError => e
582
585
  log_message = "#{__FILE__} failed with message #{e.message} in #{e.backtrace.join("\n")}"
583
586
  logger.error log_message
584
587
  raise log_message
@@ -19,6 +19,6 @@
19
19
 
20
20
  module OpenStudio
21
21
  module Workflow
22
- VERSION = '1.3.0'.freeze # Suffixes must have periods (not dashes)
22
+ VERSION = '1.3.1'.freeze # Suffixes must have periods (not dashes)
23
23
  end
24
24
  end
@@ -236,6 +236,7 @@ class WorkflowJSON_Shim
236
236
  # bool incrementStep();
237
237
  def incrementStep
238
238
  @current_step_index += 1
239
+ @workflow[:current_step] = @current_step_index
239
240
 
240
241
  if @current_step_index < @workflow[:steps].size
241
242
  return true
@@ -28,7 +28,9 @@ class WorkflowRunner < OpenStudio::Ruleset::OSRunner
28
28
  @openstudio_2 = openstudio_2
29
29
  @datapoint = nil
30
30
  @analysis = nil
31
-
31
+ @halted = false
32
+ @use_os_halted = OpenStudio::Ruleset::OSRunner.method_defined?(:halted)
33
+
32
34
  begin
33
35
  # OpenStudio 2.X
34
36
  super(@workflow_json)
@@ -95,6 +97,7 @@ class WorkflowRunner < OpenStudio::Ruleset::OSRunner
95
97
  # only called in OpenStudio 1.X
96
98
  # virtual void prepareForUserScriptRun(const UserScript& userScript);
97
99
  def prepareForUserScriptRun(userScript)
100
+
98
101
  if @openstudio_2
99
102
  prepareForMeasureRun(userScript)
100
103
  else
@@ -230,4 +233,20 @@ class WorkflowRunner < OpenStudio::Ruleset::OSRunner
230
233
  super
231
234
  @multi_logger.info message
232
235
  end
236
+
237
+ # Overload haltSimulation
238
+ def haltWorkflow(completed_status)
239
+ if @use_os_halted
240
+ super
241
+ else
242
+ @halted = true
243
+ @workflow_json.setCompletedStatus(completed_status)
244
+ end
245
+ end
246
+
247
+ # Overload halted
248
+ def halted
249
+ return @halted unless @use_os_halted
250
+ super
251
+ end
233
252
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstudio-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Long
@@ -9,34 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-06-15 00:00:00.000000000 Z
12
+ date: 2017-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.6'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.6'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: json-schema
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  description: Run OpenStudio based measures and simulations using EnergyPlus
@@ -47,6 +47,10 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
+ - CHANGELOG.md
51
+ - README.md
52
+ - Rakefile
53
+ - lib/openstudio-workflow.rb
50
54
  - lib/openstudio/workflow/adapters/input/local.rb
51
55
  - lib/openstudio/workflow/adapters/output/local.rb
52
56
  - lib/openstudio/workflow/adapters/output/socket.rb
@@ -66,20 +70,16 @@ files:
66
70
  - lib/openstudio/workflow/registry.rb
67
71
  - lib/openstudio/workflow/run.rb
68
72
  - lib/openstudio/workflow/time_logger.rb
73
+ - lib/openstudio/workflow/util.rb
69
74
  - lib/openstudio/workflow/util/energyplus.rb
70
75
  - lib/openstudio/workflow/util/io.rb
71
76
  - lib/openstudio/workflow/util/measure.rb
72
77
  - lib/openstudio/workflow/util/model.rb
73
78
  - lib/openstudio/workflow/util/post_process.rb
74
79
  - lib/openstudio/workflow/util/weather_file.rb
75
- - lib/openstudio/workflow/util.rb
76
80
  - lib/openstudio/workflow/version.rb
77
81
  - lib/openstudio/workflow_json.rb
78
82
  - lib/openstudio/workflow_runner.rb
79
- - lib/openstudio-workflow.rb
80
- - README.md
81
- - CHANGELOG.md
82
- - Rakefile
83
83
  homepage: https://github.com/NREL/OpenStudio-workflow-gem
84
84
  licenses:
85
85
  - LGPL
@@ -90,17 +90,17 @@ require_paths:
90
90
  - lib
91
91
  required_ruby_version: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - '>='
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '2.0'
96
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - '>='
98
+ - - ">="
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 2.0.14.1
103
+ rubygems_version: 2.6.10
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: OpenStudio Workflow Manager