Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uo update #671

Merged
merged 6 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/openstudio-server-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:

jobs:
linux-test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2
Expand All @@ -36,6 +36,7 @@ jobs:
run: ./ci/github-actions/test.sh
env:
BUILD_TYPE: integration
SKIP_URBANOPT_ALGO: true # Set this when excluding urbanopt-cli gem from server.
- name: logs
if: ${{ failure() }}
shell: bash
Expand Down Expand Up @@ -68,7 +69,7 @@ jobs:
run: ./ci/github-actions/test.sh
env:
BUILD_TYPE: integration
SKIP_URBANOPT_ALGO: false # Set this when excluding urbanopt-cli gem from server.
SKIP_URBANOPT_ALGO: true # Set this when excluding urbanopt-cli gem from server.
- name: logs
if: ${{ failure() }}
shell: bash
Expand All @@ -84,7 +85,7 @@ jobs:
name: openstudio-server-gems-darwin
path: build/NREL/export/*.tar.gz
docker:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2
Expand All @@ -106,8 +107,7 @@ jobs:
docker-compose -f docker-compose.test.yml build --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_TAG
docker-compose -f docker-compose.test.yml up -d
# set SKIP_URBANOPT_ALGO=true to skip UrbanOpt algo tests
# set SKIP_URBANOPT_ALGO=true to skip UrbanOpt algo tests
docker-compose exec -e SKIP_URBANOPT_ALGO=true -T web /usr/local/bin/run-server-tests
docker-compose exec -e SKIP_URBANOPT_ALGO=false -T web /usr/local/bin/run-server-tests
docker-compose stop
git checkout -- .dockerignore && git checkout -- Dockerfile
env:
Expand Down
6 changes: 3 additions & 3 deletions ci/github-actions/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

echo "The build architecture is ${ImageOS}"

if [ "${ImageOS}" == "ubuntu18" ] && [ "${BUILD_TYPE}" == "docker" ]; then
if [ "${ImageOS}" == "ubuntu20" ] && [ "${BUILD_TYPE}" == "docker" ]; then
echo "Installing docker compose"
sudo rm /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
Expand Down Expand Up @@ -59,12 +59,12 @@ else
ulimit -n 4096
ulimit -a

elif [ "${ImageOS}" == "ubuntu18" ]; then
elif [ "${ImageOS}" == "ubuntu20" ]; then
echo "Setting up Ubuntu for unit tests and Rubocop"
# install pipe viewer to throttle printing logs to screen (not a big deal in linux, but it is in osx)
sudo apt-get update && sudo apt-get install -y wget gnupg software-properties-common build-essential
sudo wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.4 multiverse | tee /etc/apt/sources.list.d/mongodb-org-4.4.list"
echo "deb http://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse | tee /etc/apt/sources.list.d/mongodb-org-4.4.list"
sudo apt-get update
sudo apt-get install -y pv tree mongodb libqdbm14 libxml2-dev
# explicitly install. the latest version of redis-server
Expand Down
2 changes: 1 addition & 1 deletion ci/github-actions/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [ "${ImageOS}" == "macos1015" ]; then
export GEM_HOME="$GITHUB_WORKSPACE/gems"
export GEM_PATH="$GITHUB_WORKSPACE/gems:$GITHUB_WORKSPACE/gems/bundler/gems"
mongo_dir="/usr/local/bin"
elif [ "${ImageOS}" == "ubuntu18" ]; then
elif [ "${ImageOS}" == "ubuntu20" ]; then
# Dir containing openstudio
export ENERGYPLUS_EXE_PATH=/usr/local/openstudio-${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT}/EnergyPlus/energyplus
export PATH=/usr/local/ruby/bin:/usr/bin:/usr/local/openstudio-${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT}/bin:${PATH}
Expand Down
3 changes: 2 additions & 1 deletion docker/server/run-server-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ done
# can be removed.
cd /opt/openstudio/server && bundle exec rspec spec/features/docker_stack_test_apis_spec.rb; (( exit_status = exit_status || $? ))
cd /opt/openstudio/server && bundle exec rspec spec/features/docker_stack_algo_spec.rb; (( exit_status = exit_status || $? ))
if [ ! SKIP_URBANOPT_ALGO=true ]
echo "SKIP_URBANOPT_ALGO: $SKIP_URBANOPT_ALGO"
if ! $SKIP_URBANOPT_ALGO -eq true
then
cd /opt/openstudio/server && bundle exec rspec spec/features/docker_stack_urbanopt_algo_spec.rb; (( exit_status = exit_status || $? ))
fi
Expand Down
4 changes: 2 additions & 2 deletions server/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ gem 'openstudio-workflow', '= 2.3.1'
gem 'openstudio-analysis', '= 1.2.0'

# Remove urbanopt cli gems for minor for releases as they use different versions of ext gems
gem 'urbanopt-cli', '= 0.7.1'
gem 'urbanopt-reopt', '= 0.7.0'
gem 'urbanopt-cli', '= 0.8.0'
#gem 'urbanopt-reopt', '= 0.8.0'

## End commonly updated gems

Expand Down
86 changes: 42 additions & 44 deletions server/spec/features/docker_stack_urbanopt_algo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
# To Run this test manually:
#
# start a server stack with /spec added and ssh into the Web container
# >ruby /opt/openstudio/bin/openstudio_meta install_gems
# >cd /opt/openstudio/spec/
# >gem install rspec
# >cd /opt/openstudio/server/spec/
# >gem install rest-client rails_helper json rspec rspec-retry
# >rspec openstudio_algo_spec.rb
#
#################################################################################
Expand Down Expand Up @@ -85,27 +84,23 @@
# @api = OpenStudio::Analysis::ServerApi.new(options)
# You are still going to want the ServerApi to grab results. You can replace a bunch of the
# RestClient calls below.
APP_CONFIG['os_server_host_url'] = options[:hostname]
end

it 'run urbanopt_single_run analysis', :single_run, js: true do
# setup expected results
single_run = [
{ electricity_kwh: 19294572.2222,
natural_gas_kwh: 21731513.8888 }
]
single_run_round = [
{ electricity_kwh: 19000000,
natural_gas_kwh: 22000000 }
{ electricity_kwh: 20983305.555555556,
natural_gas_kwh: 24483569.444444444 }
]

# setup bad results
single_run_bad = [
{ electricity_kwh: 0,
natural_gas_kwh: 0}
]

# run an analysis
command = "#{@bundle_cmd} #{@meta_cli} run_analysis --debug --verbose '#{@project}/UrbanOpt_singlerun.json' 'http://#{@host}' -z 'UrbanOpt_NSGA' -a single_run"
command = "#{@bundle_cmd} #{@meta_cli} run_analysis --debug --verbose '#{@project}/URBANopt_071_sr.json' 'http://#{@host}' -z 'URBANopt_071' -a single_run"
puts "run command: #{command}"
run_analysis = system(command)
expect(run_analysis).to be true
Expand Down Expand Up @@ -232,43 +227,32 @@
sim = sim_result.slice(:electricity_kwh, :natural_gas_kwh)
expect(sim.size).to eq(2)
sim = sim.transform_values { |x| x.round(-6) }

compare = single_run_round.include?(sim)
puts "single_run sim: #{sim}"
tmp = []
single_run.each do |x|
tmp << x.transform_values { |y| y.round(-6) }
end
compare = tmp.include?(sim)
expect(compare).to be true
puts "data_point[:#{data_point[:_id]}] results compare is: #{compare}"

compare = single_run_bad.include?(sim)
expect(compare).to be false

objectives = [{
objective_function_1: 19287658.3333,
objective_function_target_1: 0,
objective_function_group_1: 1,
objective_function_2: 21750497.2222,
objective_function_target_2: 0,
objective_function_group_2: 2,
objective_function_3: 454019.4444,
objective_function_target_3: 0,
objective_function_group_3: 3,
objective_function_4: 609722.2222,
objective_function_target_4: 0,
objective_function_group_4: 4
}]

objectives_round = [{
objective_function_1: 19000000,
objective_function_target_1: 0,
objective_function_group_1: 1,
objective_function_2: 22000000,
objective_function_target_2: 0,
objective_function_group_2: 2,
objective_function_3: 500000,
objective_function_target_3: 0,
objective_function_group_3: 3,
objective_function_4: 600000,
objective_function_target_4: 0,
objective_function_group_4: 4
}]
objectives = {
objective_function_1: 20983305.555555556,
objective_function_target_1: 0,
objective_function_group_1: 1,
objective_function_2: 24483569.444444444,
objective_function_target_2: 0,
objective_function_group_2: 2,
objective_function_3: 1651205.5555555555,
objective_function_target_3: 0,
objective_function_group_3: 3,
objective_function_4: 1814133.3333333333,
objective_function_target_4: 0,
objective_function_group_4: 4
}

#test the objectives.json
objectives_json = RestClient.get "http://#{@host}/data_points/#{data_point_id}/download_result_file?filename=objectives.json"
Expand All @@ -288,8 +272,22 @@
end
end
end

compare = objectives_round.include?(obj_json)
#round test objectives {} for the comparison since repeatability is an issue
cmp = []
tmp = {}
objectives.each do |key, value|
if key.to_s.include?("target") || key.to_s.include?("group")
tmp[key] = value.to_i
else
if Math.log10(value) > 6
tmp[key] = value.round(-6)
else
tmp[key] = value.round(-5)
end
end
end
cmp << tmp
compare = cmp.include?(obj_json)
expect(compare).to be true
puts "data_point[:#{data_point[:_id]}] objective.json compare is: #{compare}"

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"analysis": {
"display_name": "URBANopt_singlerun",
"name": "URBANopt_singlerun",
"display_name": "URBANopt_071_sr",
"name": "URBANopt_071_sr",
"urbanopt": true,
"output_variables": [
{
Expand Down
Loading