openstudio-extension 0.2.1 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  # *******************************************************************************
4
2
  # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
5
3
  # All rights reserved.
@@ -43,6 +41,7 @@ require 'openstudio'
43
41
  require 'yaml'
44
42
  require 'fileutils'
45
43
  require 'parallel'
44
+ require 'bcl'
46
45
 
47
46
  module OpenStudio
48
47
  module Extension
@@ -57,7 +56,7 @@ module OpenStudio
57
56
  # compatible with the OpenStudio CLI.
58
57
  ##
59
58
  # @param [String] dirname Directory to run commands in, defaults to Dir.pwd. If directory includes a Gemfile then create a local bundle.
60
- # @param bundle_without [Hash] Hash describing the distribution of the variable.
59
+ # @param bundle_without [Array] List of strings of the groups to exclude when running the bundle command
61
60
  # @param options [Hash] Hash describing options for running the simulation. These are the defaults for all runs unless overriden within the run_* methods. Note if options is used, then a local runner.conf file will not be loaded.
62
61
  # @option options [String] :max_datapoints Max number of datapoints to run
63
62
  # @option options [String] :num_parallel Number of simulations to run in parallel at a time
@@ -69,20 +68,29 @@ module OpenStudio
69
68
  # in ~/OpenStudio/#{alias} or something like that?
70
69
 
71
70
  # if the dirname contains a runner.conf file, then use the config file to specify the parameters
71
+
72
+ @options = OpenStudio::Extension::RunnerConfig.default_config
73
+ # ORDER of PRECEDENCE: default config < runner.conf file < options passed in directly
72
74
  if File.exist?(File.join(dirname, OpenStudio::Extension::RunnerConfig::FILENAME)) && options.empty?
73
75
  puts 'Using runner options from runner.conf file'
74
76
  runner_config = OpenStudio::Extension::RunnerConfig.new(dirname)
75
- @options = runner_config.options
76
- else
77
- # use the passed values or defaults overriden by passed options
78
- @options = OpenStudio::Extension::RunnerConfig.default_config.merge(options)
77
+ # use the default values overriden with runner.conf values
78
+ @options = @options.merge(runner_config.options)
79
79
  end
80
80
 
81
+ # use the passed values or defaults overriden by passed options
82
+ @options = @options.merge(options)
83
+
81
84
  puts "Initializing runner with dirname: '#{dirname}' and options: #{@options}"
82
85
  @dirname = File.absolute_path(dirname)
83
- @gemfile_path = File.join(@dirname, 'Gemfile')
84
- @bundle_install_path = File.join(@dirname, '.bundle/install/')
86
+
87
+ # use passed options, otherwise assume @dirname
88
+ @gemfile_path = !@options.key?(:gemfile_path) || @options[:gemfile_path] === '' ? File.join(@dirname, 'Gemfile') : @options[:gemfile_path]
89
+ @bundle_install_path = !@options.key?(:bundle_install_path) || @options[:bundle_install_path] === '' ? File.join(@dirname, '.bundle/install/') : @options[:bundle_install_path]
85
90
  @original_dir = Dir.pwd
91
+ # puts "DIRNAME: #{@dirname}"
92
+ # puts "@gemfile_path set to: #{@gemfile_path}"
93
+ # puts "@bundle_install_path set to: #{@bundle_install_path}"
86
94
 
87
95
  @bundle_without = bundle_without || []
88
96
  @bundle_without_string = @bundle_without.join(' ')
@@ -156,7 +164,9 @@ module OpenStudio
156
164
 
157
165
  puts "needs_update = #{needs_update}"
158
166
  if needs_update
159
- run_command('bundle update', get_clean_env)
167
+ # run_command('bundle update', get_clean_env)
168
+ # KAF: updated to include specified gemfile_path...this didn't seem to work before
169
+ run_command("bundle update --gemfile=#{@gemfile_path}", get_clean_env)
160
170
  end
161
171
  ensure
162
172
  Dir.chdir(@original_dir)
@@ -562,12 +572,12 @@ module OpenStudio
562
572
  puts "Encoding.default_internal = #{Encoding.default_internal}"
563
573
 
564
574
  paths.each do |path|
565
- Dir[path[:glob]].each do |file|
566
- puts "Updating license in file #{file}"
567
- f = File.read(file)
575
+ Dir[path[:glob]].each do |dir_file|
576
+ puts "Updating license in file #{dir_file}"
577
+ f = File.read(dir_file)
568
578
  if f.match?(path[:regex])
569
579
  puts ' License found -- updating'
570
- File.open(file, 'w') { |write| write << f.gsub(path[:regex], path[:license]) }
580
+ File.open(dir_file, 'w') { |write| write << f.gsub(path[:regex], path[:license]) }
571
581
  elsif f =~ /\(C\)/i || f =~ /\(Copyright\)/i
572
582
  puts ' File already has copyright -- skipping'
573
583
  else
@@ -576,7 +586,7 @@ module OpenStudio
576
586
  puts ' CANNOT add license to file automatically, add it manually and it will update automatically in the future'
577
587
  next
578
588
  end
579
- File.open(file, 'w') { |write| write << f.insert(0, path[:license] + "\n") }
589
+ File.open(dir_file, 'w') { |write| write << f.insert(0, path[:license] + "\n") }
580
590
  end
581
591
  end
582
592
  end
@@ -646,7 +656,16 @@ module OpenStudio
646
656
  puts 'simulations are not performed, since to the @options[:run_simulations] is set to false'
647
657
  end
648
658
 
649
- # DLM: this does not always return false for failed CLI runs, consider checking for failed.job file as backup test
659
+ if @options[:run_simulations]
660
+ # Additional checks for failed CLI
661
+ if File.exist?(File.join(run_dir, 'failed.job'))
662
+ result = false
663
+ end
664
+
665
+ if !File.exist?(File.join(run_dir, 'finished.job'))
666
+ result = false
667
+ end
668
+ end
650
669
 
651
670
  return result
652
671
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  # *******************************************************************************
4
2
  # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
5
3
  # All rights reserved.
@@ -40,7 +38,7 @@ require 'json'
40
38
  module OpenStudio
41
39
  module Extension
42
40
  class RunnerConfig
43
- FILENAME = 'runner.conf'
41
+ FILENAME = 'runner.conf'.freeze
44
42
 
45
43
  ##
46
44
  # Class to store configuration of the runner options.
@@ -80,7 +78,9 @@ module OpenStudio
80
78
  max_datapoints: 1E9.to_i,
81
79
  num_parallel: 2,
82
80
  run_simulations: true,
83
- verbose: false
81
+ verbose: false,
82
+ gemfile_path: '',
83
+ bundle_install_path: ''
84
84
  }
85
85
  end
86
86
 
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  # *******************************************************************************
4
2
  # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
5
3
  # All rights reserved.
@@ -37,6 +35,6 @@
37
35
 
38
36
  module OpenStudio
39
37
  module Extension
40
- VERSION = '0.2.1'
38
+ VERSION = '0.2.6'.freeze
41
39
  end
42
40
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'openstudio/extension/version'
@@ -22,7 +20,7 @@ Gem::Specification.new do |spec|
22
20
  }
23
21
 
24
22
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
- f.match(%r{^(test|spec|features)/})
23
+ f.match(%r{^(test|lib.measures.*tests|spec|features)/})
26
24
  end
27
25
  spec.bindir = 'exe'
28
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -30,12 +28,13 @@ Gem::Specification.new do |spec|
30
28
 
31
29
  spec.required_ruby_version = '~> 2.5.0'
32
30
 
31
+ spec.add_dependency 'bcl', '~> 0.6.1'
33
32
  spec.add_dependency 'bundler', '~> 2.1'
33
+ spec.add_dependency 'octokit', '~> 4.18.0' # for change logs
34
34
  spec.add_dependency 'openstudio-workflow', '~> 2.0.0'
35
- spec.add_dependency 'openstudio_measure_tester', '~> 0.2.2'
35
+ spec.add_dependency 'openstudio_measure_tester', '~> 0.2.3'
36
36
  spec.add_dependency 'parallel', '~> 1.19.1'
37
37
 
38
- spec.add_development_dependency 'github_api', '~> 0.18.0'
39
38
  spec.add_development_dependency 'rake', '~> 13.0'
40
39
  spec.add_development_dependency 'rspec', '~> 3.9'
41
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstudio-extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katherine Fleming
@@ -10,8 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-04-07 00:00:00.000000000 Z
13
+ date: 2021-01-15 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bcl
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: 0.6.1
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: bundler
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -27,61 +41,61 @@ dependencies:
27
41
  - !ruby/object:Gem::Version
28
42
  version: '2.1'
29
43
  - !ruby/object:Gem::Dependency
30
- name: openstudio-workflow
44
+ name: octokit
31
45
  requirement: !ruby/object:Gem::Requirement
32
46
  requirements:
33
47
  - - "~>"
34
48
  - !ruby/object:Gem::Version
35
- version: 2.0.0
49
+ version: 4.18.0
36
50
  type: :runtime
37
51
  prerelease: false
38
52
  version_requirements: !ruby/object:Gem::Requirement
39
53
  requirements:
40
54
  - - "~>"
41
55
  - !ruby/object:Gem::Version
42
- version: 2.0.0
56
+ version: 4.18.0
43
57
  - !ruby/object:Gem::Dependency
44
- name: openstudio_measure_tester
58
+ name: openstudio-workflow
45
59
  requirement: !ruby/object:Gem::Requirement
46
60
  requirements:
47
61
  - - "~>"
48
62
  - !ruby/object:Gem::Version
49
- version: 0.2.2
63
+ version: 2.0.0
50
64
  type: :runtime
51
65
  prerelease: false
52
66
  version_requirements: !ruby/object:Gem::Requirement
53
67
  requirements:
54
68
  - - "~>"
55
69
  - !ruby/object:Gem::Version
56
- version: 0.2.2
70
+ version: 2.0.0
57
71
  - !ruby/object:Gem::Dependency
58
- name: parallel
72
+ name: openstudio_measure_tester
59
73
  requirement: !ruby/object:Gem::Requirement
60
74
  requirements:
61
75
  - - "~>"
62
76
  - !ruby/object:Gem::Version
63
- version: 1.19.1
77
+ version: 0.2.3
64
78
  type: :runtime
65
79
  prerelease: false
66
80
  version_requirements: !ruby/object:Gem::Requirement
67
81
  requirements:
68
82
  - - "~>"
69
83
  - !ruby/object:Gem::Version
70
- version: 1.19.1
84
+ version: 0.2.3
71
85
  - !ruby/object:Gem::Dependency
72
- name: github_api
86
+ name: parallel
73
87
  requirement: !ruby/object:Gem::Requirement
74
88
  requirements:
75
89
  - - "~>"
76
90
  - !ruby/object:Gem::Version
77
- version: 0.18.0
78
- type: :development
91
+ version: 1.19.1
92
+ type: :runtime
79
93
  prerelease: false
80
94
  version_requirements: !ruby/object:Gem::Requirement
81
95
  requirements:
82
96
  - - "~>"
83
97
  - !ruby/object:Gem::Version
84
- version: 0.18.0
98
+ version: 1.19.1
85
99
  - !ruby/object:Gem::Dependency
86
100
  name: rake
87
101
  requirement: !ruby/object:Gem::Requirement
@@ -154,7 +168,6 @@ files:
154
168
  - lib/measures/openstudio_extension_test_measure/measure.rb
155
169
  - lib/measures/openstudio_extension_test_measure/measure.xml
156
170
  - lib/measures/openstudio_extension_test_measure/resources/os_lib_helper_methods.rb
157
- - lib/measures/openstudio_extension_test_measure/tests/openstudio_extension_test_measure_test.rb
158
171
  - lib/openstudio-extension.rb
159
172
  - lib/openstudio/extension.rb
160
173
  - lib/openstudio/extension/core/CreateResults.rb
@@ -205,7 +218,7 @@ licenses: []
205
218
  metadata:
206
219
  bug_tracker_uri: https://github.com/NREL/openstudio-extension-gem/issues
207
220
  changelog_uri: https://github.com/NREL/openstudio-extension-gem/blob/develop/CHANGELOG.md
208
- source_code_uri: https://github.com/NREL/openstudio-extension-gem/tree/v0.2.1
221
+ source_code_uri: https://github.com/NREL/openstudio-extension-gem/tree/v0.2.6
209
222
  post_install_message:
210
223
  rdoc_options: []
211
224
  require_paths:
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # *******************************************************************************
4
- # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
5
- # All rights reserved.
6
- # Redistribution and use in source and binary forms, with or without
7
- # modification, are permitted provided that the following conditions are met:
8
- #
9
- # (1) Redistributions of source code must retain the above copyright notice,
10
- # this list of conditions and the following disclaimer.
11
- #
12
- # (2) Redistributions in binary form must reproduce the above copyright notice,
13
- # this list of conditions and the following disclaimer in the documentation
14
- # and/or other materials provided with the distribution.
15
- #
16
- # (3) Neither the name of the copyright holder nor the names of any contributors
17
- # may be used to endorse or promote products derived from this software without
18
- # specific prior written permission from the respective party.
19
- #
20
- # (4) Other than as required in clauses (1) and (2), distributions in any form
21
- # of modifications or other derivative works may not use the "OpenStudio"
22
- # trademark, "OS", "os", or any other confusingly similar designation without
23
- # specific prior written permission from Alliance for Sustainable Energy, LLC.
24
- #
25
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
26
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
- # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
29
- # UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
30
- # THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
32
- # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34
- # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35
- # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
- # *******************************************************************************
37
-
38
- require 'openstudio'
39
- require 'openstudio/measure/ShowRunnerOutput'
40
-
41
- require_relative '../measure.rb'
42
- require 'minitest/autorun'
43
-
44
- class OpenStudioExtensionTestMeasureTest < Minitest::Test
45
- # def setup
46
- # end
47
-
48
- # def teardown
49
- # end
50
-
51
- def test_OpenStudioExtensionTestMeasure
52
- # create an instance of the measure
53
- measure = OpenStudioExtensionTestMeasure.new
54
-
55
- # create an instance of a runner
56
- runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
57
-
58
- # make an empty model
59
- model = OpenStudio::Model::Model.new
60
-
61
- # get arguments and test that they are what we are expecting
62
- arguments = measure.arguments(model)
63
- assert_equal(0, arguments.size)
64
-
65
- # set argument values to good values and run the measure on model with spaces
66
- arguments = measure.arguments(model)
67
- argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
68
-
69
- measure.run(model, runner, argument_map)
70
- result = runner.result
71
- # show_output(result)
72
- assert(result.value.valueName == 'Success')
73
- assert(result.warnings.empty?)
74
- assert(result.info.empty?)
75
- end
76
- end