Skip to content

Commit

Permalink
Simplify release process and only create 1 release zip. Link to all E…
Browse files Browse the repository at this point in the history
…PWs will be in the release notes.
  • Loading branch information
shorowit committed Nov 18, 2022
1 parent 82b08b2 commit 8e8601e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 75 deletions.
1 change: 0 additions & 1 deletion docs/source/usage_instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ To get started:

#. Either download `OpenStudio 3.5.0 <https://github.com/NREL/OpenStudio/releases/tag/v3.5.0>`_ and install the Command Line Interface/EnergyPlus/C++ API components, or use the `nrel/openstudio docker image <https://hub.docker.com/r/nrel/openstudio>`_.
#. Download the `latest release <https://github.com/NREL/OpenStudio-ERI/releases>`_ release.
#. To obtain all available weather files, run: ``openstudio workflow/energy_rating_index.rb --download-weather``

.. note::

Expand Down
53 changes: 12 additions & 41 deletions tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2940,13 +2940,6 @@ def display_usage(command_list)
if ARGV[0].to_sym == :create_release_zips
require_relative 'workflow/version'

release_map = { File.join(File.dirname(__FILE__), "OpenStudio-ERI-v#{Version::OS_ERI_Version}-minimal.zip") => false,
File.join(File.dirname(__FILE__), "OpenStudio-ERI-v#{Version::OS_ERI_Version}-full.zip") => true }

release_map.keys.each do |zip_path|
File.delete(zip_path) if File.exist? zip_path
end

if ENV['CI']
# CI doesn't have git, so default to everything
git_files = Dir['**/*.*']
Expand Down Expand Up @@ -2996,46 +2989,24 @@ def display_usage(command_list)
if Dir.exist? fonts_dir
FileUtils.rm_r(fonts_dir)
end

# Check if we need to download weather files for the full release zip
num_epws_expected = 1011
num_epws_local = 0
files.each do |f|
Dir[f].each do |file|
next unless file.end_with? '.epw'

num_epws_local += 1
end
end

# Make sure we have the full set of weather files
if num_epws_local < num_epws_expected
puts 'Fetching all weather files...'
command = "#{OpenStudio.getOpenStudioCLI} workflow/energy_rating_index.rb --download-weather"
`#{command}`
end
end

# Create zip files
require 'zip'
release_map.each do |zip_path, include_all_epws|
puts "Creating #{zip_path}..."
Zip::File.open(zip_path, create: true) do |zipfile|
files.each do |f|
Dir[f].each do |file|
if file.start_with? 'documentation'
# always include
elsif include_all_epws
if (not git_files.include? file) && (not file.start_with? 'weather')
next
end
else
if not git_files.include? file
next
end
zip_path = File.join(File.dirname(__FILE__), "OpenStudio-ERI-v#{Version::OS_ERI_Version}.zip")
File.delete(zip_path) if File.exist? zip_path
puts "Creating #{zip_path}..."
Zip::File.open(zip_path, create: true) do |zipfile|
files.each do |f|
Dir[f].each do |file|
if file.start_with? 'documentation'
# always include
else
if not git_files.include? file
next
end
zipfile.add(File.join('OpenStudio-ERI', file), file)
end
zipfile.add(File.join('OpenStudio-ERI', file), file)
end
end
puts "Wrote file at #{zip_path}."
Expand Down
32 changes: 0 additions & 32 deletions workflow/energy_rating_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -758,30 +758,6 @@ def write_es_zerh_results(ruleset, resultsdir, rd_eri_results, rated_eri_results
CSV.open(results_csv, 'wb') { |csv| results_out.to_a.each { |elem| csv << elem } }
end

def download_epws
require_relative '../hpxml-measures/HPXMLtoOpenStudio/resources/util'

require 'tempfile'
tmpfile = Tempfile.new('epw')

UrlResolver.fetch('https://data.nrel.gov/system/files/128/tmy3s-cache-csv.zip', tmpfile)

puts 'Extracting weather files...'
weather_dir = File.join(File.dirname(__FILE__), '..', 'weather')
require 'zip'
Zip.on_exists_proc = true
Zip::File.open(tmpfile.path.to_s) do |zip_file|
zip_file.each do |f|
zip_file.extract(f, File.join(weather_dir, f.name))
end
end

num_epws_actual = Dir[File.join(weather_dir, '*.epw')].count
puts "#{num_epws_actual} weather files are available in the weather directory."
puts 'Completed.'
exit!
end

def cache_weather
# Process all epw files through weather.rb and serialize objects
require_relative '../hpxml-measures/HPXMLtoOpenStudio/resources/materials'
Expand Down Expand Up @@ -1028,10 +1004,6 @@ def main(options)
options[:monthly_outputs] << t
end

opts.on('-w', '--download-weather', 'Downloads all US TMY3 weather files') do |t|
options[:epws] = t
end

opts.on('-c', '--cache-weather', 'Caches all weather files') do |t|
options[:cache] = t
end
Expand Down Expand Up @@ -1102,10 +1074,6 @@ def main(options)
exit!
end

if options[:epws]
download_epws
end

if options[:cache]
cache_weather
end
Expand Down
2 changes: 1 addition & 1 deletion workflow/tests/energy_rating_index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_release_zips
top_dir = File.join(File.dirname(__FILE__), '..', '..')
command = "\"#{OpenStudio.getOpenStudioCLI}\" #{File.join(top_dir, 'tasks.rb')} create_release_zips"
system(command)
assert_equal(2, Dir["#{top_dir}/*.zip"].size)
assert_equal(1, Dir["#{top_dir}/*.zip"].size)

# Check successful running of ERI calculation from release zips
require 'zip'
Expand Down

0 comments on commit 8e8601e

Please sign in to comment.