Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nllong committed Dec 8, 2020
2 parents 7e80569 + bf6df3d commit ca0ec88
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.bundle/
/.yardoc
/.ruby-version
/.python-version
/Gemfile.lock
/gems
/_yardoc/
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# OpenStudio Extension Gem

## Version 0.3.2

* Update Extension Gem Template
* Add gemfile path instead of just dirname to the initialization
* Update to latest workflow gem to support URBANopt Workflow

## Version 0.3.1

* This change first zeroes-out latent (for good measure) and radiant fractions before setting lost fraction to 1.0 to avoid this error.

## Version 0.3.0
Expand Down
12 changes: 7 additions & 5 deletions init_templates/gemspec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler', '~> 1.14'
spec.add_development_dependency 'rake', '12.3.1'
spec.add_development_dependency 'rspec', '3.7.0'
spec.required_ruby_version = '~> 2.5.0'

spec.add_development_dependency 'bundler', '~> 2.1'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.9'
spec.add_development_dependency 'rubocop', '~> 0.54.0'

spec.add_dependency 'openstudio-extension', '~> 0.1.0'
spec.add_dependency 'openstudio-standards', '~> 0.2.7'
spec.add_dependency 'openstudio-extension', '~> 0.3.1'
spec.add_dependency 'openstudio-standards', '~> 0.2.12'
end
5 changes: 1 addition & 4 deletions init_templates/template_gemfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ elsif allow_local
gem 'openstudio-extension', github: 'NREL/OpenStudio-extension-gem', branch: 'develop'
end

gem 'openstudio_measure_tester', '= 0.1.7' # This includes the dependencies for running unit tests, coverage, and rubocop

# simplecov has an unnecessary dependency on native json gem, use fork that does not require this
gem 'simplecov', github: 'NREL/simplecov'
gem 'openstudio_measure_tester', '~> 0.2.3' # This includes the dependencies for running unit tests, coverage, and rubocop
22 changes: 13 additions & 9 deletions lib/openstudio/extension/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class Runner
# @option options [String] :num_parallel Number of simulations to run in parallel at a time
# @option options [String] :run_simulations Set to true to run the simulations
# @option options [String] :verbose Set to true to receive extra information while running simulations
# @option options [String] :gemfile_path Path to gemfile to use
# @option options [String] :bundle_install_path Path where the bundle should be installed
def initialize(dirname = Dir.pwd, bundle_without = [], options = {})
# DLM: I am not sure if we want to use the main root directory to create these bundles
# had the idea of passing in a Gemfile name/alias and path to Gemfile, then doing the bundle
Expand All @@ -88,9 +90,14 @@ def initialize(dirname = Dir.pwd, bundle_without = [], options = {})
@gemfile_path = !@options.key?(:gemfile_path) || @options[:gemfile_path] === '' ? File.join(@dirname, 'Gemfile') : @options[:gemfile_path]
@bundle_install_path = !@options.key?(:bundle_install_path) || @options[:bundle_install_path] === '' ? File.join(@dirname, '.bundle/install/') : @options[:bundle_install_path]
@original_dir = Dir.pwd

# gemfile directory
@gemfile_dir = File.dirname(@gemfile_path)

# puts "DIRNAME: #{@dirname}"
# puts "@gemfile_path set to: #{@gemfile_path}"
# puts "@bundle_install_path set to: #{@bundle_install_path}"
# puts "@gemfile directory: #{@gemfile_dir}"

@bundle_without = bundle_without || []
@bundle_without_string = @bundle_without.join(' ')
Expand All @@ -106,8 +113,8 @@ def initialize(dirname = Dir.pwd, bundle_without = [], options = {})
else
# there is a gemfile, attempt to create a bundle
begin
# go to the directory with the gemfile
Dir.chdir(@dirname)
# go to the directory with the gemfile to run these commands
Dir.chdir(@gemfile_dir)

# test to see if bundle is installed
check_bundle = run_command('bundle -v', get_clean_env)
Expand All @@ -119,7 +126,7 @@ def initialize(dirname = Dir.pwd, bundle_without = [], options = {})

# check existing config
needs_config = true
if File.exist?('./.bundle/config')
if File.exist?('./.bundle/config') # checking wrt gemfile_dir
puts 'config exists'
needs_config = false
config = YAML.load_file('./.bundle/config')
Expand All @@ -135,7 +142,7 @@ def initialize(dirname = Dir.pwd, bundle_without = [], options = {})

# check existing platform
needs_platform = true
if File.exist?('Gemfile.lock')
if File.exist?('Gemfile.lock') # checking wrt gemfile_dir
puts 'Gemfile.lock exists'
gemfile_lock = Bundler::LockfileParser.new(Bundler.read_file('Gemfile.lock'))
if gemfile_lock.platforms.include?('ruby')
Expand Down Expand Up @@ -164,9 +171,7 @@ def initialize(dirname = Dir.pwd, bundle_without = [], options = {})

puts "needs_update = #{needs_update}"
if needs_update
# run_command('bundle update', get_clean_env)
# KAF: updated to include specified gemfile_path...this didn't seem to work before
run_command("bundle update --gemfile=#{@gemfile_path}", get_clean_env)
run_command('bundle update', get_clean_env)
end
ensure
Dir.chdir(@original_dir)
Expand Down Expand Up @@ -220,8 +225,7 @@ def run_command(command, env = {})
result = false
original_dir = Dir.pwd
begin
Dir.chdir(@dirname)

Dir.chdir(@gemfile_dir)
# DLM: using popen3 here can result in deadlocks
stdout_str, stderr_str, status = Open3.capture3(env, command)
if status.success?
Expand Down
2 changes: 1 addition & 1 deletion lib/openstudio/extension/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@

module OpenStudio
module Extension
VERSION = '0.3.1'.freeze
VERSION = '0.3.2'.freeze
end
end
2 changes: 1 addition & 1 deletion openstudio-extension.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'bcl', '~> 0.6.1'
spec.add_dependency 'bundler', '~> 2.1'
spec.add_dependency 'octokit', '~> 4.18.0' # for change logs
spec.add_dependency 'openstudio-workflow', '~> 2.1.0'
spec.add_dependency 'openstudio-workflow', '~> 2.1.1'
spec.add_dependency 'openstudio_measure_tester', '~> 0.2.3'
spec.add_dependency 'parallel', '~> 1.19.1'

Expand Down

0 comments on commit ca0ec88

Please sign in to comment.