openstudio-analysis 0.4.5 → 1.0.0.pat1
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/.travis.yml +1 -1
- data/CHANGELOG.md +7 -3
- data/Gemfile +1 -0
- data/README.md +53 -47
- data/lib/openstudio/analysis/formulation.rb +1 -1
- data/lib/openstudio/analysis/server_api.rb +143 -246
- data/lib/openstudio/analysis/translator/datapoints.rb +8 -3
- data/lib/openstudio/analysis/translator/excel.rb +16 -4
- data/lib/openstudio/analysis/translator/workflow.rb +106 -0
- data/lib/openstudio/analysis/version.rb +1 -1
- data/lib/openstudio/analysis/workflow_step.rb +5 -2
- data/lib/openstudio/analysis.rb +85 -0
- data/lib/openstudio-analysis.rb +1 -0
- data/openstudio-analysis.gemspec +4 -3
- data/spec/files/workflow/analysis.osa +1334 -0
- data/spec/files/workflow/datapoint_0.osd +63 -0
- data/spec/files/workflow/datapoint_1.osd +63 -0
- data/spec/files/workflow/datapoint_2.osd +63 -0
- data/spec/files/workflow/datapoint_wrong_osa_id.osd +65 -0
- data/spec/openstudio/excel_spec.rb +0 -5
- data/spec/openstudio/osw_spec.rb +618 -0
- metadata +36 -9
@@ -0,0 +1,618 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OpenStudio::Analysis::Translator::Workflow do
|
4
|
+
before :all do
|
5
|
+
clean_dir = File.expand_path 'spec/files/workflow/datapoints'
|
6
|
+
|
7
|
+
if Dir.exist? clean_dir
|
8
|
+
FileUtils.rm_rf clean_dir
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'read in the osa' do
|
13
|
+
let(:osa_path) { File.expand_path 'analysis.osa' }
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
Dir.chdir 'spec/files/workflow'
|
17
|
+
@translator = OpenStudio::Analysis::Translator::Workflow.new(osa_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
after(:each) do
|
21
|
+
Dir.chdir '../../..'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should find and load the osa' do
|
25
|
+
expect(@translator).not_to be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should load the analysis' do
|
29
|
+
expect(@translator.osa.class).to eq(Hash)
|
30
|
+
expect(@translator.osa).not_to eq({})
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not have measure or file paths' do
|
34
|
+
expect(@translator.file_paths).to eq([])
|
35
|
+
expect(@translator.measure_paths).to eq([])
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should have steps' do
|
39
|
+
expect(@translator.steps.class).to eq(Array)
|
40
|
+
expect(@translator.steps).not_to eq([])
|
41
|
+
@translator.steps.each do |step|
|
42
|
+
expect(step.class).to eq(Hash)
|
43
|
+
expect(step).not_to eq({})
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'write individual osws' do
|
49
|
+
let(:osa_path) { 'analysis.osa' }
|
50
|
+
|
51
|
+
before(:each) do
|
52
|
+
Dir.chdir 'spec/files/workflow'
|
53
|
+
@translator = OpenStudio::Analysis::Translator::Workflow.new(osa_path)
|
54
|
+
end
|
55
|
+
|
56
|
+
after(:each) do
|
57
|
+
Dir.chdir '../../..'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should write a single osd' do
|
61
|
+
osd_path = 'datapoint_0.osd'
|
62
|
+
expect{ @translator.process_datapoint(osd_path) }.not_to raise_error
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should not write a osd with a different osa id' do
|
66
|
+
osd_path = 'datapoint_wrong_osa_id.osd'
|
67
|
+
expect{ @translator.process_datapoint(osd_path).first }.to raise_error(RuntimeError)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should write several osds' do
|
71
|
+
osd_paths = %w(datapoint_0.osd datapoint_1.osd datapoint_2.osd)
|
72
|
+
expect{ @translator.process_datapoints(osd_paths).each {|_|} }.not_to raise_error
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should not fail when one osd is bad' do
|
76
|
+
osd_paths = %w(datapoint_0.osd datapoint_1.osd datapoint_2.osd)
|
77
|
+
expect{ @translator.process_datapoints(osd_paths).each {|_|} }.not_to raise_error
|
78
|
+
end
|
79
|
+
end
|
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'])
|
615
|
+
end
|
616
|
+
end
|
617
|
+
=end
|
618
|
+
end
|