openstudio-analysis 1.0.0.pre.rc3 → 1.0.0.pre.rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/openstudio/analysis/translator/workflow.rb +11 -9
- data/lib/openstudio/analysis/version.rb +1 -1
- data/spec/openstudio/osw_spec.rb +18 -542
- data/spec/openstudio/support_files_spec.rb +14 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54391b81c2f65e4be2f21d880318705e49482bc0
|
4
|
+
data.tar.gz: 0e107eced77ba5b34747b26b73b125d65619d8c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85902d52a7300052efc0914aaa6d40355a5eadb8bf4adbe479dce69505cfddf54d41759104f348aef3dc8f513f142883ea67061106f1d88350f4d3179de4b030
|
7
|
+
data.tar.gz: b25fc97d234143affac537fb34288c7467c2c1afaf465c94bea48c69680d0c3efb2f2ecefe70b75cab99a1914a64f635fa46af8b762d24d41670a0a92eec2470
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
OpenStudio Analysis Gem Change Log
|
2
2
|
==================================
|
3
3
|
|
4
|
+
Version 1.0.0.pre.rc4
|
5
|
+
---------------------
|
6
|
+
* Change seed_model to seed_file in OSWs generated from the translator
|
7
|
+
* Add more unit tests
|
8
|
+
|
4
9
|
Version 1.0.0.pre.rc3
|
5
10
|
---------------------
|
6
11
|
* Catch null arguments when translating from OSA/OSD to OSW
|
@@ -2,9 +2,6 @@ module OpenStudio
|
|
2
2
|
module Analysis
|
3
3
|
module Translator
|
4
4
|
|
5
|
-
require 'json'
|
6
|
-
require 'securerandom'
|
7
|
-
|
8
5
|
class Workflow
|
9
6
|
attr_reader :osa_filename
|
10
7
|
attr_reader :root_path
|
@@ -25,7 +22,7 @@ module OpenStudio
|
|
25
22
|
|
26
23
|
# try to read the osa json file
|
27
24
|
if File.exist?(@osa_filename)
|
28
|
-
@osa = ::JSON.parse(File.read(@osa_filename),
|
25
|
+
@osa = ::JSON.parse(File.read(@osa_filename), symbolize_names: true)[:analysis]
|
29
26
|
else
|
30
27
|
fail "File #{@osa_filename} does not exist"
|
31
28
|
end
|
@@ -46,7 +43,7 @@ module OpenStudio
|
|
46
43
|
step_hash[:measure_dir_name] = File.basename(step[:measure_definition_directory])
|
47
44
|
step_hash[:arguments] = {}
|
48
45
|
# Measures can have no arguments -- make sure to catch it
|
49
|
-
if @osa[:problem][:workflow][i][:arguments]
|
46
|
+
if @osa[:problem][:workflow][i][:arguments]
|
50
47
|
@osa[:problem][:workflow][i][:arguments].each do |arg|
|
51
48
|
step_hash[:arguments][arg[:name].to_sym] = arg[:value]
|
52
49
|
end
|
@@ -55,12 +52,13 @@ module OpenStudio
|
|
55
52
|
end
|
56
53
|
end
|
57
54
|
|
55
|
+
# Convert a file in the form of an OSD into an OSW
|
58
56
|
def process_datapoint(osd_filename)
|
59
57
|
# Try to read the osd json file
|
60
58
|
osd = nil
|
61
59
|
if File.exist?(osd_filename)
|
62
60
|
# warn('data_point selector in ods will be changed to datapoint in version 1.0') # NL this isn't true anymore.
|
63
|
-
osd = ::JSON.parse(File.read(osd_filename),
|
61
|
+
osd = ::JSON.parse(File.read(osd_filename), symbolize_names: true)[:data_point]
|
64
62
|
else
|
65
63
|
fail "File #{osd_filename} does not exist"
|
66
64
|
end
|
@@ -82,7 +80,7 @@ module OpenStudio
|
|
82
80
|
# Save the OSW hash
|
83
81
|
osw = {}
|
84
82
|
created_at = ::Time.now
|
85
|
-
osw[:
|
83
|
+
osw[:seed_file] = @seed_file
|
86
84
|
osw[:weather_file] = @weather_file
|
87
85
|
osw[:file_format_version] = @osw_version
|
88
86
|
osw[:osa_id] = @osa_id
|
@@ -97,13 +95,17 @@ module OpenStudio
|
|
97
95
|
|
98
96
|
# Runs an array of OSD files
|
99
97
|
def process_datapoints(osd_filename_array)
|
98
|
+
r = []
|
100
99
|
osd_filename_array.each do |osd_file|
|
101
100
|
begin
|
102
|
-
|
101
|
+
r << process_datapoint(osd_file)
|
103
102
|
rescue => e
|
104
|
-
|
103
|
+
r << nil
|
104
|
+
puts "Warning: Failed to process datapoint #{osd_file} with error #{e.message} in #{e.backtrace.join('\n')}"
|
105
105
|
end
|
106
106
|
end
|
107
|
+
|
108
|
+
return r
|
107
109
|
end
|
108
110
|
end
|
109
111
|
end
|
data/spec/openstudio/osw_spec.rb
CHANGED
@@ -49,6 +49,8 @@ describe OpenStudio::Analysis::Translator::Workflow do
|
|
49
49
|
let(:osa_path) { 'analysis.osa' }
|
50
50
|
|
51
51
|
before(:each) do
|
52
|
+
FileUtils.mkdir_p 'spec/files/export/workflow' unless Dir.exist? 'spec/files/export/workflow'
|
53
|
+
|
52
54
|
Dir.chdir 'spec/files/workflow'
|
53
55
|
@translator = OpenStudio::Analysis::Translator::Workflow.new(osa_path)
|
54
56
|
end
|
@@ -59,7 +61,16 @@ describe OpenStudio::Analysis::Translator::Workflow do
|
|
59
61
|
|
60
62
|
it 'should write a single osd' do
|
61
63
|
osd_path = 'datapoint_0.osd'
|
62
|
-
|
64
|
+
result = @translator.process_datapoint(osd_path)
|
65
|
+
expect(result).to be_a(Hash)
|
66
|
+
|
67
|
+
# Save the file to the export directory
|
68
|
+
File.open('../../../spec/files/export/workflow/0.osw', 'w') { |f| f << JSON.pretty_generate(result)}
|
69
|
+
|
70
|
+
expect(result.key?(:seed_model)).to eq false
|
71
|
+
expect(result[:seed_file]).to eq 'large_office_air_cooled_chiller.osm'
|
72
|
+
expect(result[:weather_file]).to eq 'USA_CO_Denver.Intl.AP.725650_TMY3.epw'
|
73
|
+
expect(result[:file_format_version]).to eq '0.0.1'
|
63
74
|
end
|
64
75
|
|
65
76
|
it 'should not write a osd with a different osa id' do
|
@@ -69,550 +80,15 @@ describe OpenStudio::Analysis::Translator::Workflow do
|
|
69
80
|
|
70
81
|
it 'should write several osds' do
|
71
82
|
osd_paths = %w(datapoint_0.osd datapoint_1.osd datapoint_2.osd)
|
72
|
-
|
83
|
+
r = @translator.process_datapoints(osd_paths)
|
84
|
+
expect(r.size).to eq 3
|
73
85
|
end
|
74
86
|
|
75
87
|
it 'should not fail when one osd is bad' do
|
76
|
-
osd_paths = %w(datapoint_0.osd datapoint_1.osd
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
=begin
|
81
|
-
context 'small list of incomplete variables' do
|
82
|
-
before(:all) do
|
83
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_09_small_list_incomplete.xlsx')
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should fail to process' do
|
87
|
-
expect { @excel.process }.to raise_error('Variable adjust_thermostat_setpoints_by_degrees:cooling_adjustment must have a mean')
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'small list with with repeated variable names' do
|
92
|
-
before(:all) do
|
93
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_09_small_list_repeat_vars.xlsx')
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should fail to process' do
|
97
|
-
expect { @excel.process }.to raise_error("duplicate variable names found in list [\"Insulation R-value (ft^2*h*R/Btu).\"]")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context 'small list of variables should not validate' do
|
102
|
-
before(:all) do
|
103
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_09_small_list_validation_errors.xlsx')
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'should fail to process' do
|
107
|
-
error_message = 'Variable min is greater than variable max for adjust_thermostat_setpoints_by_degrees:heating_adjustment'
|
108
|
-
expect { @excel.process }.to raise_error(error_message)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'small list of variables' do
|
113
|
-
before(:all) do
|
114
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_09_small_list.xlsx')
|
115
|
-
@excel.process
|
116
|
-
end
|
117
|
-
it 'should have a model' do
|
118
|
-
expect(@excel.models.first).not_to be_nil
|
119
|
-
expect(@excel.models.first[:name]).to eq('small_seed')
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should have a weather file' do
|
123
|
-
expect(@excel.weather_files.first).not_to be_nil
|
124
|
-
expect(@excel.weather_files.first.include?('partial_weather')).to eq(true)
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'should have notes and source' do
|
128
|
-
@excel.variables['data'].each do |measure|
|
129
|
-
measure['variables'].each do |var|
|
130
|
-
if var['machine_name'] == 'lighting_power_reduction'
|
131
|
-
expect(var['distribution']['source']).to eq('some data source')
|
132
|
-
elsif var['machine_name'] == 'demo_cost_initial_const'
|
133
|
-
expect(var['notes']).to eq('some note')
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'should write a json' do
|
140
|
-
@excel.save_analysis
|
141
|
-
expect(File).to exist('spec/files/export/analysis/example_analysis.json')
|
142
|
-
expect(File).to exist('spec/files/export/analysis/example_analysis.zip')
|
143
|
-
|
144
|
-
expect(JSON.parse(File.read('spec/files/export/analysis/example_analysis.json'))).not_to be_nil
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context 'setup version 0.1.9' do
|
149
|
-
before(:all) do
|
150
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_09_setup_version_2.xlsx')
|
151
|
-
@excel.process
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'should have a version and analysis name in machine format' do
|
155
|
-
expect(@excel.version).to eq('0.1.9')
|
156
|
-
expect(@excel.analysis_name).to eq('example_analysis')
|
157
|
-
end
|
158
|
-
it 'should have the new settings' do
|
159
|
-
expect(@excel.settings['server_instance_type']).to eq('m2.xlarge')
|
160
|
-
end
|
161
|
-
|
162
|
-
it 'should have algorithm setup' do
|
163
|
-
h = @excel.analysis
|
164
|
-
|
165
|
-
expect(h.algorithm['number_of_samples']).to eq(100)
|
166
|
-
expect(h.algorithm['number_of_generations']).to eq(20)
|
167
|
-
expect(h.algorithm['sample_method']).to eq('all_variables')
|
168
|
-
expect(h.algorithm['number_of_generations']).to be_a Integer
|
169
|
-
expect(h.algorithm['tolerance']).to eq(0.115)
|
170
|
-
expect(h.algorithm['tolerance']).to be_a Float
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'should create a valid hash' do
|
174
|
-
h = @excel.analysis
|
175
|
-
|
176
|
-
expect(h.analysis_type).to eq('lhs')
|
177
|
-
expect(h.algorithm).to be_a OpenStudio::Analysis::AlgorithmAttributes
|
178
|
-
expect(h.algorithm['number_of_samples']).to eq(100)
|
179
|
-
expect(h.algorithm['sample_method']).to eq('all_variables')
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context 'proxy setup' do
|
184
|
-
before(:all) do
|
185
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_10_proxy.xlsx')
|
186
|
-
@excel.process
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'should have a proxy setting' do
|
190
|
-
expect(@excel.settings['proxy_host']).to eq('192.168.0.1')
|
191
|
-
expect(@excel.settings['proxy_port']).to eq(8080)
|
192
|
-
expect(@excel.settings['proxy_username']).to be_nil
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
context 'proxy setup with user' do
|
197
|
-
before(:all) do
|
198
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_10_proxy_user.xlsx')
|
199
|
-
@excel.process
|
200
|
-
end
|
201
|
-
|
202
|
-
it 'should have a user' do
|
203
|
-
expect(@excel.settings['proxy_host']).to eq('192.168.0.1')
|
204
|
-
expect(@excel.settings['proxy_port']).to eq(8080)
|
205
|
-
expect(@excel.settings['proxy_username']).to eq('a_user')
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
context 'discrete variables' do
|
210
|
-
before(:all) do
|
211
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_11_discrete_variables.xlsx')
|
212
|
-
@excel.process
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'should have parsed the spreadsheet' do
|
216
|
-
@excel.variables['data'].each do |measure|
|
217
|
-
measure['variables'].each do |var|
|
218
|
-
# TODO: Add some tests!
|
219
|
-
if var['name'] == 'alter_design_days'
|
220
|
-
expect(var['type']).to eq 'bool'
|
221
|
-
expect(var['distribution']['discrete_values']).to match_array [true, false]
|
222
|
-
expect(var['distribution']['discrete_weights']).to match_array [0.8, 0.2]
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
it 'should save the file' do
|
229
|
-
@excel.save_analysis
|
230
|
-
expect(File.exist?('spec/files/export/analysis/example_analysis.json')).to eq true
|
231
|
-
expect(File.exist?('spec/files/export/analysis/example_analysis.zip')).to eq true
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
context 'discrete with dynamic columns' do
|
236
|
-
before(:all) do
|
237
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_12_discrete_dynamic_columns.xlsx')
|
238
|
-
@excel.process
|
239
|
-
end
|
240
|
-
|
241
|
-
it 'should have parsed the spreadsheet' do
|
242
|
-
@excel.variables['data'].each do |measure|
|
243
|
-
measure['variables'].each do |_var|
|
244
|
-
# TODO: test something?
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
it 'should save the file' do
|
250
|
-
@excel.save_analysis
|
251
|
-
expect(File.exist?('spec/files/export/analysis/test_model.json')).to eq true
|
252
|
-
expect(File.exist?('spec/files/export/analysis/test_model.zip')).to eq true
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
context 'setup output variables' do
|
257
|
-
before(:all) do
|
258
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_09_outputvars.xlsx')
|
259
|
-
@excel.process
|
260
|
-
end
|
261
|
-
|
262
|
-
it 'should have a model' do
|
263
|
-
expect(@excel.models.first).not_to be_nil
|
264
|
-
expect(@excel.models.first[:name]).to eq('0_1_09_outputvars')
|
265
|
-
end
|
266
|
-
|
267
|
-
it 'should have a weather file' do
|
268
|
-
expect(@excel.weather_files.first).not_to be_nil
|
269
|
-
expect(@excel.weather_files.first.include?('partial_weather')).to eq(true)
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'should have notes and source' do
|
273
|
-
@excel.variables['data'].each do |measure|
|
274
|
-
measure['variables'].each do |var|
|
275
|
-
if var['machine_name'] == 'lighting_power_reduction'
|
276
|
-
expect(var['distribution']['source']).to eq('some data source')
|
277
|
-
elsif var['machine_name'] == 'demo_cost_initial_const'
|
278
|
-
expect(var['notes']).to eq('some note')
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'should have algorithm setup' do
|
285
|
-
expect(@excel.algorithm['number_of_samples']).to eq(100)
|
286
|
-
expect(@excel.algorithm['number_of_generations']).to eq(20)
|
287
|
-
expect(@excel.algorithm['sample_method']).to eq('all_variables')
|
288
|
-
expect(@excel.algorithm['number_of_generations']).to be_a Integer
|
289
|
-
# expect(@excel.algorithm["tolerance"]).to eq(0.115)
|
290
|
-
# expect(@excel.algorithm["tolerance"]).to be_a Float
|
291
|
-
end
|
292
|
-
|
293
|
-
it 'should create a valid hash' do
|
294
|
-
h = @excel.analysis
|
295
|
-
|
296
|
-
expect(h.analysis_type).to eq('nsga')
|
297
|
-
expect(h.algorithm).to be_a OpenStudio::Analysis::AlgorithmAttributes
|
298
|
-
expect(h.algorithm['number_of_samples']).to eq(100)
|
299
|
-
expect(h.algorithm['sample_method']).to eq('all_variables')
|
300
|
-
end
|
301
|
-
|
302
|
-
it 'should write a json' do
|
303
|
-
@excel.save_analysis
|
304
|
-
expect(File).to exist('spec/files/export/analysis/0_1_09_outputvars.json')
|
305
|
-
expect(File).to exist('spec/files/export/analysis/0_1_09_outputvars.zip')
|
306
|
-
expect(JSON.parse(File.read('spec/files/export/analysis/0_1_09_outputvars.json'))).not_to be_nil
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
context 'version 0.1.10' do
|
311
|
-
before(:all) do
|
312
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_1_10_template_input.xlsx')
|
313
|
-
end
|
314
|
-
|
315
|
-
it 'should process' do
|
316
|
-
expect(@excel.process).to eq(true)
|
317
|
-
end
|
318
|
-
|
319
|
-
it 'should have new setting variables' do
|
320
|
-
expect(@excel.settings['user_id']).to eq('new_user')
|
321
|
-
expect(@excel.settings['openstudio_server_version']).to eq('1.3.2')
|
322
|
-
expect(@excel.cluster_name).to eq('analysis_cluster')
|
323
|
-
expect(@excel.run_setup['analysis_name']).to eq('LHS Example Project')
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
context 'version 0.2.0' do
|
328
|
-
before(:all) do
|
329
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_2_0_template.xlsx')
|
330
|
-
end
|
331
|
-
|
332
|
-
it 'should process' do
|
333
|
-
expect(@excel.process).to eq(true)
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'should have new setting variables' do
|
337
|
-
expect(@excel.settings['user_id']).to eq('new_user')
|
338
|
-
expect(@excel.settings['openstudio_server_version']).to eq('1.3.2')
|
339
|
-
expect(@excel.cluster_name).to eq('analysis_cluster_name')
|
340
|
-
expect(@excel.run_setup['analysis_name']).to eq('Name goes here')
|
341
|
-
end
|
342
|
-
|
343
|
-
it 'should have the new measure directory column' do
|
344
|
-
expect(@excel.variables['data'][1]['measure_file_name_directory']).to eq('ReduceLightingLoadsByPercentage')
|
345
|
-
end
|
346
|
-
|
347
|
-
it 'should write a json' do
|
348
|
-
@excel.save_analysis
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
context 'version 0.2.0 simple' do
|
353
|
-
before(:all) do
|
354
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_2_0_template_simpletest.xlsx')
|
355
|
-
end
|
356
|
-
|
357
|
-
it 'should process' do
|
358
|
-
expect(@excel.process).to eq(true)
|
359
|
-
end
|
360
|
-
|
361
|
-
it 'should have new setting variables' do
|
362
|
-
expect(@excel.settings['user_id']).to eq('new_user')
|
363
|
-
expect(@excel.settings['openstudio_server_version']).to eq('1.3.2')
|
364
|
-
end
|
365
|
-
|
366
|
-
it 'should have the new measure directory column' do
|
367
|
-
expect(@excel.variables['data'][0]['measure_file_name_directory']).to eq('ExampleMeasure')
|
368
|
-
expect(@excel.variables['data'][0]['display_name']).to eq('Baseline')
|
369
|
-
end
|
370
|
-
|
371
|
-
it 'should write a json' do
|
372
|
-
@excel.save_analysis
|
373
|
-
expect(File.exist?('spec/files/export/analysis/simple_test.json')).to eq true
|
374
|
-
expect(File.exist?('spec/files/export/analysis/simple_test.zip')).to eq true
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
context 'version 0.3.0 objective functions' do
|
379
|
-
before(:all) do
|
380
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_3_0_outputs.xlsx')
|
381
|
-
expect(@excel.process).to eq(true)
|
382
|
-
end
|
383
|
-
|
384
|
-
it 'should have new setting variables' do
|
385
|
-
expect(@excel.settings['user_id']).to eq('new_user')
|
386
|
-
expect(@excel.settings['openstudio_server_version']).to eq('1.6.1')
|
387
|
-
end
|
388
|
-
|
389
|
-
it 'should have typed outputs' do
|
390
|
-
h = @excel.analysis
|
391
|
-
|
392
|
-
expect(h.outputs).to be_an Array
|
393
|
-
h.outputs.each do |o|
|
394
|
-
if o['name'] == 'standard_report_legacy.total_energy'
|
395
|
-
expect(o['variable_type']).to eq 'double'
|
396
|
-
expect(o['objective_function']).to eq true
|
397
|
-
expect(o['objective_function_index']).to eq 0
|
398
|
-
expect(o['objective_function_target']).to eq nil
|
399
|
-
expect(o['scaling_factor']).to eq nil
|
400
|
-
expect(o['objective_function_group']).to eq 1
|
401
|
-
end
|
402
|
-
if o['name'] == 'standard_report_legacy.total_source_energy'
|
403
|
-
expect(o['variable_type']).to eq 'double'
|
404
|
-
expect(o['objective_function']).to eq true
|
405
|
-
expect(o['objective_function_index']).to eq 1
|
406
|
-
expect(o['objective_function_target']).to eq 25.1
|
407
|
-
expect(o['scaling_factor']).to eq 25.2
|
408
|
-
expect(o['objective_function_group']).to eq 7
|
409
|
-
end
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
it 'should write a json' do
|
414
|
-
@excel.save_analysis
|
415
|
-
expect(File.exist?('spec/files/export/analysis/0_3_0_outputs.json')).to eq true
|
416
|
-
expect(File.exist?('spec/files/export/analysis/0_3_0_outputs.zip')).to eq true
|
417
|
-
|
418
|
-
# check the JSON
|
419
|
-
h = JSON.parse(File.read('spec/files/export/analysis/0_3_0_outputs.json'))
|
420
|
-
expect(h['analysis']['weather_file']).to be_a Hash
|
421
|
-
expect(h['analysis']['weather_file']['path']).to match /partial_weather.*epw/
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
context 'version 0.3.0 measure existence checks' do
|
426
|
-
before(:all) do
|
427
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_3_0_measure_existence.xlsx')
|
428
|
-
end
|
429
|
-
|
430
|
-
it 'should process' do
|
431
|
-
expect(@excel.process).to eq(true)
|
432
|
-
|
433
|
-
model_name = @excel.models.first[:name]
|
434
|
-
expect(model_name).to eq '0_3_0_outputs'
|
435
|
-
end
|
436
|
-
|
437
|
-
it 'should error out with missing measure information' do
|
438
|
-
expect { @excel.save_analysis }.to raise_error /Measure in directory.*not contain a measure.rb.*$/
|
439
|
-
end
|
440
|
-
end
|
441
|
-
|
442
|
-
context 'version 0.3.0 dynamic uuid assignments' do
|
443
|
-
before(:all) do
|
444
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_3_0_dynamic_uuids.xlsx')
|
445
|
-
expect(@excel.process).to eq(true)
|
446
|
-
end
|
447
|
-
|
448
|
-
it 'should process' do
|
449
|
-
model_uuid = @excel.models.first[:name]
|
450
|
-
expect(model_uuid).to match /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
|
451
|
-
end
|
452
|
-
|
453
|
-
it 'should error out with missing measure information' do
|
454
|
-
@excel.save_analysis
|
455
|
-
model_uuid = @excel.models.first[:name]
|
456
|
-
expect(File.exist?('spec/files/export/analysis/0_3_0_dynamic_uuids.json')).to eq true
|
457
|
-
expect(File.exist?('spec/files/export/analysis/0_3_0_dynamic_uuids.zip')).to eq true
|
458
|
-
end
|
459
|
-
end
|
460
|
-
|
461
|
-
context 'version 0.3.3 and short display names' do
|
462
|
-
before :all do
|
463
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_3_3_short_names.xlsx')
|
464
|
-
expect(@excel.process).to eq(true)
|
465
|
-
end
|
466
|
-
|
467
|
-
it 'should process' do
|
468
|
-
model_uuid = @excel.models.first[:name]
|
469
|
-
expect(model_uuid).to match /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
|
470
|
-
end
|
471
|
-
|
472
|
-
it 'should process and save short display names' do
|
473
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_3_3_short_names.xlsx')
|
474
|
-
expect(@excel.process).to eq(true)
|
475
|
-
@excel.save_analysis
|
476
|
-
model_uuid = @excel.models.first[:name]
|
477
|
-
expect(File.exist?('spec/files/export/analysis/0_3_3_short_names.json')).to eq true
|
478
|
-
expect(File.exist?('spec/files/export/analysis/0_3_3_short_names.zip')).to eq true
|
479
|
-
|
480
|
-
@excel.outputs['output_variables'].each do |o|
|
481
|
-
expect(o['display_name_short']).to eq 'Site EUI' if o['name'] == 'standard_report_legacy.total_energy'
|
482
|
-
expect(o['display_name_short']).to eq 'Natural Gas Heating Intensity' if o['name'] == 'standard_report_legacy.heating_natural_gas'
|
483
|
-
end
|
484
|
-
|
485
|
-
# Check the JSON
|
486
|
-
j = JSON.parse(File.read('spec/files/export/analysis/0_3_3_short_names.json'))
|
487
|
-
|
488
|
-
expect(j['analysis']['output_variables'].first['display_name']).to eq 'Total Site Energy Intensity'
|
489
|
-
expect(j['analysis']['output_variables'].first['display_name_short']).to eq 'Site EUI'
|
490
|
-
expect(j['analysis']['problem']['workflow'][0]['variables'][0]['argument']['display_name']).to eq 'Orientation'
|
491
|
-
expect(j['analysis']['problem']['workflow'][0]['variables'][0]['argument']['display_name_short']).to eq 'Shorter Display Name'
|
492
|
-
expect(j['analysis']['problem']['workflow'][1]['arguments'][0]['display_name']).to eq 'unknown'
|
493
|
-
expect(j['analysis']['problem']['workflow'][1]['arguments'][0]['display_name_short']).to eq 'un'
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
context 'version 0.3.5 and measure paths' do
|
498
|
-
before :all do
|
499
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_3_5_multiple_measure_paths.xlsx')
|
500
|
-
expect(@excel.process).to eq(true)
|
501
|
-
end
|
502
|
-
|
503
|
-
it 'should save the analysis' do
|
504
|
-
@excel.save_analysis
|
505
|
-
model_uuid = @excel.models.first[:name]
|
506
|
-
|
507
|
-
expect(File.exist?('spec/files/export/analysis/0_3_5_multiple_measure_paths.json')).to eq true
|
508
|
-
expect(File.exist?('spec/files/export/analysis/0_3_5_multiple_measure_paths.zip')).to eq true
|
509
|
-
|
510
|
-
expect(@excel.settings['openstudio_server_version']).to eq('1.8.0')
|
511
|
-
expect(@excel.settings['spreadsheet_version']).to eq '0.3.5'
|
512
|
-
expect(@excel.settings['server_instance_type']).to eq 'm3.xlarge'
|
513
|
-
expect(@excel.settings['worker_instance_type']).to eq 'c3.2xlarge'
|
514
|
-
|
515
|
-
expect(@excel.aws_tags).to eq(['org=5500', 'nothing=else matters'])
|
516
|
-
end
|
517
|
-
end
|
518
|
-
|
519
|
-
context 'version 0.3.7 and worker init-final scripts' do
|
520
|
-
before :all do
|
521
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_3_7_worker_init_final.xlsx')
|
522
|
-
expect(@excel.process).to eq(true)
|
523
|
-
end
|
524
|
-
|
525
|
-
it 'should save the analysis' do
|
526
|
-
@excel.save_analysis
|
527
|
-
model_uuid = @excel.models.first[:name]
|
528
|
-
|
529
|
-
expect(File.exist?('spec/files/export/analysis/0_3_7_worker_init_final.json')).to eq true
|
530
|
-
expect(File.exist?('spec/files/export/analysis/0_3_7_worker_init_final.zip')).to eq true
|
531
|
-
|
532
|
-
expect(@excel.worker_inits.size).to eq 2
|
533
|
-
expect(@excel.worker_inits[0][:name]).to eq 'initialize me'
|
534
|
-
expect(@excel.worker_inits[0][:args]).to eq "[\"first_arg\",2,{a_hash: \"input\"}]"
|
535
|
-
|
536
|
-
# test the eval'ing of the args
|
537
|
-
a = eval(@excel.analysis.worker_inits.first[:metadata][:args])
|
538
|
-
expect(a[0]).to eq 'first_arg'
|
539
|
-
expect(a[1]).to eq 2
|
540
|
-
expect(a[2]).to be_a Hash
|
541
|
-
expect(a[2][:a_hash]).to eq 'input'
|
542
|
-
|
543
|
-
expect(File.basename(@excel.analysis.worker_inits.first[:file])).to eq 'first_file.rb'
|
544
|
-
expect(File.basename(@excel.analysis.worker_inits.last[:file])).to eq 'second_file.rb'
|
545
|
-
|
546
|
-
expect(@excel.analysis.worker_finalizes.size).to eq 1
|
547
|
-
expect(File.basename(@excel.analysis.worker_finalizes.first[:file])).to eq 'first_file.rb'
|
548
|
-
end
|
549
|
-
end
|
550
|
-
|
551
|
-
context 'version 0.3.7 and worker init-final scripts' do
|
552
|
-
before :all do
|
553
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_4_0_lhs_discrete_continuous.xlsx')
|
554
|
-
end
|
555
|
-
|
556
|
-
it 'should fail to process' do
|
557
|
-
@excel.process
|
558
|
-
# expect { @excel.process }.to raise_error("Measure Display Names are not unique for 'Rotate Building Relative to Current Orientation', 'Nothing Important'")
|
559
|
-
|
560
|
-
@excel.save_analysis
|
561
|
-
end
|
562
|
-
end
|
563
|
-
|
564
|
-
context 'version 0.4.0 multiple seed models' do
|
565
|
-
before :all do
|
566
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_4_0_multiple_seeds.xlsx')
|
567
|
-
expect(@excel.process).to eq(true)
|
568
|
-
end
|
569
|
-
|
570
|
-
it 'should save the analysis' do
|
571
|
-
expect { @excel.analysis }.to raise_error /There are more than one seed models defined in the excel file. Call .analyses. to return the array/
|
572
|
-
model_uuid = "#{@excel.name.snake_case}_#{@excel.models.first[:name]}"
|
573
|
-
|
574
|
-
@excel.save_analysis # this will save all the analyses
|
575
|
-
|
576
|
-
@excel.models.each do |f|
|
577
|
-
model_uuid = "#{@excel.name.snake_case}_#{f[:name]}"
|
578
|
-
puts model_uuid
|
579
|
-
expect(File.exist?("spec/files/export/analysis/#{model_uuid}.json")).to eq true
|
580
|
-
expect(File.exist?("spec/files/export/analysis/#{model_uuid}.zip")).to eq true
|
581
|
-
end
|
582
|
-
|
583
|
-
expect(@excel.settings['openstudio_server_version']).to eq('1.11.0-rc2')
|
584
|
-
expect(@excel.settings['spreadsheet_version']).to eq '0.3.7'
|
585
|
-
expect(@excel.settings['server_instance_type']).to eq 'm3.xlarge'
|
586
|
-
expect(@excel.settings['worker_instance_type']).to eq 'c3.4xlarge'
|
587
|
-
expect(@excel.aws_tags).to eq(['org=5500'])
|
588
|
-
end
|
589
|
-
end
|
590
|
-
|
591
|
-
context 'version 0.4.0 pivot test' do
|
592
|
-
before :all do
|
593
|
-
@excel = OpenStudio::Analysis::Translator::Excel.new('spec/files/0_4_0_pivot_test.xlsx')
|
594
|
-
expect(@excel.process).to eq(true)
|
595
|
-
end
|
596
|
-
|
597
|
-
it 'should save the analysis' do
|
598
|
-
a = @excel.analysis
|
599
|
-
|
600
|
-
@excel.save_analysis # this will save all the analyses
|
601
|
-
|
602
|
-
j = JSON.parse(File.read('spec/files/export/analysis/pivot_test.json'))
|
603
|
-
|
604
|
-
expect(j['analysis']['problem']['workflow'][0]['name']).to eq 'reduce_lighting_loads_by_percentage'
|
605
|
-
expect(j['analysis']['problem']['workflow'][0]['variables'][0]['variable_type']).to eq 'pivot'
|
606
|
-
expect(j['analysis']['problem']['workflow'][0]['variables'][0]['pivot']).to eq true
|
607
|
-
expect(j['analysis']['problem']['workflow'][1]['variables'][0]['variable']).to eq true
|
608
|
-
expect(j['analysis']['problem']['workflow'][1]['variables'][0]['pivot']).to eq nil
|
609
|
-
|
610
|
-
expect(@excel.settings['openstudio_server_version']).to eq('1.11.0-rc2')
|
611
|
-
expect(@excel.settings['spreadsheet_version']).to eq '0.3.7'
|
612
|
-
expect(@excel.settings['server_instance_type']).to eq 'm3.xlarge'
|
613
|
-
expect(@excel.settings['worker_instance_type']).to eq 'c3.4xlarge'
|
614
|
-
expect(@excel.aws_tags).to eq(['org=5500'])
|
88
|
+
osd_paths = %w(datapoint_0.osd datapoint_1.osd datapoint_wrong_osa_id.osd)
|
89
|
+
r = @translator.process_datapoints(osd_paths)
|
90
|
+
expect(r[0]).to be_a Hash
|
91
|
+
expect(r[2]).to eq nil
|
615
92
|
end
|
616
93
|
end
|
617
|
-
=end
|
618
94
|
end
|
@@ -30,9 +30,21 @@ describe OpenStudio::Analysis::SupportFiles do
|
|
30
30
|
expect(@s.size).to eq 0
|
31
31
|
end
|
32
32
|
|
33
|
-
it 'should only add existing files'
|
33
|
+
it 'should only add existing files' do
|
34
|
+
f = 'spec/files/worker_init/second_file.rb'
|
35
|
+
@s.add(f)
|
36
|
+
@s.add(f)
|
37
|
+
|
38
|
+
expect(@s.size).to eq 1
|
39
|
+
|
40
|
+
f = 'non-existent.rb'
|
41
|
+
expect{@s.add(f)}.to raise_error /Path or file does not exist and cannot be added.*/
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should add metadata data' do
|
45
|
+
|
46
|
+
end
|
34
47
|
|
35
|
-
it 'should add metadata data'
|
36
48
|
|
37
49
|
it 'should add a directory' do
|
38
50
|
@s.clear
|