openstudio-analysis 1.0.4 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/openstudio-analysis.yml +40 -0
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +23 -1
- data/LICENSE.md +1 -1
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/openstudio-analysis.rb +2 -1
- data/lib/openstudio/analysis.rb +1 -1
- data/lib/openstudio/analysis/algorithm_attributes.rb +1 -1
- data/lib/openstudio/analysis/formulation.rb +1 -1
- data/lib/openstudio/analysis/server_api.rb +1 -1
- data/lib/openstudio/analysis/support_files.rb +1 -1
- data/lib/openstudio/analysis/translator/datapoints.rb +24 -38
- data/lib/openstudio/analysis/translator/excel.rb +1 -1
- data/lib/openstudio/analysis/translator/workflow.rb +5 -4
- data/lib/openstudio/analysis/version.rb +4 -2
- data/lib/openstudio/analysis/workflow.rb +28 -36
- data/lib/openstudio/analysis/workflow_step.rb +5 -8
- data/lib/openstudio/helpers/hash.rb +1 -1
- data/lib/openstudio/helpers/string.rb +1 -1
- data/lib/openstudio/helpers/utils.rb +66 -0
- data/lib/openstudio/weather/epw.rb +1 -1
- data/openstudio-analysis.gemspec +3 -4
- data/update_license.rb +3 -3
- metadata +12 -27
- data/.gitlab-ci.yml +0 -20
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c57c83c75eb61c8b4253907c07d2f4cc1eaa6939aa27c30dc5fdae7bc0bd551f
|
4
|
+
data.tar.gz: c2299fdd5b78dfc58792c4bf35aa621f2a4e1db862e2e5b3fcd93107ee7f82ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eac9ee6feee2103b9fe6b9529116f5939145198b8dee8ea9c7094ea5fe0d61e47fb009882c73b0770c152c997f319c5202c56266c6bbd84ca3775a2a98b1074c
|
7
|
+
data.tar.gz: ac4167112ffa932916d99c765d1486e184ad154f65e49b70b56d99b458bb3a3458371687450e031cc6d0afa92318e647c4756625dd5ef1f097937a50c0d43e88
|
@@ -0,0 +1,40 @@
|
|
1
|
+
name: openstudio-analysis-gem
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
ubuntu-1804: # ruby 2.5 workflow
|
7
|
+
if: github.event.pull_request.base.ref == '1.1.X-LTS' # check target branch of pr
|
8
|
+
runs-on: ubuntu-18.04
|
9
|
+
steps:
|
10
|
+
- name: Check out repository
|
11
|
+
uses: actions/checkout@v2
|
12
|
+
- name: ruby-install
|
13
|
+
shell: bash
|
14
|
+
run: "sudo apt install -y ruby && ruby -v" # ruby anye tests here when ready
|
15
|
+
ubuntu-2004: # ruby 2.7 workflow
|
16
|
+
if: github.event.pull_request.base.ref != '1.1.X-LTS' # check target branch of pr
|
17
|
+
runs-on: ubuntu-20.04
|
18
|
+
steps:
|
19
|
+
-
|
20
|
+
name: Check out repository
|
21
|
+
uses: actions/checkout@v2
|
22
|
+
-
|
23
|
+
name: Display system info
|
24
|
+
run: |
|
25
|
+
ruby --version
|
26
|
+
docker --version
|
27
|
+
docker-compose --version
|
28
|
+
-
|
29
|
+
name: Start OpenStudio for testing Server API
|
30
|
+
run: |
|
31
|
+
echo "Not yet implemented"
|
32
|
+
-
|
33
|
+
name: Run tests in Docker
|
34
|
+
env:
|
35
|
+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
36
|
+
run: |
|
37
|
+
docker run -e COVERALLS_REPO_TOKEN=${COVERALLS_REPO_TOKEN} \
|
38
|
+
-v $(pwd):/var/simdata/openstudio \
|
39
|
+
nrel/openstudio:develop \
|
40
|
+
/bin/bash -c "bundle install && bundle exec rake"
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,31 @@
|
|
1
1
|
OpenStudio Analysis Gem Change Log
|
2
2
|
==================================
|
3
3
|
|
4
|
+
Version 1.2.0
|
5
|
+
-------------
|
6
|
+
* master -> main
|
7
|
+
* Remove support for Ruby 2.5. Only support Ruby ~> 2.7.0
|
8
|
+
* BCL ~> 0.7.0
|
9
|
+
* Use GitHub actions for CI
|
10
|
+
|
11
|
+
Version 1.1.0
|
12
|
+
-------------
|
13
|
+
* Allow for blank :seed, :weather_file and :workflow sections of OSA
|
14
|
+
|
15
|
+
Version 1.0.6
|
16
|
+
-------------
|
17
|
+
* Always include ../lib to the file paths to search
|
18
|
+
|
19
|
+
Version 1.0.5
|
20
|
+
-------------
|
21
|
+
* Upgrade to latest BCL (0.6.1)
|
22
|
+
* Remove the need for the measure.json (which has been deprecated in BCL gem). Now parses the measure.xml.
|
23
|
+
* Upgrade Faraday (1.0.1)
|
24
|
+
* Remove dependency on Nokogiri.
|
25
|
+
|
4
26
|
Version 1.0.4
|
5
27
|
-------------
|
6
|
-
* Update dependency
|
28
|
+
* Update dependency Nokogiri
|
7
29
|
|
8
30
|
Version 1.0.3
|
9
31
|
-------------
|
data/LICENSE.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
OpenStudio(R), Copyright (c) 2008-
|
1
|
+
OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
|
2
2
|
|
3
3
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
4
4
|
that the following conditions are met:
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# OpenStudio Analysis Gem
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/NREL/OpenStudio-analysis-gem/actions/workflows/openstudio-analysis.yml/badge.svg?branch=develop)](https://github.com/NREL/OpenStudio-analysis-gem/actions/workflows/openstudio-analysis.yml)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/NREL/OpenStudio-analysis-gem/badge.svg?branch=develop)](https://coveralls.io/r/NREL/OpenStudio-analysis-gem?branch=develop)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/openstudio-analysis.svg)](https://badge.fury.io/rb/openstudio-analysis)
|
6
6
|
|
@@ -81,8 +81,8 @@ Follow the steps below when releasing a new version:
|
|
81
81
|
3. Run rubocop and make sure code meets coding standards.
|
82
82
|
4. Push release candidate on a branch.
|
83
83
|
5. Create a pull request to develop. Once the tests pass, merge into develop.
|
84
|
-
6. Create a pull request to
|
85
|
-
7. Checkout
|
84
|
+
6. Create a pull request to main. Once tests pass, then merge into main.
|
85
|
+
7. Checkout main and run `rake release`
|
86
86
|
|
87
87
|
# Todos
|
88
88
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
data/lib/openstudio-analysis.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -70,6 +70,7 @@ require 'openstudio/analysis/translator/workflow'
|
|
70
70
|
# helpers / core_ext
|
71
71
|
require 'openstudio/helpers/string'
|
72
72
|
require 'openstudio/helpers/hash'
|
73
|
+
require 'openstudio/helpers/utils'
|
73
74
|
|
74
75
|
# weather file parsing
|
75
76
|
require 'openstudio/weather/epw'
|
data/lib/openstudio/analysis.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -58,7 +58,7 @@ module OpenStudio
|
|
58
58
|
attr_accessor :name
|
59
59
|
attr_reader :analysis_name
|
60
60
|
|
61
|
-
require '
|
61
|
+
require 'rexml/document'
|
62
62
|
|
63
63
|
# Pass in the filename to read
|
64
64
|
def initialize(csv_filename)
|
@@ -368,16 +368,16 @@ module OpenStudio
|
|
368
368
|
data = []
|
369
369
|
measures.each_with_index do |measure, measure_index|
|
370
370
|
data[measure_index] = {}
|
371
|
-
|
371
|
+
measure_parsed = find_measure(measure.to_s)
|
372
372
|
|
373
|
-
raise "Could not find measure #{measure} xml in measure_paths: '#{@measure_paths.join("\n")}'" unless
|
373
|
+
raise "Could not find measure #{measure} xml in measure_paths: '#{@measure_paths.join("\n")}'" unless measure_parsed
|
374
374
|
measure_data = {}
|
375
|
-
measure_data[:classname] =
|
376
|
-
measure_data[:name] =
|
377
|
-
measure_data[:display_name] =
|
378
|
-
measure_data[:measure_type] = measure_type
|
379
|
-
measure_data[:uid] =
|
380
|
-
measure_data[:version_id] =
|
375
|
+
measure_data[:classname] = measure_parsed[:classname]
|
376
|
+
measure_data[:name] = measure_parsed[:name]
|
377
|
+
measure_data[:display_name] = measure_parsed[:display_name]
|
378
|
+
measure_data[:measure_type] = measure_parsed[:measure_type]
|
379
|
+
measure_data[:uid] = measure_parsed[:uid]
|
380
|
+
measure_data[:version_id] = measure_parsed[:version_id]
|
381
381
|
data[measure_index][:measure_data] = measure_data
|
382
382
|
data[measure_index][:vars] = []
|
383
383
|
vars = measure_map[measure]
|
@@ -389,8 +389,8 @@ module OpenStudio
|
|
389
389
|
next if var.to_s == 'None'
|
390
390
|
var_hash = {}
|
391
391
|
found_arg = nil
|
392
|
-
|
393
|
-
if var.to_s == '__SKIP__' || arg
|
392
|
+
measure_parsed[:arguments].each do |arg|
|
393
|
+
if var.to_s == '__SKIP__' || arg[:name] == var.to_s
|
394
394
|
found_arg = arg
|
395
395
|
break
|
396
396
|
end
|
@@ -404,8 +404,8 @@ module OpenStudio
|
|
404
404
|
var_type = 'boolean'
|
405
405
|
var_units = ''
|
406
406
|
else
|
407
|
-
var_type = found_arg.
|
408
|
-
var_units = found_arg
|
407
|
+
var_type = found_arg[:variable_type].downcase
|
408
|
+
var_units = found_arg[:units]
|
409
409
|
end
|
410
410
|
|
411
411
|
var_hash[:name] = var.to_s
|
@@ -437,7 +437,8 @@ module OpenStudio
|
|
437
437
|
var_hash[:distribution][:type] = 'discrete'
|
438
438
|
var_hash[:distribution][:units] = var_hash[:units]
|
439
439
|
if var_hash[:type] == 'choice'
|
440
|
-
var_hash[:distribution][:enumerations] = found_arg.xpath('choices/choice').map { |s| s.xpath('value').text }
|
440
|
+
# var_hash[:distribution][:enumerations] = found_arg.xpath('choices/choice').map { |s| s.xpath('value').text }
|
441
|
+
# This would need to be updated if we want to do this again... sorry.
|
441
442
|
elsif var_hash[:type] == 'bool'
|
442
443
|
var_hash[:distribution][:enumerations] = []
|
443
444
|
var_hash[:distribution][:enumerations] << true
|
@@ -447,13 +448,13 @@ module OpenStudio
|
|
447
448
|
end
|
448
449
|
data[measure_index][:args] = []
|
449
450
|
|
450
|
-
|
451
|
+
measure_parsed[:arguments].each do |arg_xml|
|
451
452
|
arg = {}
|
452
|
-
arg[:value_type] = arg_xml
|
453
|
-
arg[:name] = arg_xml
|
454
|
-
arg[:display_name] = arg_xml
|
453
|
+
arg[:value_type] = arg_xml[:variable_type]
|
454
|
+
arg[:name] = arg_xml[:name]
|
455
|
+
arg[:display_name] = arg_xml[:display_name].downcase
|
455
456
|
arg[:display_name_short] = arg[:display_name]
|
456
|
-
arg[:default_value] = arg_xml
|
457
|
+
arg[:default_value] = arg_xml[:default_value].downcase
|
457
458
|
arg[:value] = arg[:default_value]
|
458
459
|
data[measure_index][:args] << arg
|
459
460
|
end
|
@@ -470,27 +471,12 @@ module OpenStudio
|
|
470
471
|
measure_xml = File.join(mp, measure_name, 'measure.xml')
|
471
472
|
measure_rb = File.join(mp, measure_name, 'measure.rb')
|
472
473
|
if File.exist?(measure_xml) && File.exist?(measure_rb)
|
473
|
-
|
474
|
+
measure_parsed = parse_measure_xml(measure_xml)
|
475
|
+
return measure_parsed
|
474
476
|
end
|
475
477
|
end
|
476
478
|
|
477
|
-
return nil
|
478
|
-
end
|
479
|
-
|
480
|
-
def parse_measure_type(measure_filename)
|
481
|
-
measure_string = File.read(measure_filename)
|
482
|
-
|
483
|
-
if measure_string =~ /OpenStudio::Ruleset::WorkspaceUserScript/
|
484
|
-
return 'EnergyPlusMeasure'
|
485
|
-
elsif measure_string =~ /OpenStudio::Ruleset::ModelUserScript/
|
486
|
-
return 'RubyMeasure'
|
487
|
-
elsif measure_string =~ /OpenStudio::Ruleset::ReportingUserScript/
|
488
|
-
return 'ReportingMeasure'
|
489
|
-
elsif measure_string =~ /OpenStudio::Ruleset::UtilityUserScript/
|
490
|
-
return 'UtilityUserScript'
|
491
|
-
else
|
492
|
-
raise "measure type is unknown with an inherited class in #{measure_filename}"
|
493
|
-
end
|
479
|
+
return nil
|
494
480
|
end
|
495
481
|
end
|
496
482
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -65,14 +65,15 @@ module OpenStudio
|
|
65
65
|
@osw_version = '0.0.1'
|
66
66
|
@options = options
|
67
67
|
@file_paths = options[:file_paths] ? options[:file_paths] : []
|
68
|
+
@file_paths << '../lib'
|
68
69
|
@measure_paths = options[:measure_paths] ? options[:measure_paths] : []
|
69
70
|
|
70
71
|
# Initialize static inputs from the OSA
|
71
|
-
@seed_file = File.basename(@osa[:seed][:path])
|
72
|
+
!@osa[:seed].nil? ? @seed_file = File.basename(@osa[:seed][:path]) : @seed_file = ''
|
72
73
|
if @options[:seed]
|
73
74
|
@seed_file = @options[:seed]
|
74
75
|
end
|
75
|
-
@weather_file = File.basename(@osa[:weather_file][:path])
|
76
|
+
!@osa[:weather_file].nil? ? @weather_file = File.basename(@osa[:weather_file][:path]) : @weather_file = ''
|
76
77
|
@osa_id = @osa[:_id]
|
77
78
|
@steps = []
|
78
79
|
@osa[:problem][:workflow].each_with_index do |step, i|
|
@@ -96,7 +97,7 @@ module OpenStudio
|
|
96
97
|
step_hash[:modeler_description] = step[:modeler_description] if step[:modeler_description]
|
97
98
|
step_hash[:taxonomy] = step[:taxonomy] if step[:taxonomy]
|
98
99
|
step_hash[:measure_type] = step[:measure_type]
|
99
|
-
step_hash[:measure_type] = 'ModelMeasure'
|
100
|
+
step_hash[:measure_type] = 'ModelMeasure'
|
100
101
|
@steps << step_hash
|
101
102
|
end
|
102
103
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -35,6 +35,8 @@
|
|
35
35
|
|
36
36
|
module OpenStudio
|
37
37
|
module Analysis
|
38
|
-
|
38
|
+
# format should be ^.*\-{1}[a-z]+[0-9]+
|
39
|
+
# for example: -rc1, -beta6, -customusecase0
|
40
|
+
VERSION = '1.2.0'.freeze
|
39
41
|
end
|
40
42
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -53,8 +53,7 @@ module OpenStudio
|
|
53
53
|
@items.clear
|
54
54
|
end
|
55
55
|
|
56
|
-
# Add a measure to the workflow from a path.
|
57
|
-
# if not, the BCL gem is used to create the measure.json file.
|
56
|
+
# Add a measure to the workflow from a path. This will parse the measure.xml which must exist.
|
58
57
|
#
|
59
58
|
# @params instance_name [String] The name of the instance. This allows for multiple measures to be added to the workflow with uni que names
|
60
59
|
# @params instance_display_name [String] The display name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
@@ -69,19 +68,11 @@ module OpenStudio
|
|
69
68
|
end
|
70
69
|
|
71
70
|
if Dir.exist?(local_path_to_measure) && File.directory?(local_path_to_measure)
|
72
|
-
# Watch out for namespace conflicts (use ::BCL)
|
73
|
-
b = ::BCL::ComponentMethods.new
|
74
71
|
measure_hash = nil
|
75
|
-
|
76
|
-
measure_hash =
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
if measure_hash.nil? && File.exist?(File.join(local_path_to_measure, 'measure.json'))
|
82
|
-
measure_hash = JSON.parse(File.read(File.join(local_path_to_measure, 'measure.json')), symbolize_names: true)
|
83
|
-
elsif measure_hash.nil?
|
84
|
-
raise 'measure.json was not found and was not automatically created'
|
72
|
+
if File.exist?(File.join(local_path_to_measure, 'measure.xml'))
|
73
|
+
measure_hash = parse_measure_xml(File.join(local_path_to_measure, 'measure.xml'))
|
74
|
+
else
|
75
|
+
raise 'Could not find measure.xml'
|
85
76
|
end
|
86
77
|
|
87
78
|
add_measure(instance_name, instance_display_name, local_path_to_measure, measure_hash)
|
@@ -92,12 +83,12 @@ module OpenStudio
|
|
92
83
|
@items.last
|
93
84
|
end
|
94
85
|
|
95
|
-
# Add a measure from the custom hash format without reading the measure.rb or measure.
|
86
|
+
# Add a measure from the custom hash format without reading the measure.rb or measure.xml file
|
96
87
|
#
|
97
88
|
# @params instance_name [String] The name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
98
89
|
# @params instance_display_name [String] The display name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
99
90
|
# @param local_path_to_measure [String] This is the local path to the measure directory, relative or absolute. It is used when zipping up all the measures.
|
100
|
-
# @param measure_metadata [Hash] Format of the measure.
|
91
|
+
# @param measure_metadata [Hash] Format of the measure.xml in JSON format
|
101
92
|
# @return [Object] Returns the measure that was added as an OpenStudio::AnalysisWorkflowStep object
|
102
93
|
def add_measure(instance_name, instance_display_name, local_path_to_measure, measure_metadata)
|
103
94
|
@items << OpenStudio::Analysis::WorkflowStep.from_measure_hash(instance_name, instance_display_name, local_path_to_measure, measure_metadata)
|
@@ -110,7 +101,7 @@ module OpenStudio
|
|
110
101
|
# @params instance_name [String] The name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
111
102
|
# @params instance_display_name [String] The display name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
112
103
|
# @param local_path_to_measure [String] This is the local path to the measure directory, relative or absolute. It is used when zipping up all the measures.
|
113
|
-
# @param measure_metadata [Hash] Format of the measure.
|
104
|
+
# @param measure_metadata [Hash] Format of the measure.xml in JSON format
|
114
105
|
# @return [Object] Returns the measure that was added as an OpenStudio::AnalysisWorkflowStep object
|
115
106
|
def add_measure_from_analysis_hash(instance_name, instance_display_name, local_path_to_measure, measure_metadata)
|
116
107
|
@items << OpenStudio::Analysis::WorkflowStep.from_analysis_hash(instance_name, instance_display_name, local_path_to_measure, measure_metadata)
|
@@ -271,29 +262,30 @@ module OpenStudio
|
|
271
262
|
|
272
263
|
o = OpenStudio::Analysis::Workflow.new
|
273
264
|
|
274
|
-
h[:workflow]
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
265
|
+
if h[:workflow]
|
266
|
+
h[:workflow].each do |wf|
|
267
|
+
puts "Adding measure #{wf[:name]}"
|
268
|
+
|
269
|
+
# Go though the defined measure paths and try and find the local measure
|
270
|
+
local_measure_dir = nil
|
271
|
+
if wf[:measure_definition_directory_local] && Dir.exist?(wf[:measure_definition_directory_local])
|
272
|
+
local_measure_dir = wf[:measure_definition_directory_local]
|
273
|
+
else
|
274
|
+
# search in the measure paths for the measure
|
275
|
+
OpenStudio::Analysis.measure_paths.each do |p|
|
276
|
+
test_dir = File.join(p, File.basename(wf[:measure_definition_directory]))
|
277
|
+
if Dir.exist?(test_dir)
|
278
|
+
local_measure_dir = test_dir
|
279
|
+
break
|
280
|
+
end
|
288
281
|
end
|
289
282
|
end
|
290
|
-
end
|
291
283
|
|
292
|
-
|
284
|
+
raise "Could not find local measure when loading workflow for #{wf[:measure_definition_class_name]} in #{File.basename(wf[:measure_definition_directory])}. You may have to add measure paths to OpenStudio::Analysis.measure_paths" unless local_measure_dir
|
293
285
|
|
294
|
-
|
286
|
+
o.add_measure_from_analysis_hash(wf[:name], wf[:display_name], local_measure_dir, wf)
|
287
|
+
end
|
295
288
|
end
|
296
|
-
|
297
289
|
o
|
298
290
|
end
|
299
291
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -60,7 +60,7 @@ module OpenStudio
|
|
60
60
|
@name = ''
|
61
61
|
@display_name = ''
|
62
62
|
|
63
|
-
# The type of item being added (
|
63
|
+
# The type of item being added (ModelMeasure, EnergyPlusMeasure, ...)
|
64
64
|
@type = nil
|
65
65
|
|
66
66
|
@measure_definition_class_name = nil
|
@@ -267,15 +267,12 @@ module OpenStudio
|
|
267
267
|
#
|
268
268
|
# @param instance_name [String] Machine name of the instance
|
269
269
|
# @param instance_display_name [String] Display name of the instance
|
270
|
-
# @param path_to_measure [String] This is the local path to the measure
|
271
|
-
# @param hash [Hash] Measure hash in the format of
|
270
|
+
# @param path_to_measure [String] This is the local path to the measure directory, relative or absolute. It is used when zipping up all the measures.
|
271
|
+
# @param hash [Hash] Measure hash in the format of a converted measure.xml hash (from the Analysis Spreadsheet project)
|
272
272
|
# @param options [Hash] Optional arguments
|
273
273
|
# @option options [Boolean] :ignore_not_found Do not raise an exception if the measure could not be found on the machine
|
274
274
|
# @return [Object] Returns the OpenStudio::Analysis::WorkflowStep
|
275
275
|
def self.from_measure_hash(instance_name, instance_display_name, path_to_measure, hash, options = {})
|
276
|
-
# TODO: Validate the hash
|
277
|
-
# TODO: validate that the measure exists?
|
278
|
-
|
279
276
|
if File.directory? path_to_measure
|
280
277
|
path_to_measure = File.join(path_to_measure, 'measure.rb')
|
281
278
|
end
|
@@ -352,7 +349,7 @@ module OpenStudio
|
|
352
349
|
# @param instance_name [String] Machine name of the instance
|
353
350
|
# @param instance_display_name [String] Display name of the instance
|
354
351
|
# @param path_to_measure [String] This is the local path to the measure directroy, relative or absolute. It is used when zipping up all the measures.
|
355
|
-
# @param hash [Hash] Measure hash in the format of the measure.
|
352
|
+
# @param hash [Hash] Measure hash in the format of the measure.xml converted to JSON (from the Analysis Spreadsheet project)
|
356
353
|
# @param options [Hash] Optional arguments
|
357
354
|
# @option options [Boolean] :ignore_not_found Do not raise an exception if the measure could not be found on the machine
|
358
355
|
# @return [Object] Returns the OpenStudio::Analysis::WorkflowStep
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
|
+
# All rights reserved.
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
#
|
10
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
#
|
14
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
+
# may be used to endorse or promote products derived from this software without
|
16
|
+
# specific prior written permission from the respective party.
|
17
|
+
#
|
18
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
+
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
# *******************************************************************************
|
35
|
+
|
36
|
+
require 'rexml/document'
|
37
|
+
|
38
|
+
def parse_measure_xml(measure_xml_filename)
|
39
|
+
measure_hash = {}
|
40
|
+
xml_to_parse = File.open(measure_xml_filename)
|
41
|
+
xml_root = REXML::Document.new(xml_to_parse).root
|
42
|
+
|
43
|
+
# pull out some information
|
44
|
+
measure_hash[:classname] = xml_root.elements['//measure/class_name'].text
|
45
|
+
measure_hash[:name] = xml_root.elements['//measure/name'].text
|
46
|
+
measure_hash[:display_name] = xml_root.elements['//measure/display_name'].text
|
47
|
+
measure_hash[:display_name_titleized] = measure_hash[:name].titleize
|
48
|
+
measure_hash[:measure_type] = xml_root.elements['//measure/attributes/attribute[name="Measure Type"]/value'].text
|
49
|
+
measure_hash[:description] = xml_root.elements['//measure/description'].text
|
50
|
+
measure_hash[:modeler_description] = xml_root.elements['//measure/modeler_description'].text
|
51
|
+
measure_hash[:uid] = xml_root.elements['//measure/uid'].text
|
52
|
+
measure_hash[:version_id] = xml_root.elements['//measure/version_id'].text
|
53
|
+
measure_hash[:arguments] = []
|
54
|
+
|
55
|
+
REXML::XPath.each(xml_root, '//measure/arguments/argument') do |arg|
|
56
|
+
measure_hash[:arguments] << {
|
57
|
+
name: arg.elements['name'].text,
|
58
|
+
display_name: arg.elements['display_name'].text,
|
59
|
+
variable_type: arg.elements['type'].text.downcase,
|
60
|
+
default_value: arg.elements['default_value'].text,
|
61
|
+
units: arg.elements['units'] ? arg.elements['units'].text : ''
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
measure_hash
|
66
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
data/openstudio-analysis.gemspec
CHANGED
@@ -21,12 +21,11 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
s.require_paths = ['lib']
|
23
23
|
|
24
|
-
s.required_ruby_version = '~> 2.
|
24
|
+
s.required_ruby_version = '~> 2.7.0'
|
25
25
|
|
26
|
-
s.add_dependency 'bcl', '
|
26
|
+
s.add_dependency 'bcl', '~> 0.7.0'
|
27
27
|
s.add_dependency 'dencity', '~> 0.1.0'
|
28
|
-
s.add_dependency 'faraday', '~> 0.
|
29
|
-
s.add_dependency 'nokogiri', '~> 1.10.8'
|
28
|
+
s.add_dependency 'faraday', '~> 1.0.1'
|
30
29
|
s.add_dependency 'roo', '~> 2.8.3'
|
31
30
|
s.add_dependency 'rubyzip', '~> 2.3.0'
|
32
31
|
s.add_dependency 'semantic', '~> 1.4'
|
data/update_license.rb
CHANGED
@@ -6,7 +6,7 @@ js_regex = /^\/\* @preserve.*Copyright.*license.{2}\*\//m
|
|
6
6
|
|
7
7
|
ruby_header_text = <<EOT
|
8
8
|
# *******************************************************************************
|
9
|
-
# OpenStudio(R), Copyright (c) 2008-
|
9
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
10
10
|
# All rights reserved.
|
11
11
|
# Redistribution and use in source and binary forms, with or without
|
12
12
|
# modification, are permitted provided that the following conditions are met:
|
@@ -45,7 +45,7 @@ ruby_header_text.strip!
|
|
45
45
|
erb_header_text = <<EOT
|
46
46
|
<%
|
47
47
|
# *******************************************************************************
|
48
|
-
# OpenStudio(R), Copyright (c) 2008-
|
48
|
+
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
|
49
49
|
# All rights reserved.
|
50
50
|
# Redistribution and use in source and binary forms, with or without
|
51
51
|
# modification, are permitted provided that the following conditions are met:
|
@@ -84,7 +84,7 @@ erb_header_text.strip!
|
|
84
84
|
|
85
85
|
js_header_text = <<EOT
|
86
86
|
/* @preserve
|
87
|
-
* OpenStudio(R), Copyright (c) 2008-
|
87
|
+
* OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
|
88
88
|
* Use of this source code is governed by a BSD-style license that can be found at openstudio.net/license.
|
89
89
|
*/
|
90
90
|
EOT
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstudio-analysis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Long
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcl
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.7.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dencity
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,28 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.14'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: nokogiri
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.10.8
|
47
|
+
version: 1.0.1
|
62
48
|
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
54
|
+
version: 1.0.1
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: roo
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,10 +157,9 @@ executables: []
|
|
171
157
|
extensions: []
|
172
158
|
extra_rdoc_files: []
|
173
159
|
files:
|
160
|
+
- ".github/workflows/openstudio-analysis.yml"
|
174
161
|
- ".gitignore"
|
175
|
-
- ".gitlab-ci.yml"
|
176
162
|
- ".rubocop.yml"
|
177
|
-
- ".travis.yml"
|
178
163
|
- CHANGELOG.md
|
179
164
|
- Gemfile
|
180
165
|
- LICENSE.md
|
@@ -194,6 +179,7 @@ files:
|
|
194
179
|
- lib/openstudio/analysis/workflow_step.rb
|
195
180
|
- lib/openstudio/helpers/hash.rb
|
196
181
|
- lib/openstudio/helpers/string.rb
|
182
|
+
- lib/openstudio/helpers/utils.rb
|
197
183
|
- lib/openstudio/weather/epw.rb
|
198
184
|
- openstudio-analysis.gemspec
|
199
185
|
- update_license.rb
|
@@ -209,15 +195,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
195
|
requirements:
|
210
196
|
- - "~>"
|
211
197
|
- !ruby/object:Gem::Version
|
212
|
-
version: 2.
|
198
|
+
version: 2.7.0
|
213
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
200
|
requirements:
|
215
201
|
- - ">="
|
216
202
|
- !ruby/object:Gem::Version
|
217
203
|
version: '0'
|
218
204
|
requirements: []
|
219
|
-
|
220
|
-
rubygems_version: 2.7.6.2
|
205
|
+
rubygems_version: 3.1.4
|
221
206
|
signing_key:
|
222
207
|
specification_version: 4
|
223
208
|
summary: Create JSON, ZIP to communicate with OpenStudio Distributed Analysis in the
|
data/.gitlab-ci.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
test:windows:
|
2
|
-
stage: test
|
3
|
-
tags:
|
4
|
-
- windows
|
5
|
-
script:
|
6
|
-
- bundle exec rake
|
7
|
-
|
8
|
-
test:mac:
|
9
|
-
stage: test
|
10
|
-
tags:
|
11
|
-
- mac
|
12
|
-
script:
|
13
|
-
- bundle exec rake
|
14
|
-
|
15
|
-
test:ubuntu:
|
16
|
-
stage: test
|
17
|
-
tags:
|
18
|
-
- ubuntu
|
19
|
-
script:
|
20
|
-
- bundle exec rake
|
data/.travis.yml
DELETED