openstudio-analysis 1.0.0 → 1.0.5
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 +5 -5
- data/.gitignore +2 -1
- data/.rubocop.yml +1 -1
- data/.travis.yml +2 -2
- data/CHANGELOG.md +28 -1
- data/Gemfile +1 -5
- data/LICENSE.md +28 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/openstudio-analysis.rb +2 -1
- data/lib/openstudio/analysis.rb +23 -27
- data/lib/openstudio/analysis/algorithm_attributes.rb +1 -1
- data/lib/openstudio/analysis/formulation.rb +1 -1
- data/lib/openstudio/analysis/server_api.rb +8 -14
- 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 +2 -2
- data/lib/openstudio/analysis/translator/workflow.rb +9 -13
- data/lib/openstudio/analysis/version.rb +2 -2
- data/lib/openstudio/analysis/workflow.rb +9 -18
- data/lib/openstudio/analysis/workflow_step.rb +67 -78
- data/lib/openstudio/helpers/hash.rb +1 -1
- data/lib/openstudio/helpers/string.rb +1 -1
- data/{spec/openstudio/support_files_spec.rb → lib/openstudio/helpers/utils.rb} +26 -48
- data/lib/openstudio/weather/epw.rb +2 -2
- data/openstudio-analysis.gemspec +18 -16
- data/update_license.rb +5 -4
- metadata +48 -200
- data/LGPL-2.1.txt +0 -502
- data/LICENSE.txt +0 -65
- data/spec/files/0_1_09_no_variables.xlsx +0 -0
- data/spec/files/0_1_09_outputvars.xlsx +0 -0
- data/spec/files/0_1_09_setup_version_2.xlsx +0 -0
- data/spec/files/0_1_09_small_list.xlsx +0 -0
- data/spec/files/0_1_09_small_list_incomplete.xlsx +0 -0
- data/spec/files/0_1_09_small_list_repeat_vars.xlsx +0 -0
- data/spec/files/0_1_09_small_list_validation_errors.xlsx +0 -0
- data/spec/files/0_1_10_proxy.xlsx +0 -0
- data/spec/files/0_1_10_proxy_user.xlsx +0 -0
- data/spec/files/0_1_10_template_input.xlsx +0 -0
- data/spec/files/0_1_11_discrete_variables.xlsx +0 -0
- data/spec/files/0_1_12_discrete_dynamic_columns.xlsx +0 -0
- data/spec/files/0_2_0_template.xlsx +0 -0
- data/spec/files/0_2_0_template_simpletest.xlsx +0 -0
- data/spec/files/0_3_0_dynamic_uuids.xlsx +0 -0
- data/spec/files/0_3_0_measure_existence.xlsx +0 -0
- data/spec/files/0_3_0_outputs.xlsx +0 -0
- data/spec/files/0_3_3_short_names.xlsx +0 -0
- data/spec/files/0_3_5_multiple_measure_paths.xlsx +0 -0
- data/spec/files/0_3_7_unique_measure_names.xlsx +0 -0
- data/spec/files/0_3_7_worker_init_final.xlsx +0 -0
- data/spec/files/0_4_0_lhs_discrete_continuous.xlsx +0 -0
- data/spec/files/0_4_0_multiple_seeds.xlsx +0 -0
- data/spec/files/0_4_0_pivot_test.xlsx +0 -0
- data/spec/files/analysis/examples/discrete_lhs_example.json +0 -809
- data/spec/files/analysis/examples/medium_office_example.json +0 -1674
- data/spec/files/analysis/examples/medium_office_workflow.json +0 -1298
- data/spec/files/measures/ActualMeasureNoJson/measure.rb +0 -80
- data/spec/files/measures/ActualMeasureNoJson/measure.xml +0 -2
- data/spec/files/measures/ExampleMeasure/measure.json +0 -3
- data/spec/files/measures/ExampleMeasure/measure.rb +0 -5
- data/spec/files/measures/ExampleMeasure/measure.xml +0 -1
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json +0 -36
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb +0 -22
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml +0 -5
- data/spec/files/measures/NoMeasureRbFile/.gitkeep +0 -0
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.json +0 -3
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.rb +0 -5
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.xml +0 -1
- data/spec/files/measures/SetThermostatSchedules/measure.json +0 -63
- data/spec/files/measures/SetThermostatSchedules/measure.rb +0 -254
- data/spec/files/measures/SetThermostatSchedules/measure.xml +0 -2
- data/spec/files/measures/example_measure_auto_directory_name/measure.json +0 -3
- data/spec/files/measures/example_measure_auto_directory_name/measure.rb +0 -5
- data/spec/files/measures/example_measure_auto_directory_name/measure.xml +0 -1
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.json +0 -3
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.rb +0 -5
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.xml +0 -1
- data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.rb +0 -5
- data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.xml +0 -1
- data/spec/files/measures/rotate_building/measure.rb +0 -5
- data/spec/files/measures/rotate_building/measure.xml +0 -1
- data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.rb +0 -5
- data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.xml +0 -1
- data/spec/files/measures_second_path/measure_in_another_dir/measure.json +0 -3
- data/spec/files/measures_second_path/measure_in_another_dir/measure.rb +0 -5
- data/spec/files/measures_second_path/measure_in_another_dir/measure.xml +0 -1
- data/spec/files/partial_weather.epw +0 -32
- data/spec/files/partial_weather_2.epw +0 -32
- data/spec/files/small_seed.osm +0 -4622
- data/spec/files/worker_init/first_file.rb +0 -15
- data/spec/files/worker_init/second_file.sh +0 -4
- data/spec/files/workflow/analysis.osa +0 -1334
- data/spec/files/workflow/datapoint_0.osd +0 -65
- data/spec/files/workflow/datapoint_1.osd +0 -65
- data/spec/files/workflow/datapoint_2.osd +0 -65
- data/spec/files/workflow/datapoint_wrong_osa_id.osd +0 -65
- data/spec/integration/server_api_spec.rb +0 -83
- data/spec/openstudio/excel_spec.rb +0 -606
- data/spec/openstudio/formulation_spec.rb +0 -200
- data/spec/openstudio/hash_spec.rb +0 -56
- data/spec/openstudio/osw_spec.rb +0 -129
- data/spec/openstudio/server_api_spec.rb +0 -68
- data/spec/openstudio/string_spec.rb +0 -34
- data/spec/openstudio/weather_spec.rb +0 -80
- data/spec/openstudio/workflow_spec.rb +0 -126
- data/spec/openstudio/workflow_step_spec.rb +0 -158
- data/spec/schema/osa.json +0 -613
- data/spec/schema/osa.png +0 -0
- data/spec/schema/osd.json +0 -110
- data/spec/schema/osd.png +0 -0
- data/spec/spec_helper.rb +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# *******************************************************************************
|
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, 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,6 @@
|
|
|
35
35
|
|
|
36
36
|
module OpenStudio
|
|
37
37
|
module Analysis
|
|
38
|
-
VERSION = '1.0.
|
|
38
|
+
VERSION = '1.0.5'.freeze
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# *******************************************************************************
|
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, 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)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# *******************************************************************************
|
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, 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
|
|
@@ -312,40 +309,36 @@ module OpenStudio
|
|
|
312
309
|
# do not allow the choice variable_type
|
|
313
310
|
|
|
314
311
|
s.type = hash[:measure_type] # this is actually the measure type
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
var_type = arg[:variable_type] ? arg[:variable_type].downcase : arg[:value_type]
|
|
319
|
-
|
|
320
|
-
if var_type == 'choice'
|
|
321
|
-
# WARN the user that the measure had a "choice data type"
|
|
322
|
-
var_type = 'string'
|
|
323
|
-
end
|
|
312
|
+
hash[:arguments]&.each do |arg|
|
|
313
|
+
# warn the user to we need to deprecate variable_type and use value_type (which is what os server uses)
|
|
314
|
+
var_type = arg[:variable_type] ? arg[:variable_type].downcase : arg[:value_type]
|
|
324
315
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
name: arg[:name],
|
|
329
|
-
value_type: var_type,
|
|
330
|
-
default_value: arg[:default_value],
|
|
331
|
-
value: arg[:default_value]
|
|
332
|
-
}
|
|
316
|
+
if var_type == 'choice'
|
|
317
|
+
# WARN the user that the measure had a "choice data type"
|
|
318
|
+
var_type = 'string'
|
|
333
319
|
end
|
|
320
|
+
|
|
321
|
+
s.arguments << {
|
|
322
|
+
display_name: arg[:display_name],
|
|
323
|
+
display_name_short: arg[:display_name_short],
|
|
324
|
+
name: arg[:name],
|
|
325
|
+
value_type: var_type,
|
|
326
|
+
default_value: arg[:default_value],
|
|
327
|
+
value: arg[:default_value]
|
|
328
|
+
}
|
|
334
329
|
end
|
|
335
330
|
|
|
336
331
|
# Load the arguments of variables, but do not make them variables. This format is more about arugments, than variables
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
end
|
|
332
|
+
hash[:variables]&.each do |variable|
|
|
333
|
+
# add the arguments first
|
|
334
|
+
s.arguments << {
|
|
335
|
+
display_name: variable[:argument][:display_name],
|
|
336
|
+
display_name_short: variable[:argument][:display_name_short],
|
|
337
|
+
name: variable[:argument][:name],
|
|
338
|
+
value_type: variable[:argument][:value_type],
|
|
339
|
+
default_value: variable[:argument][:default_value],
|
|
340
|
+
value: variable[:argument][:default_value]
|
|
341
|
+
}
|
|
349
342
|
end
|
|
350
343
|
|
|
351
344
|
s
|
|
@@ -356,7 +349,7 @@ module OpenStudio
|
|
|
356
349
|
# @param instance_name [String] Machine name of the instance
|
|
357
350
|
# @param instance_display_name [String] Display name of the instance
|
|
358
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.
|
|
359
|
-
# @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)
|
|
360
353
|
# @param options [Hash] Optional arguments
|
|
361
354
|
# @option options [Boolean] :ignore_not_found Do not raise an exception if the measure could not be found on the machine
|
|
362
355
|
# @return [Object] Returns the OpenStudio::Analysis::WorkflowStep
|
|
@@ -398,51 +391,47 @@ module OpenStudio
|
|
|
398
391
|
s.measure_definition_version_uuid = hash[:measure_definition_version_uuid]
|
|
399
392
|
|
|
400
393
|
s.type = hash[:measure_type] # this is actually the measure type
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
var_type = arg[:value_type]
|
|
405
|
-
|
|
406
|
-
if var_type == 'choice'
|
|
407
|
-
# WARN the user that the measure had a "choice data type"
|
|
408
|
-
var_type = 'string'
|
|
409
|
-
end
|
|
394
|
+
hash[:arguments]&.each do |arg|
|
|
395
|
+
# warn the user to we need to deprecate variable_type and use value_type (which is what os server uses)
|
|
396
|
+
var_type = arg[:value_type]
|
|
410
397
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
name: arg[:name],
|
|
415
|
-
value_type: var_type,
|
|
416
|
-
default_value: arg[:default_value],
|
|
417
|
-
value: arg[:value]
|
|
418
|
-
}
|
|
398
|
+
if var_type == 'choice'
|
|
399
|
+
# WARN the user that the measure had a "choice data type"
|
|
400
|
+
var_type = 'string'
|
|
419
401
|
end
|
|
402
|
+
|
|
403
|
+
s.arguments << {
|
|
404
|
+
display_name: arg[:display_name],
|
|
405
|
+
display_name_short: arg[:display_name_short],
|
|
406
|
+
name: arg[:name],
|
|
407
|
+
value_type: var_type,
|
|
408
|
+
default_value: arg[:default_value],
|
|
409
|
+
value: arg[:value]
|
|
410
|
+
}
|
|
420
411
|
end
|
|
421
412
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
s.make_variable(variable[:argument][:name], variable[:display_name], distribution, var_options)
|
|
445
|
-
end
|
|
413
|
+
hash[:variables]&.each do |variable|
|
|
414
|
+
# add the arguments first
|
|
415
|
+
s.arguments << {
|
|
416
|
+
display_name: variable[:argument][:display_name],
|
|
417
|
+
display_name_short: variable[:argument][:display_name_short],
|
|
418
|
+
name: variable[:argument][:name],
|
|
419
|
+
value_type: variable[:argument][:value_type],
|
|
420
|
+
default_value: variable[:argument][:default_value],
|
|
421
|
+
value: variable[:argument][:default_value]
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
var_options = {}
|
|
425
|
+
var_options[:variable_type] = variable[:variable_type]
|
|
426
|
+
var_options[:variable_display_name_short] = variable[:display_name_short]
|
|
427
|
+
var_options[:static_value] = variable[:static_value]
|
|
428
|
+
distribution = variable[:uncertainty_description]
|
|
429
|
+
distribution[:minimum] = variable[:minimum]
|
|
430
|
+
distribution[:mean] = distribution[:attributes].find { |a| a[:name] == 'modes' }[:value]
|
|
431
|
+
distribution[:maximum] = variable[:maximum]
|
|
432
|
+
distribution[:standard_deviation] = distribution[:attributes].find { |a| a[:name] == 'stddev' }[:value]
|
|
433
|
+
distribution[:step_size] = distribution[:attributes].find { |a| a[:name] == 'delta_x' }[:value]
|
|
434
|
+
s.make_variable(variable[:argument][:name], variable[:display_name], distribution, var_options)
|
|
446
435
|
end
|
|
447
436
|
|
|
448
437
|
s
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# *******************************************************************************
|
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, 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-2020, 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-2020, 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:
|
|
@@ -33,57 +33,35 @@
|
|
|
33
33
|
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
34
|
# *******************************************************************************
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
require 'rexml/document'
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'should add files' do
|
|
45
|
-
f = 'spec/files/worker_init/first_file.rb'
|
|
46
|
-
@s.add(f)
|
|
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
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
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] = []
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
@s.add('spec/files/worker_init/second_file.sh')
|
|
55
|
+
REXML::XPath.each(xml_root, '//measure/arguments/argument' ) do |arg|
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
measure_hash[:arguments] << {
|
|
58
|
+
name: arg.elements['name'].text,
|
|
59
|
+
display_name: arg.elements['display_name'].text,
|
|
60
|
+
variable_type: arg.elements['type'].text.downcase,
|
|
61
|
+
default_value: arg.elements['default_value'].text,
|
|
62
|
+
units: arg.elements['units'] ? arg.elements['units'].text : ''
|
|
63
|
+
}
|
|
58
64
|
end
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
f = 'spec/files/worker_init/second_file.sh'
|
|
62
|
-
@s.add(f)
|
|
63
|
-
|
|
64
|
-
@s.clear
|
|
65
|
-
expect(@s.size).to eq 0
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it 'should only add existing files' do
|
|
69
|
-
f = 'spec/files/worker_init/second_file.sh'
|
|
70
|
-
@s.add(f)
|
|
71
|
-
@s.add(f)
|
|
72
|
-
|
|
73
|
-
expect(@s.size).to eq 1
|
|
74
|
-
|
|
75
|
-
f = 'non-existent.rb'
|
|
76
|
-
expect { @s.add(f) }.to raise_error /Path or file does not exist and cannot be added.*/
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it 'should add metadata data' do
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it 'should add a directory' do
|
|
83
|
-
@s.clear
|
|
84
|
-
@s.add_files('spec/files/measures/**/*.rb', d: 'new')
|
|
85
|
-
|
|
86
|
-
expect(@s.size).to eq 10
|
|
87
|
-
expect(@s[0][:metadata][:d]).to eq 'new'
|
|
88
|
-
end
|
|
66
|
+
measure_hash
|
|
89
67
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# *******************************************************************************
|
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, 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:
|
|
@@ -154,7 +154,7 @@ module OpenStudio
|
|
|
154
154
|
header_section = true
|
|
155
155
|
row_count = 0
|
|
156
156
|
|
|
157
|
-
CSV.foreach(@filename
|
|
157
|
+
CSV.foreach(@filename) do |row|
|
|
158
158
|
row_count += 1
|
|
159
159
|
|
|
160
160
|
if header_section
|
data/openstudio-analysis.gemspec
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
lib = File.expand_path('lib', __dir__)
|
|
2
|
-
$LOAD_PATH.unshift
|
|
3
|
-
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'openstudio/analysis/version'
|
|
5
4
|
|
|
6
5
|
Gem::Specification.new do |s|
|
|
@@ -9,27 +8,30 @@ Gem::Specification.new do |s|
|
|
|
9
8
|
s.platform = Gem::Platform::RUBY
|
|
10
9
|
s.authors = ['Nicholas Long']
|
|
11
10
|
s.email = ['Nicholas.Long@nrel.gov']
|
|
11
|
+
|
|
12
12
|
s.homepage = 'http://openstudio.nrel.gov'
|
|
13
13
|
s.summary = 'Create JSON, ZIP to communicate with OpenStudio Distributed Analysis in the Cloud'
|
|
14
14
|
s.description = 'Basic classes for generating the files needed for OpenStudio-Server'
|
|
15
|
-
s.license = '
|
|
15
|
+
s.license = 'BSD'
|
|
16
16
|
|
|
17
|
-
s.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
s.
|
|
21
|
-
s.executables
|
|
22
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
17
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
s.bindir = 'exe'
|
|
21
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
22
|
s.require_paths = ['lib']
|
|
24
23
|
|
|
25
|
-
s.
|
|
24
|
+
s.required_ruby_version = '~> 2.5.0'
|
|
25
|
+
|
|
26
|
+
s.add_dependency 'bcl', '~> 0.6.1'
|
|
26
27
|
s.add_dependency 'dencity', '~> 0.1.0'
|
|
27
|
-
s.add_dependency 'faraday', '~> 0.
|
|
28
|
-
s.add_dependency '
|
|
29
|
-
s.add_dependency '
|
|
30
|
-
s.add_dependency 'rubyzip', '~> 1.2'
|
|
28
|
+
s.add_dependency 'faraday', '~> 1.0.1'
|
|
29
|
+
s.add_dependency 'roo', '~> 2.8.3'
|
|
30
|
+
s.add_dependency 'rubyzip', '~> 2.3.0'
|
|
31
31
|
s.add_dependency 'semantic', '~> 1.4'
|
|
32
32
|
|
|
33
|
-
s.add_development_dependency '
|
|
34
|
-
s.add_development_dependency '
|
|
33
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
|
34
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
|
35
|
+
s.add_development_dependency 'rubocop', '~> 0.54.0'
|
|
36
|
+
s.add_development_dependency 'rubocop-checkstyle_formatter', '~> 0.4.0'
|
|
35
37
|
end
|
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-2020, 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-2020, 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-2020, 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
|
|
@@ -96,7 +96,8 @@ paths = [
|
|
|
96
96
|
{ glob: 'spec/integration/**/*.rb', license: ruby_header_text, regex: ruby_regex },
|
|
97
97
|
|
|
98
98
|
# single files
|
|
99
|
-
{ glob: 'Rakefile', license: ruby_header_text, regex: ruby_regex }
|
|
99
|
+
{ glob: 'Rakefile', license: ruby_header_text, regex: ruby_regex },
|
|
100
|
+
{ glob: 'spec/spec_helper.rb', license: ruby_header_text, regex: ruby_regex }
|
|
100
101
|
]
|
|
101
102
|
|
|
102
103
|
paths.each do |path|
|