Skip to content

Commit 5aed387

Browse files
committed
Simplify release process and only create 1 release zip. Link to all EPWs will be in the release notes.
1 parent 85d5ba7 commit 5aed387

2 files changed

Lines changed: 15 additions & 70 deletions

File tree

tasks.rb

Lines changed: 14 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4785,28 +4785,6 @@ def renumber_hpxml_ids(hpxml)
47854785
end
47864786
end
47874787

4788-
def download_epws
4789-
require 'tempfile'
4790-
tmpfile = Tempfile.new('epw')
4791-
4792-
UrlResolver.fetch('https://data.nrel.gov/system/files/128/tmy3s-cache-csv.zip', tmpfile)
4793-
4794-
puts 'Extracting weather files...'
4795-
require 'zip'
4796-
weather_dir = File.join(File.dirname(__FILE__), 'weather')
4797-
Zip.on_exists_proc = true
4798-
Zip::File.open(tmpfile.path.to_s) do |zip_file|
4799-
zip_file.each do |f|
4800-
zip_file.extract(f, File.join(weather_dir, f.name))
4801-
end
4802-
end
4803-
4804-
num_epws_actual = Dir[File.join(weather_dir, '*.epw')].count
4805-
puts "#{num_epws_actual} weather files are available in the weather directory."
4806-
puts 'Completed.'
4807-
exit!
4808-
end
4809-
48104788
def download_utility_rates
48114789
require_relative 'HPXMLtoOpenStudio/resources/util'
48124790
require_relative 'ReportUtilityBills/resources/util'
@@ -4837,7 +4815,7 @@ def download_utility_rates
48374815
exit!
48384816
end
48394817

4840-
command_list = [:update_measures, :update_hpxmls, :cache_weather, :create_release_zips, :download_weather, :download_utility_rates]
4818+
command_list = [:update_measures, :update_hpxmls, :cache_weather, :create_release_zips, :download_utility_rates]
48414819

48424820
def display_usage(command_list)
48434821
puts "Usage: openstudio #{File.basename(__FILE__)} [COMMAND]\nCommands:\n " + command_list.join("\n ")
@@ -4970,22 +4948,11 @@ def display_usage(command_list)
49704948
end
49714949
end
49724950

4973-
if ARGV[0].to_sym == :download_weather
4974-
download_epws
4975-
end
4976-
49774951
if ARGV[0].to_sym == :download_utility_rates
49784952
download_utility_rates
49794953
end
49804954

49814955
if ARGV[0].to_sym == :create_release_zips
4982-
release_map = { File.join(File.dirname(__FILE__), "OpenStudio-HPXML-v#{Version::OS_HPXML_Version}-minimal.zip") => false,
4983-
File.join(File.dirname(__FILE__), "OpenStudio-HPXML-v#{Version::OS_HPXML_Version}-full.zip") => true }
4984-
4985-
release_map.keys.each do |zip_path|
4986-
File.delete(zip_path) if File.exist? zip_path
4987-
end
4988-
49894956
if ENV['CI']
49904957
# CI doesn't have git, so default to everything
49914958
git_files = Dir['**/*.*']
@@ -5041,50 +5008,28 @@ def display_usage(command_list)
50415008
if Dir.exist? fonts_dir
50425009
FileUtils.rm_r(fonts_dir)
50435010
end
5044-
5045-
# Check if we need to download weather files for the full release zip
5046-
num_epws_expected = 1011
5047-
num_epws_local = 0
5048-
files.each do |f|
5049-
Dir[f].each do |file|
5050-
next unless file.end_with? '.epw'
5051-
5052-
num_epws_local += 1
5053-
end
5054-
end
5055-
5056-
# Make sure we have the full set of weather files
5057-
if num_epws_local < num_epws_expected
5058-
puts 'Fetching all weather files...'
5059-
command = "#{OpenStudio.getOpenStudioCLI} #{__FILE__} download_weather"
5060-
`#{command}`
5061-
end
50625011
end
50635012

50645013
# Create zip files
50655014
require 'zip'
5066-
release_map.each do |zip_path, include_all_epws|
5067-
puts "Creating #{zip_path}..."
5068-
Zip::File.open(zip_path, create: true) do |zipfile|
5069-
files.each do |f|
5070-
Dir[f].each do |file|
5071-
if file.start_with? 'documentation'
5072-
# always include
5073-
elsif include_all_epws
5074-
if (not git_files.include? file) && (not file.start_with? 'weather')
5075-
next
5076-
end
5077-
else
5078-
if not git_files.include? file
5079-
next
5080-
end
5015+
zip_path = File.join(File.dirname(__FILE__), "OpenStudio-HPXML-v#{Version::OS_HPXML_Version}.zip")
5016+
File.delete(zip_path) if File.exist? zip_path
5017+
puts "Creating #{zip_path}..."
5018+
Zip::File.open(zip_path, create: true) do |zipfile|
5019+
files.each do |f|
5020+
Dir[f].each do |file|
5021+
if file.start_with? 'documentation'
5022+
# always include
5023+
else
5024+
if not git_files.include? file
5025+
next
50815026
end
5082-
zipfile.add(File.join('OpenStudio-HPXML', file), file)
50835027
end
5028+
zipfile.add(File.join('OpenStudio-HPXML', file), file)
50845029
end
50855030
end
5086-
puts "Wrote file at #{zip_path}."
50875031
end
5032+
puts "Wrote file at #{zip_path}."
50885033

50895034
# Cleanup
50905035
if not ENV['CI']

workflow/tests/hpxml_translator_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def test_release_zips
362362
top_dir = File.join(@this_dir, '..', '..')
363363
command = "\"#{OpenStudio.getOpenStudioCLI}\" \"#{File.join(top_dir, 'tasks.rb')}\" create_release_zips"
364364
system(command)
365-
assert_equal(2, Dir["#{top_dir}/*.zip"].size)
365+
assert_equal(1, Dir["#{top_dir}/*.zip"].size)
366366

367367
# Check successful running of simulation from release zips
368368
require 'zip'

0 commit comments

Comments
 (0)