Skip to content

Commit

Permalink
Merge pull request #33 from NREL/develop
Browse files Browse the repository at this point in the history
Preparation for Release 0.1.3
  • Loading branch information
nllong authored Oct 29, 2019
2 parents 9b6571b + 7bbf903 commit 385764f
Show file tree
Hide file tree
Showing 15 changed files with 355 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
# measures tests
lib/measures/.rubocop.yml
lib/measures/test_results/*

# runner conf
runner.conf
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
AllCops:
Exclude:
- gems/**/*
- lib/measures/**/*
- init_templates/**/*
- lib/measures/**/resources/*
- lib/openstudio/extension/core/**/*

inherit_from:
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# OpenStudio Extension Gem

## Version 0.1.3

* Move runner configuration options to runner initializer. Allow user to set the number of parallel simulations, max number of simulations, run the simulations (true/false), and verbose output.
* Add a runner.conf file that can be used to define how the run_osw(s) behaves.
* Add rake task to initialize the runner.conf (e.g., rake openstudio:runner:init)

## Version 0.1.2

* Support for BuildingSync gem
* Add run_osws capability

## Version 0.1.1

* Initial release
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Common Rake Tasks that are available to derivative extension gems include:
| openstudio:measures:add_readme | Add README.md.erb file if it and the README markdown file do not already exist for a measure |
| openstudio:measures:copy_resources | Copy the resources files to individual measures in the calling gem |
| openstudio:measures:update_copyright | Update copyright on measure files in the calling gem |
| rake openstudio:runner:init | Create a runner.conf file running simulations |
| openstudio:stage_bcl | Copy the measures to a location that can be uploaded to BCL |
| openstudio:push_bcl | Upload measures from the specified location to the BCL |
| openstudio:test_with_docker | Use openstudio docker image to run tests |
Expand Down Expand Up @@ -229,7 +230,7 @@ Or install it yourself as:
# TODO
- [ ] Finalize documentation on naming conventions, etc
- [X] Finalize documentation on naming conventions, etc
- [X] Add test measure
- [X] Rake task ```openstudio:update_measures```
- [X] Rake task ```openstudio:test_with_openstudio```
Expand All @@ -246,5 +247,5 @@ Or install it yourself as:
- [X] ```Runner::configure_osw``` _DLM: should take in an OSW, add paths to all measure and file dirs for loaded OpenStudio Extensions, write out configured OSW_
- [ ] Run rubocop on all of the core files and remove exclusion from .rubocop.yml file.
- [ ] Cleanup task after running tests (may need to be in the OpenStudio Measure Tester)
- [ ] Add a `rake init new_ext_gem` to Rakefile
- [X] Add a `rake init new_ext_gem` to Rakefile
- [ ] Add tests to the extension/core
4 changes: 2 additions & 2 deletions lib/measures/openstudio_extension_test_measure/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# *******************************************************************************

begin
#load OpenStudio measure libraries from common location
# load OpenStudio measure libraries from common location
require 'openstudio/extension/core/os_lib_helper_methods'
rescue LoadError
# common location unavailable, load from local resources
Expand All @@ -44,7 +44,7 @@
# start the measure
class OpenStudioExtensionTestMeasure < OpenStudio::Measure::ModelMeasure
# define the name that a user will see
def name
def name
return 'OpenStudio Extension Test Measure'
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
require_relative '../measure.rb'
require 'minitest/autorun'

class OpenStudioExtensionTestMeasure_Test < Minitest::Test
class OpenStudioExtensionTestMeasureTest < Minitest::Test
# def setup
# end

Expand Down Expand Up @@ -68,8 +68,7 @@ def test_OpenStudioExtensionTestMeasure
result = runner.result
# show_output(result)
assert(result.value.valueName == 'Success')
assert(result.warnings.size == 0)
assert(result.info.size == 0)
assert(result.warnings.empty?)
assert(result.info.empty?)
end

end
2 changes: 1 addition & 1 deletion lib/openstudio-extension.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative 'openstudio/extension'
require_relative 'openstudio/extension'
15 changes: 10 additions & 5 deletions lib/openstudio/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@

require 'openstudio/extension/version'
require 'openstudio/extension/runner'
require 'openstudio/extension/runner_config'

module OpenStudio
module Extension
class Extension
attr_accessor :root_dir

def initialize
@root_dir = File.absolute_path(File.join(File.dirname(__FILE__), '..', '..'))
# Typically one does not pass in the root path and it is defaulted as the root path of the project
# that is inheriting the extension. The root path can be overriden as needed on initialization only. This
# is mainly used for testing purposes.
# @param root_dir: string, fully qualified path of the root directory of the extension gem.
def initialize(root_dir = nil)
@root_dir = root_dir || File.absolute_path(File.join(File.dirname(__FILE__), '..', '..'))
end

# Return the absolute path of the measures or nil if there is none, used when configuring OSWs
Expand Down Expand Up @@ -83,6 +88,7 @@ def self.all_extensions
result = []
ObjectSpace.each_object(::Class) do |obj|
next if !obj.ancestors.include?(OpenStudio::Extension::Extension)

result << obj
end
return result.uniq
Expand Down Expand Up @@ -163,7 +169,7 @@ def self.check_for_name_conflicts
end

if !conflicts.empty?
raise "Conflicting file names found: #{conflicts.join(', ')}"
raise "Conflicting file names found: [#{conflicts.join(', ')}]"
end

return false
Expand Down Expand Up @@ -193,7 +199,7 @@ def self.configure_osw(in_osw)
##
# Module method used to set the measure argument for measure_dir_name to argument_value,
# argument_name must appear in the OSW or exception will be raised. If step_name is nil
# then all workflow steps matching measure_dir_name will be affected. If step_name is
# then all workflow steps matching measure_dir_name will be affected. If step_name is
# not nil, then only workflow steps matching measure_dir_name and step_name will be affected.
##
# @param [Hash] in_osw Initial OSW object as a Hash, keys should be symbolized
Expand All @@ -203,7 +209,6 @@ def self.configure_osw(in_osw)
# @param [String] step_name Optional argument, if present used to select workflow step to modify
#
# @return [Hash] Output OSW with measure argument set to argument value
#
def self.set_measure_argument(osw, measure_dir_name, argument_name, argument_value, step_name = nil)
result = false
osw[:steps].each do |step|
Expand Down
18 changes: 14 additions & 4 deletions lib/openstudio/extension/rake_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ def setup_subtasks(name)
end
end

desc 'Use openstudio docker image to run tests'
task :test_with_docker do
puts 'testing with docker'
end
# TODO: Implement this eventually... comment out for now.
# desc 'Use openstudio docker image to run tests'
# task :test_with_docker do
# puts 'testing with docker'
# end

# namespace for measure operations
namespace 'measures' do
Expand Down Expand Up @@ -125,6 +126,15 @@ def setup_subtasks(name)
end
end

# namespace for anything runner related
namespace 'runner' do
desc 'Initialize a local runner.conf file to set custom runner parameters'
task :init do
puts 'Creating runner.conf'
OpenStudio::Extension::RunnerConfig.init(Dir.pwd)
end
end

desc 'Update copyright on files'
task :update_copyright do
# update copyright
Expand Down
Loading

0 comments on commit 385764f

Please sign in to comment.