openstudio-analysis 1.0.0.rc9 → 1.0.0.rc10
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/.rubocop.yml +47 -43
- data/CHANGELOG.md +5 -0
- data/lib/openstudio/analysis/formulation.rb +4 -4
- data/lib/openstudio/analysis/server_api.rb +69 -69
- data/lib/openstudio/analysis/support_files.rb +1 -1
- data/lib/openstudio/analysis/translator/datapoints.rb +61 -42
- data/lib/openstudio/analysis/translator/excel.rb +38 -38
- data/lib/openstudio/analysis/translator/workflow.rb +3 -4
- data/lib/openstudio/analysis/version.rb +1 -1
- data/lib/openstudio/analysis/workflow.rb +8 -8
- data/lib/openstudio/analysis/workflow_step.rb +27 -18
- data/lib/openstudio/analysis.rb +6 -6
- data/lib/openstudio/helpers/string.rb +2 -2
- data/lib/openstudio/weather/epw.rb +2 -2
- data/openstudio-analysis.gemspec +1 -1
- data/spec/openstudio/excel_spec.rb +4 -4
- data/spec/openstudio/formulation_spec.rb +2 -2
- data/spec/openstudio/osw_spec.rb +2 -2
- data/spec/openstudio/support_files_spec.rb +1 -3
- data/spec/openstudio/workflow_spec.rb +1 -1
- data/spec/schema/osa.json +3 -0
- metadata +2 -2
@@ -35,7 +35,7 @@ module OpenStudio
|
|
35
35
|
if File.exist?(@csv_filename)
|
36
36
|
@csv = CSV.read(@csv_filename)
|
37
37
|
else
|
38
|
-
|
38
|
+
raise "File #{@csv_filename} does not exist"
|
39
39
|
end
|
40
40
|
|
41
41
|
# Remove nil rows and check row length
|
@@ -66,7 +66,7 @@ module OpenStudio
|
|
66
66
|
# Seperate CSV into meta and measure groups
|
67
67
|
measure_tag_index = nil
|
68
68
|
@csv.each_with_index { |row, index| measure_tag_index = index if row[0] == 'BEGIN-MEASURES' }
|
69
|
-
|
69
|
+
raise "ERROR: No 'BEGIN-MEASURES' tag found in input csv file." unless measure_tag_index
|
70
70
|
meta_rows = []
|
71
71
|
measure_rows = []
|
72
72
|
@csv.each_with_index do |_, index|
|
@@ -77,7 +77,7 @@ module OpenStudio
|
|
77
77
|
@setup = parse_csv_meta(meta_rows)
|
78
78
|
|
79
79
|
@version = Semantic::Version.new @version
|
80
|
-
|
80
|
+
raise "CSV interface version #{@version} is no longer supported. Please upgrade your csv interface to at least 0.0.1" if @version < '0.0.0'
|
81
81
|
|
82
82
|
@variables = parse_csv_measures(measure_rows)
|
83
83
|
|
@@ -103,34 +103,34 @@ module OpenStudio
|
|
103
103
|
def validate_analysis
|
104
104
|
# Setup the paths and do some error checking
|
105
105
|
@measure_paths.each do |mp|
|
106
|
-
|
106
|
+
raise "Measures directory '#{mp}' does not exist" unless Dir.exist?(mp)
|
107
107
|
end
|
108
108
|
|
109
109
|
@models.uniq!
|
110
|
-
|
110
|
+
raise 'No seed models defined in spreadsheet' if @models.empty?
|
111
111
|
|
112
112
|
@models.each do |model|
|
113
|
-
|
113
|
+
raise "Seed model does not exist: #{model[:path]}" unless File.exist?(model[:path])
|
114
114
|
end
|
115
115
|
|
116
116
|
@weather_paths.uniq!
|
117
|
-
|
117
|
+
raise 'No weather files found based on what is in the spreadsheet' if @weather_paths.empty?
|
118
118
|
|
119
119
|
@weather_paths.each do |wf|
|
120
|
-
|
120
|
+
raise "Weather file does not exist: #{wf}" unless File.exist?(wf)
|
121
121
|
end
|
122
122
|
|
123
123
|
# This can be a directory as well
|
124
124
|
@other_files.each do |f|
|
125
|
-
|
125
|
+
raise "Other files do not exist for: #{f[:path]}" unless File.exist?(f[:path])
|
126
126
|
end
|
127
127
|
|
128
128
|
@worker_inits.each do |f|
|
129
|
-
|
129
|
+
raise "Worker initialization file does not exist for: #{f[:path]}" unless File.exist?(f[:path])
|
130
130
|
end
|
131
131
|
|
132
132
|
@worker_finals.each do |f|
|
133
|
-
|
133
|
+
raise "Worker finalization file does not exist for: #{f[:path]}" unless File.exist?(f[:path])
|
134
134
|
end
|
135
135
|
|
136
136
|
FileUtils.mkdir_p(@export_path)
|
@@ -140,13 +140,13 @@ module OpenStudio
|
|
140
140
|
measure_display_names = @variables.map { |m| m[:measure_data][:display_name] }.compact
|
141
141
|
measure_display_names_mult = measure_display_names.select { |m| measure_display_names.count(m) > 1 }.uniq
|
142
142
|
if measure_display_names_mult && !measure_display_names_mult.empty?
|
143
|
-
|
143
|
+
raise "Measure Display Names are not unique for '#{measure_display_names_mult.join('\', \'')}'"
|
144
144
|
end
|
145
145
|
|
146
146
|
variable_names = @variables.map { |v| v[:vars].map { |hash| hash[:display_name] } }.flatten
|
147
147
|
dupes = variable_names.select { |e| variable_names.count(e) > 1 }.uniq
|
148
148
|
if dupes.count > 0
|
149
|
-
|
149
|
+
raise "duplicate variable names found in list #{dupes.inspect}"
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
@@ -155,8 +155,8 @@ module OpenStudio
|
|
155
155
|
# @append_model_name [Boolean] Append the name of the seed model to the display name
|
156
156
|
# @return [Object] An OpenStudio::Analysis
|
157
157
|
def analysis(seed_model = nil, append_model_name = false)
|
158
|
-
|
159
|
-
|
158
|
+
raise 'There are no seed models defined in the excel file. Please add one.' if @models.size == 0
|
159
|
+
raise 'There are more than one seed models defined in the excel file. This is not supported by the CSV Translator.' if @models.size > 1 && seed_model.nil?
|
160
160
|
|
161
161
|
seed_model = @models.first if seed_model.nil?
|
162
162
|
|
@@ -174,12 +174,12 @@ module OpenStudio
|
|
174
174
|
measure[:measure_data][:local_path_to_measure] = "#{measure_dir_to_add}/measure.rb"
|
175
175
|
break
|
176
176
|
else
|
177
|
-
|
177
|
+
raise "Measure in directory '#{measure_dir_to_add}' did not contain a measure.rb file"
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
-
|
182
|
+
raise "Could not find measure '#{measure['name']}' in directory named '#{measure['measure_file_name_directory']}' in the measure paths '#{@measure_paths.join(', ')}'" unless measure[:measure_data][:local_path_to_measure]
|
183
183
|
|
184
184
|
a.workflow.add_measure_from_csv(measure)
|
185
185
|
end
|
@@ -226,7 +226,7 @@ module OpenStudio
|
|
226
226
|
end
|
227
227
|
|
228
228
|
# Assign required attributes
|
229
|
-
|
229
|
+
raise 'Require setting not found: version' unless config_hash[:version]
|
230
230
|
@version = config_hash[:version]
|
231
231
|
|
232
232
|
if config_hash[:analysis_name]
|
@@ -236,7 +236,7 @@ module OpenStudio
|
|
236
236
|
end
|
237
237
|
@analysis_name = @name.to_underscore
|
238
238
|
|
239
|
-
|
239
|
+
raise 'Require setting not found: measure_path' unless config_hash[:measure_paths]
|
240
240
|
config_hash[:measure_paths] = [config_hash[:measure_paths]] unless config_hash[:measure_paths].respond_to?(:each)
|
241
241
|
config_hash[:measure_paths].each do |path|
|
242
242
|
if (Pathname.new path).absolute?
|
@@ -246,7 +246,7 @@ module OpenStudio
|
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
249
|
-
|
249
|
+
raise 'Required setting not found: weather_paths' unless config_hash[:weather_paths]
|
250
250
|
config_hash[:weather_paths] = config_hash[:weather_paths].split(',')
|
251
251
|
config_hash[:weather_paths].each do |path|
|
252
252
|
if (Pathname.new path).absolute?
|
@@ -256,7 +256,7 @@ module OpenStudio
|
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
259
|
-
|
259
|
+
raise 'Required setting not found: models' unless config_hash[:models]
|
260
260
|
config_hash[:models] = [config_hash[:models]] unless config_hash[:models].respond_to?(:each)
|
261
261
|
config_hash[:models].each do |path|
|
262
262
|
model_name = File.basename(path).split('.')[0]
|
@@ -274,7 +274,7 @@ module OpenStudio
|
|
274
274
|
if File.exist? path
|
275
275
|
@outputs = MultiJson.load(File.read(path))
|
276
276
|
else
|
277
|
-
|
277
|
+
raise "Could not find output json: #{config_hash[:output_json]}"
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
@@ -295,10 +295,10 @@ module OpenStudio
|
|
295
295
|
end
|
296
296
|
|
297
297
|
if config_hash[:allow_multiple_jobs]
|
298
|
-
|
298
|
+
raise 'allow_multiple_jobs is no longer a valid option in the CSV, please delete and rerun'
|
299
299
|
end
|
300
300
|
if config_hash[:use_server_as_worker]
|
301
|
-
|
301
|
+
raise 'use_server_as_worker is no longer a valid option in the CSV, please delete and rerun'
|
302
302
|
end
|
303
303
|
|
304
304
|
# Assign AWS settings
|
@@ -323,7 +323,7 @@ module OpenStudio
|
|
323
323
|
col_ind = (0..(measure_rows[0].length - 1)).to_a.select { |i| measure_rows[0][i] == measure.to_s }
|
324
324
|
col_ind.each do |var_ind|
|
325
325
|
tuple = measure.to_s + measure_rows[1][var_ind]
|
326
|
-
|
326
|
+
raise "Multiple measure_variable tuples found for '#{measure}_#{measure_rows[1][var_ind]}'. These tuples must be unique." if measure_var_list.include? tuple
|
327
327
|
measure_var_list << tuple
|
328
328
|
measure_map[measure][measure_rows[1][var_ind].to_sym] = var_ind
|
329
329
|
end
|
@@ -333,19 +333,14 @@ module OpenStudio
|
|
333
333
|
data = []
|
334
334
|
measures.each_with_index do |measure, measure_index|
|
335
335
|
data[measure_index] = {}
|
336
|
-
measure_xml =
|
337
|
-
|
338
|
-
|
339
|
-
measure_xml = Nokogiri::XML File.read(File.join(@measure_paths[i], measure.to_s, 'measure.xml'))
|
340
|
-
break
|
341
|
-
end
|
342
|
-
end
|
343
|
-
fail "Could not find measure #{measure} xml in measure_paths: '#{@measure_paths.join("\n")}'" if measure_xml == ''
|
336
|
+
measure_xml, measure_type = find_measure(measure.to_s)
|
337
|
+
|
338
|
+
raise "Could not find measure #{measure} xml in measure_paths: '#{@measure_paths.join("\n")}'" unless measure_xml
|
344
339
|
measure_data = {}
|
345
340
|
measure_data[:classname] = measure_xml.xpath('/measure/class_name').text
|
346
341
|
measure_data[:name] = measure_xml.xpath('/measure/name').text
|
347
342
|
measure_data[:display_name] = measure_xml.xpath('/measure/display_name').text
|
348
|
-
measure_data[:measure_type] =
|
343
|
+
measure_data[:measure_type] = measure_type
|
349
344
|
measure_data[:uid] = measure_xml.xpath('/measure/uid').text
|
350
345
|
measure_data[:version_id] = measure_xml.xpath('/measure/version_id').text
|
351
346
|
data[measure_index][:measure_data] = measure_data
|
@@ -354,30 +349,41 @@ module OpenStudio
|
|
354
349
|
|
355
350
|
# construct the list of variables
|
356
351
|
vars.each do |var|
|
352
|
+
# var looks like [:cooling_adjustment, 0]
|
357
353
|
var = var[0]
|
358
|
-
next if var.to_s ==
|
354
|
+
next if var.to_s == 'None'
|
359
355
|
var_hash = {}
|
360
356
|
found_arg = nil
|
361
357
|
measure_xml.xpath('/measure/arguments/argument').each do |arg|
|
362
|
-
if arg.xpath('name').text == var.to_s
|
358
|
+
if var.to_s == '__SKIP__' || arg.xpath('name').text == var.to_s
|
363
359
|
found_arg = arg
|
364
360
|
break
|
365
361
|
end
|
366
362
|
end
|
367
363
|
|
368
364
|
# var_json = measure_json['arguments'].select { |hash| hash['local_variable'] == var.to_s }[0]
|
369
|
-
|
365
|
+
raise "measure.xml for measure #{measure} does not have an argument with argument == #{var}" unless found_arg
|
366
|
+
var_type = nil
|
367
|
+
var_units = ''
|
368
|
+
if var.to_s == '__SKIP__'
|
369
|
+
var_type = 'boolean'
|
370
|
+
var_units = ''
|
371
|
+
else
|
372
|
+
var_type = found_arg.xpath('type').text.downcase
|
373
|
+
var_units = found_arg.xpath('units')
|
374
|
+
end
|
375
|
+
|
370
376
|
var_hash[:name] = var.to_s
|
371
377
|
var_hash[:variable_type] = 'variable'
|
372
378
|
var_hash[:display_name] = measure_rows[2][measure_map[measure][var]]
|
373
379
|
var_hash[:display_name_short] = var_hash[:display_name]
|
374
380
|
# var_hash[:name] = var_json['local_variable']
|
375
|
-
var_hash[:type] =
|
376
|
-
var_hash[:units] =
|
381
|
+
var_hash[:type] = var_type
|
382
|
+
var_hash[:units] = var_units
|
377
383
|
var_hash[:distribution] = {}
|
378
384
|
case var_hash[:type].downcase
|
379
|
-
when 'bool', 'boolean'
|
380
|
-
var_hash[:distribution][:values] = (3..(measure_rows.length - 1)).map { |value| measure_rows[value.to_i][measure_map[measure][var]].to_s == 'true' }
|
385
|
+
when 'bool', 'boolean'
|
386
|
+
var_hash[:distribution][:values] = (3..(measure_rows.length - 1)).map { |value| measure_rows[value.to_i][measure_map[measure][var]].to_s.downcase == 'true' }
|
381
387
|
var_hash[:distribution][:maximum] = true
|
382
388
|
var_hash[:distribution][:minimum] = false
|
383
389
|
var_hash[:distribution][:mode] = var_hash[:distribution][:values].group_by { |i| i }.max { |x, y| x[1].length <=> y[1].length }[0]
|
@@ -423,6 +429,19 @@ module OpenStudio
|
|
423
429
|
|
424
430
|
private
|
425
431
|
|
432
|
+
# Find the measure in the measure path
|
433
|
+
def find_measure(measure_name)
|
434
|
+
@measure_paths.each do |mp|
|
435
|
+
measure_xml = File.join(mp, measure_name, 'measure.xml')
|
436
|
+
measure_rb = File.join(mp, measure_name, 'measure.rb')
|
437
|
+
if File.exist?(measure_xml) && File.exist?(measure_rb)
|
438
|
+
return Nokogiri::XML File.read(measure_xml), parse_measure_type(measure_rb)
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
return nil, nil
|
443
|
+
end
|
444
|
+
|
426
445
|
def parse_measure_type(measure_filename)
|
427
446
|
measure_string = File.read(measure_filename)
|
428
447
|
|
@@ -435,7 +454,7 @@ module OpenStudio
|
|
435
454
|
elsif measure_string =~ /OpenStudio::Ruleset::UtilityUserScript/
|
436
455
|
return 'UtilityUserScript'
|
437
456
|
else
|
438
|
-
|
457
|
+
raise "measure type is unknown with an inherited class in #{measure_filename}"
|
439
458
|
end
|
440
459
|
end
|
441
460
|
end
|
@@ -37,7 +37,7 @@ module OpenStudio
|
|
37
37
|
if File.exist?(@xls_filename)
|
38
38
|
@xls = Roo::Spreadsheet.open(@xls_filename)
|
39
39
|
else
|
40
|
-
|
40
|
+
raise "File #{@xls_filename} does not exist"
|
41
41
|
end
|
42
42
|
|
43
43
|
# Initialize some other instance variables
|
@@ -66,7 +66,7 @@ module OpenStudio
|
|
66
66
|
@setup = parse_setup
|
67
67
|
|
68
68
|
@version = Semantic::Version.new @version
|
69
|
-
|
69
|
+
raise "Spreadsheet version #{@version} is no longer supported. Please upgrade your spreadsheet to at least 0.1.9" if @version < '0.1.9'
|
70
70
|
|
71
71
|
@variables = parse_variables
|
72
72
|
|
@@ -94,34 +94,34 @@ module OpenStudio
|
|
94
94
|
def validate_analysis
|
95
95
|
# Setup the paths and do some error checking
|
96
96
|
@measure_paths.each do |mp|
|
97
|
-
|
97
|
+
raise "Measures directory '#{mp}' does not exist" unless Dir.exist?(mp)
|
98
98
|
end
|
99
99
|
|
100
100
|
@models.uniq!
|
101
|
-
|
101
|
+
raise 'No seed models defined in spreadsheet' if @models.empty?
|
102
102
|
|
103
103
|
@models.each do |model|
|
104
|
-
|
104
|
+
raise "Seed model does not exist: #{model[:path]}" unless File.exist?(model[:path])
|
105
105
|
end
|
106
106
|
|
107
107
|
@weather_files.uniq!
|
108
|
-
|
108
|
+
raise 'No weather files found based on what is in the spreadsheet' if @weather_files.empty?
|
109
109
|
|
110
110
|
@weather_files.each do |wf|
|
111
|
-
|
111
|
+
raise "Weather file does not exist: #{wf}" unless File.exist?(wf)
|
112
112
|
end
|
113
113
|
|
114
114
|
# This can be a directory as well
|
115
115
|
@other_files.each do |f|
|
116
|
-
|
116
|
+
raise "Other files do not exist for: #{f[:path]}" unless File.exist?(f[:path])
|
117
117
|
end
|
118
118
|
|
119
119
|
@worker_inits.each do |f|
|
120
|
-
|
120
|
+
raise "Worker initialization file does not exist for: #{f[:path]}" unless File.exist?(f[:path])
|
121
121
|
end
|
122
122
|
|
123
123
|
@worker_finals.each do |f|
|
124
|
-
|
124
|
+
raise "Worker finalization file does not exist for: #{f[:path]}" unless File.exist?(f[:path])
|
125
125
|
end
|
126
126
|
|
127
127
|
FileUtils.mkdir_p(@export_path)
|
@@ -131,7 +131,7 @@ module OpenStudio
|
|
131
131
|
measure_display_names = @variables['data'].map { |m| m['enabled'] ? m['display_name'] : nil }.compact
|
132
132
|
measure_display_names_mult = measure_display_names.select { |m| measure_display_names.count(m) > 1 }.uniq
|
133
133
|
if measure_display_names_mult && !measure_display_names_mult.empty?
|
134
|
-
|
134
|
+
raise "Measure Display Names are not unique for '#{measure_display_names_mult.join('\', \'')}'"
|
135
135
|
end
|
136
136
|
|
137
137
|
# verify that all continuous variables have all the data needed and create a name map
|
@@ -145,7 +145,7 @@ module OpenStudio
|
|
145
145
|
|
146
146
|
# make sure that variables have static values
|
147
147
|
if variable['distribution']['static_value'].nil? || variable['distribution']['static_value'] == ''
|
148
|
-
|
148
|
+
raise "Variable #{measure['name']}:#{variable['name']} needs a static value"
|
149
149
|
end
|
150
150
|
|
151
151
|
if variable['type'] == 'enum' || variable['type'] == 'Choice'
|
@@ -153,39 +153,39 @@ module OpenStudio
|
|
153
153
|
else # must be an integer or double
|
154
154
|
if variable['distribution']['type'] == 'discrete_uncertain'
|
155
155
|
if variable['distribution']['discrete_values'].nil? || variable['distribution']['discrete_values'] == ''
|
156
|
-
|
156
|
+
raise "Variable #{measure['name']}:#{variable['name']} needs discrete values"
|
157
157
|
end
|
158
158
|
elsif variable['distribution']['type'] == 'integer_sequence'
|
159
159
|
if variable['distribution']['mean'].nil? || variable['distribution']['mean'] == ''
|
160
|
-
|
160
|
+
raise "Variable #{measure['name']}:#{variable['name']} must have a mean/mode"
|
161
161
|
end
|
162
162
|
if variable['distribution']['min'].nil? || variable['distribution']['min'] == ''
|
163
|
-
|
163
|
+
raise "Variable #{measure['name']}:#{variable['name']} must have a minimum"
|
164
164
|
end
|
165
165
|
if variable['distribution']['max'].nil? || variable['distribution']['max'] == ''
|
166
|
-
|
167
|
-
end
|
166
|
+
raise "Variable #{measure['name']}:#{variable['name']} must have a maximum"
|
167
|
+
end
|
168
168
|
else
|
169
169
|
if variable['distribution']['mean'].nil? || variable['distribution']['mean'] == ''
|
170
|
-
|
170
|
+
raise "Variable #{measure['name']}:#{variable['name']} must have a mean"
|
171
171
|
end
|
172
172
|
if variable['distribution']['stddev'].nil? || variable['distribution']['stddev'] == ''
|
173
|
-
|
173
|
+
raise "Variable #{measure['name']}:#{variable['name']} must have a stddev"
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
177
|
if variable['distribution']['mean'].nil? || variable['distribution']['mean'] == ''
|
178
|
-
|
178
|
+
raise "Variable #{measure['name']}:#{variable['name']} must have a mean/mode"
|
179
179
|
end
|
180
180
|
if variable['distribution']['min'].nil? || variable['distribution']['min'] == ''
|
181
|
-
|
181
|
+
raise "Variable #{measure['name']}:#{variable['name']} must have a minimum"
|
182
182
|
end
|
183
183
|
if variable['distribution']['max'].nil? || variable['distribution']['max'] == ''
|
184
|
-
|
184
|
+
raise "Variable #{measure['name']}:#{variable['name']} must have a maximum"
|
185
185
|
end
|
186
186
|
unless variable['type'] == 'string' || variable['type'] =~ /bool/
|
187
187
|
if variable['distribution']['min'] > variable['distribution']['max']
|
188
|
-
|
188
|
+
raise "Variable min is greater than variable max for #{measure['name']}:#{variable['name']}"
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
@@ -197,7 +197,7 @@ module OpenStudio
|
|
197
197
|
|
198
198
|
dupes = variable_names.select { |e| variable_names.count(e) > 1 }.uniq
|
199
199
|
if dupes.count > 0
|
200
|
-
|
200
|
+
raise "duplicate variable names found in list #{dupes.inspect}"
|
201
201
|
end
|
202
202
|
|
203
203
|
# most of the checks will raise a runtime exception, so this true will never be called
|
@@ -210,8 +210,8 @@ module OpenStudio
|
|
210
210
|
# @append_model_name [Boolean] Append the name of the seed model to the display name
|
211
211
|
# @return [Object] An OpenStudio::Analysis
|
212
212
|
def analysis(seed_model = nil, append_model_name = false)
|
213
|
-
|
214
|
-
|
213
|
+
raise 'There are no seed models defined in the excel file. Please add one.' if @models.size == 0
|
214
|
+
raise "There are more than one seed models defined in the excel file. Call 'analyses' to return the array" if @models.size > 1 && seed_model.nil?
|
215
215
|
|
216
216
|
seed_model = @models.first if seed_model.nil?
|
217
217
|
|
@@ -231,12 +231,12 @@ module OpenStudio
|
|
231
231
|
measure['local_path_to_measure'] = "#{measure_dir_to_add}/measure.rb"
|
232
232
|
break
|
233
233
|
else
|
234
|
-
|
234
|
+
raise "Measure in directory '#{measure_dir_to_add}' did not contain a measure.rb file"
|
235
235
|
end
|
236
236
|
end
|
237
237
|
end
|
238
238
|
|
239
|
-
|
239
|
+
raise "Could not find measure '#{measure['name']}' in directory named '#{measure['measure_file_name_directory']}' in the measure paths '#{@measure_paths.join(', ')}'" unless measure['local_path_to_measure']
|
240
240
|
|
241
241
|
a.workflow.add_measure_from_excel(measure)
|
242
242
|
end
|
@@ -426,7 +426,7 @@ module OpenStudio
|
|
426
426
|
|
427
427
|
if b_settings
|
428
428
|
@version = row[1].chomp if row[0] == 'Spreadsheet Version'
|
429
|
-
@settings[
|
429
|
+
@settings[(row[0].to_underscore).to_s] = row[1] if row[0]
|
430
430
|
if @settings['cluster_name']
|
431
431
|
@settings['cluster_name'] = @settings['cluster_name'].to_underscore
|
432
432
|
end
|
@@ -463,27 +463,27 @@ module OpenStudio
|
|
463
463
|
@measure_paths << File.expand_path(File.join(@root_path, tmp_filepath))
|
464
464
|
end
|
465
465
|
end
|
466
|
-
@run_setup[
|
466
|
+
@run_setup[(row[0].to_underscore).to_s] = row[1] if row[0]
|
467
467
|
|
468
468
|
# type cast
|
469
469
|
if @run_setup['allow_multiple_jobs']
|
470
|
-
|
470
|
+
raise 'allow_multiple_jobs is no longer a valid option in the Excel file, please delete the row and rerun'
|
471
471
|
end
|
472
472
|
if @run_setup['use_server_as_worker']
|
473
|
-
|
473
|
+
raise 'use_server_as_worker is no longer a valid option in the Excel file, please delete the row and rerun'
|
474
474
|
end
|
475
475
|
elsif b_problem_setup
|
476
476
|
if row[0]
|
477
477
|
v = row[1]
|
478
478
|
v.to_i if v % 1 == 0
|
479
|
-
@problem[
|
479
|
+
@problem[(row[0].to_underscore).to_s] = v
|
480
480
|
end
|
481
481
|
|
482
482
|
elsif b_algorithm_setup
|
483
483
|
if row[0] && !row[0].empty?
|
484
484
|
v = row[1]
|
485
485
|
v = v.to_i if v % 1 == 0
|
486
|
-
@algorithm[
|
486
|
+
@algorithm[(row[0].to_underscore).to_s] = v
|
487
487
|
end
|
488
488
|
elsif b_weather_files
|
489
489
|
if row[0] == 'Weather File'
|
@@ -575,7 +575,7 @@ module OpenStudio
|
|
575
575
|
notes: /notes/i,
|
576
576
|
relation_to_eui: /typical\svar\sto\seui\srelationship/i,
|
577
577
|
clean: true)
|
578
|
-
elsif @version >= '0.3.0'.to_version
|
578
|
+
elsif @version >= '0.3.0'.to_version
|
579
579
|
rows = @xls.sheet('Variables').parse(enabled: /# variable/i,
|
580
580
|
measure_name_or_var_type: /type/i,
|
581
581
|
measure_file_name_or_var_display_name: /parameter\sdisplay\sname.*/i,
|
@@ -692,7 +692,7 @@ module OpenStudio
|
|
692
692
|
raise "Unable to parse spreadsheet #{@xls_filename} with version #{@version} due to error: #{e.message}"
|
693
693
|
end
|
694
694
|
|
695
|
-
|
695
|
+
raise "Could not find the sheet name 'Variables' in excel file #{@root_path}" unless rows
|
696
696
|
|
697
697
|
# map the data to another hash that is more easily processed
|
698
698
|
data = {}
|
@@ -841,11 +841,11 @@ module OpenStudio
|
|
841
841
|
objective_function_target: /objective\sfunction\starget/i,
|
842
842
|
scaling_factor: /scale/i,
|
843
843
|
objective_function_group: /objective/i)
|
844
|
-
|
844
|
+
|
845
845
|
end
|
846
846
|
|
847
847
|
unless rows
|
848
|
-
|
848
|
+
raise "Could not find the sheet name 'Outputs' in excel file #{@root_path}"
|
849
849
|
end
|
850
850
|
|
851
851
|
data = {}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module OpenStudio
|
2
2
|
module Analysis
|
3
3
|
module Translator
|
4
|
-
|
5
4
|
class Workflow
|
6
5
|
attr_reader :osa_filename
|
7
6
|
attr_reader :root_path
|
@@ -24,7 +23,7 @@ module OpenStudio
|
|
24
23
|
if File.exist?(@osa_filename)
|
25
24
|
@osa = ::JSON.parse(File.read(@osa_filename), symbolize_names: true)[:analysis]
|
26
25
|
else
|
27
|
-
|
26
|
+
raise "File #{@osa_filename} does not exist"
|
28
27
|
end
|
29
28
|
|
30
29
|
# Initialize some other instance variables
|
@@ -68,11 +67,11 @@ module OpenStudio
|
|
68
67
|
# warn('data_point selector in ods will be changed to datapoint in version 1.0') # NL this isn't true anymore.
|
69
68
|
osd = ::JSON.parse(File.read(osd_filename), symbolize_names: true)[:data_point]
|
70
69
|
else
|
71
|
-
|
70
|
+
raise "File #{osd_filename} does not exist"
|
72
71
|
end
|
73
72
|
|
74
73
|
# Parse the osd hash based off of the osa hash. First check that the analysis id matches
|
75
|
-
|
74
|
+
raise "File #{osd_filename} does not reference #{@osa_id}." unless @osa_id == osd[:analysis_id]
|
76
75
|
# @todo (rhorsey) Fix the spec so this line can be uncommented
|
77
76
|
osw_steps_instance = @steps
|
78
77
|
osw_steps_instance.each_with_index do |step, i|
|
@@ -4,7 +4,7 @@ module OpenStudio
|
|
4
4
|
class Workflow
|
5
5
|
attr_reader :items
|
6
6
|
# allow users to access the items via the measures attribute accessor
|
7
|
-
|
7
|
+
alias measures items
|
8
8
|
|
9
9
|
# Create an instance of the OpenStudio::Analysis::Workflow
|
10
10
|
#
|
@@ -46,12 +46,12 @@ module OpenStudio
|
|
46
46
|
if measure_hash.nil? && File.exist?(File.join(local_path_to_measure, 'measure.json'))
|
47
47
|
measure_hash = JSON.parse(File.read(File.join(local_path_to_measure, 'measure.json')), symbolize_names: true)
|
48
48
|
elsif measure_hash.nil?
|
49
|
-
|
49
|
+
raise 'measure.json was not found and was not automatically created'
|
50
50
|
end
|
51
51
|
|
52
52
|
add_measure(instance_name, instance_display_name, local_path_to_measure, measure_hash)
|
53
53
|
else
|
54
|
-
|
54
|
+
raise "could not find measure to add to workflow #{local_path_to_measure}"
|
55
55
|
end
|
56
56
|
|
57
57
|
@items.last
|
@@ -186,7 +186,7 @@ module OpenStudio
|
|
186
186
|
def find_measure(instance_name)
|
187
187
|
@items.find { |i| i.name == instance_name }
|
188
188
|
end
|
189
|
-
|
189
|
+
alias find_workflow_step find_measure
|
190
190
|
|
191
191
|
# Return all the variables in the analysis as an array. The list that is returned is read only.
|
192
192
|
#
|
@@ -209,7 +209,7 @@ module OpenStudio
|
|
209
209
|
|
210
210
|
h = arr
|
211
211
|
else
|
212
|
-
|
212
|
+
raise "Version #{version} not yet implemented for to_hash"
|
213
213
|
end
|
214
214
|
|
215
215
|
h
|
@@ -222,7 +222,7 @@ module OpenStudio
|
|
222
222
|
if version == 1
|
223
223
|
JSON.pretty_generate(to_hash(version))
|
224
224
|
else
|
225
|
-
|
225
|
+
raise "Version #{version} not yet implemented for to_json"
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -254,7 +254,7 @@ module OpenStudio
|
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
-
|
257
|
+
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
|
258
258
|
|
259
259
|
o.add_measure_from_analysis_hash(wf[:name], wf[:display_name], local_measure_dir, wf)
|
260
260
|
end
|
@@ -272,7 +272,7 @@ module OpenStudio
|
|
272
272
|
j = JSON.parse(File.read(filename), symbolize_names: true)
|
273
273
|
o = OpenStudio::Analysis::Workflow.load(j)
|
274
274
|
else
|
275
|
-
|
275
|
+
raise "Could not find workflow file #{filename}"
|
276
276
|
end
|
277
277
|
|
278
278
|
o
|