Skip to content

Commit

Permalink
Merge pull request #80 from urbanopt/develop
Browse files Browse the repository at this point in the history
Version 0.2.1
  • Loading branch information
kflemin authored Mar 31, 2020
2 parents 5578aab + e0b5356 commit ed9da15
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 0.2.1

Date Range: 03/31/20 - 03/31/20

- Fixed [#77]( https://github.com/urbanopt/urbanopt-cli/issues/77 ), Undefined local variable

## Version 0.2.0

Date Range: 02/14/20 - 03/31/20
Expand Down
3 changes: 0 additions & 3 deletions example_files/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,5 @@ else
# gem 'urbanopt-geojson', github: 'URBANopt/urbanopt-geojson-gem', branch: 'develop'
end

# simplecov has an unneccesary dependency on native json gem, use fork that does not require this
gem 'simplecov', github: 'NREL/simplecov'

# Fix rack version temporarily to work with Ruby 2.2.4
gem 'rack', '2.1.2'
26 changes: 11 additions & 15 deletions lib/uo_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ module CLI
# params\
# +scenario+:: _string_ Path to csv file that defines the scenario\
# +feature_file_path+:: _string_ Path to Feature File used to describe set of features in the district
#
# FIXME: This only works when scenario_file and feature_file are in the project root directory
# This works when called with filename (from inside project directory) and with absolute filepaths
# Also, feels a little weird that now I'm only using instance variables and not passing anything to this function. I guess it's ok?
def self.run_func
name = File.basename(@scenario_file_name, File.extname(@scenario_file_name))
run_dir = File.join(@root_dir, 'run', name.downcase)
Expand All @@ -147,8 +143,9 @@ def self.run_func
reopt_files_dir = File.join(@root_dir, 'reopt/')
num_header_rows = 1
# FIXME: This can be cleaned up in Ruby 2.5 with Dir.children(<"foldername">)
# TODO: Better way of grabbing assumptions file than the first file in the folder
reopt_files_dir_contents_list = Dir["#{reopt_files_dir}/*"]
reopt_folder_path, reopt_assumptions_filename = File.split(reopt_files_dir_contents_list[0])
reopt_assumptions_filename = File.basename(reopt_files_dir_contents_list[0])

if @feature_id
feature_run_dir = File.join(run_dir, @feature_id)
Expand All @@ -167,8 +164,7 @@ def self.run_func
def self.create_scenario_csv_file(feature_id)
feature_file_json = JSON.parse(File.read(File.absolute_path(@user_input[:feature])), symbolize_names: true)
Dir["#{@feature_path}/mappers/*.rb"].each do |mapper_file|
mapper_path, mapper_name = File.split(mapper_file)
mapper_name = mapper_name.split('.')[0]
mapper_name = File.basename(mapper_file, File.extname(mapper_file))
scenario_file_name = if feature_id == 'SKIP'
"#{mapper_name.downcase}_scenario.csv"
else
Expand Down Expand Up @@ -253,13 +249,13 @@ def self.create_project_folder(dir_name, empty_folder = false, overwrite_project

# Download mapper files to user's local machine
remote_mapper_files.each do |mapper_file|
mapper_path, mapper_name = File.split(mapper_file)
mapper_name = File.basename(mapper_file)
mapper_download = open(mapper_file, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
IO.copy_stream(mapper_download, File.join(mappers_dir_abs_path, mapper_name))
end

# Download gemfile to user's local machine
gem_path, gem_name = File.split(example_gem_file)
gem_name = File.basename(example_gem_file)
example_gem_download = open(example_gem_file, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
IO.copy_stream(example_gem_download, File.join(dir_name, gem_name))

Expand All @@ -274,26 +270,26 @@ def self.create_project_folder(dir_name, empty_folder = false, overwrite_project
end

# Download config file to user's local machine
config_path, config_name = File.split(config_file)
config_name = File.basename(config_file)
config_download = open(config_file, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
IO.copy_stream(config_download, File.join(dir_name, config_name))

# Download weather file to user's local machine
remote_weather_files.each do |weather_file|
weather_path, weather_name = File.split(weather_file)
weather_name = File.basename(weather_file)
weather_download = open(weather_file, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
IO.copy_stream(weather_download, File.join(weather_dir_abs_path, weather_name))
end

# Download osm files to user's local machine
osm_files.each do |osm_file|
osm_path, osm_name = File.split(osm_file)
osm_name = File.basename(osm_file)
osm_download = open(osm_file, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
IO.copy_stream(osm_download, File.join(osm_dir_abs_path, osm_name))
end

# Download feature file to user's local machine
feature_path, feature_name = File.split(example_feature_file)
feature_name = File.basename(example_feature_file)
example_feature_download = open(example_feature_file, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
IO.copy_stream(example_feature_download, File.join(dir_name, feature_name))
end
Expand Down Expand Up @@ -351,7 +347,7 @@ def self.create_project_folder(dir_name, empty_folder = false, overwrite_project
abort("\nYou must provide '-f' flag and a valid path to a FeatureFile!\n---\n\n")
end
if @user_input[:scenario].to_s.include? '-'
@scenario_folder = scenario_file_name.split(/\W+/)[0].capitalize.to_s
@scenario_folder = @scenario_file_name.split(/\W+/)[0].capitalize.to_s
@feature_id = (@feature_name.split(/\W+/)[1]).to_s
else
@scenario_folder = @scenario_file_name.split('.')[0].capitalize.to_s
Expand Down Expand Up @@ -388,7 +384,7 @@ def self.create_project_folder(dir_name, empty_folder = false, overwrite_project
puts "\nPost-processing OpenDSS results\n"
opendss_folder = File.join(@root_dir, 'run', @scenario_name.split('.')[0], 'opendss')
if File.directory?(opendss_folder)
opendss_folder_path, opendss_folder_name = File.split(opendss_folder)
opendss_folder_name = File.basename(opendss_folder)
opendss_post_processor = URBANopt::Scenario::OpenDSSPostProcessor.new(scenario_report, opendss_results_dir_name = opendss_folder_name)
opendss_post_processor.run
puts "\nDone\n"
Expand Down
2 changes: 1 addition & 1 deletion lib/uo_cli/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module URBANopt
module CLI
VERSION = '0.2.0'.freeze
VERSION = '0.2.1'.freeze
end
end
2 changes: 1 addition & 1 deletion uo_cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'bundler', '~> 1.17'
spec.add_development_dependency 'github_api', '~> 0.18'
spec.add_development_dependency 'rake', '~> 12.3'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rspec', '~> 3.7'
spec.add_development_dependency 'rubocop', '~> 0.54.0'
end

0 comments on commit ed9da15

Please sign in to comment.