openstudio-analysis 0.4.1 → 0.4.2

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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/openstudio/analysis/algorithm_attributes.rb +1 -1
  4. data/lib/openstudio/analysis/formulation.rb +181 -31
  5. data/lib/openstudio/analysis/server_api.rb +2 -2
  6. data/lib/openstudio/analysis/support_files.rb +76 -0
  7. data/lib/openstudio/analysis/version.rb +1 -1
  8. data/lib/openstudio/analysis/workflow.rb +4 -0
  9. data/lib/openstudio/analysis/workflow_step.rb +3 -3
  10. data/lib/openstudio-analysis.rb +1 -0
  11. data/spec/files/analysis/medium_office.json +88 -88
  12. data/spec/files/analysis/medium_office.zip +0 -0
  13. data/spec/files/export/analysis/0_1_09_outputvars.json +38 -38
  14. data/spec/files/export/analysis/0_1_09_outputvars.zip +0 -0
  15. data/spec/files/export/analysis/0_1_11_discrete_variables.json +40 -40
  16. data/spec/files/export/analysis/0_1_11_discrete_variables.zip +0 -0
  17. data/spec/files/export/analysis/0_1_12_discrete_dynamic_columns.json +8 -8
  18. data/spec/files/export/analysis/0_1_12_discrete_dynamic_columns.zip +0 -0
  19. data/spec/files/export/analysis/0_2_0_template_simpletest.json +12 -12
  20. data/spec/files/export/analysis/0_2_0_template_simpletest.zip +0 -0
  21. data/spec/files/export/analysis/0_3_0_outputs.json +6 -6
  22. data/spec/files/export/analysis/0_3_0_outputs.zip +0 -0
  23. data/spec/files/export/analysis/{d1e0168f-97c4-4f25-9ac2-8daf34769494.json → 1d8d62bb-f058-4c38-893b-8eaa7ceea254.json} +10 -10
  24. data/spec/files/export/analysis/{d1e0168f-97c4-4f25-9ac2-8daf34769494.zip → 1d8d62bb-f058-4c38-893b-8eaa7ceea254.zip} +0 -0
  25. data/spec/files/export/analysis/{0754ec1c-39d7-45e7-a8a5-5e5847a757fb.json → 5b5264db-a31e-4bab-931b-94101bd23b80.json} +14 -14
  26. data/spec/files/export/analysis/{10e6ec76-f2e8-43bd-b5a0-26a311173576.zip → 5b5264db-a31e-4bab-931b-94101bd23b80.zip} +0 -0
  27. data/spec/files/export/analysis/{10e6ec76-f2e8-43bd-b5a0-26a311173576.json → 67e3ba4a-2660-41b6-a7c5-d4457a4275c4.json} +14 -14
  28. data/spec/files/export/analysis/{0754ec1c-39d7-45e7-a8a5-5e5847a757fb.zip → 67e3ba4a-2660-41b6-a7c5-d4457a4275c4.zip} +0 -0
  29. data/spec/files/export/analysis/{4d9244ef-58b6-43c4-87bc-625e6d7365df.json → 71bebb0a-34b7-404b-b430-0ee7dab962ff.json} +6 -6
  30. data/spec/files/export/analysis/{4d9244ef-58b6-43c4-87bc-625e6d7365df.zip → 71bebb0a-34b7-404b-b430-0ee7dab962ff.zip} +0 -0
  31. data/spec/files/export/analysis/discrete_lhs_example.json +60 -60
  32. data/spec/files/export/analysis/discrete_lhs_example.zip +0 -0
  33. data/spec/files/export/analysis/small_seed.json +38 -38
  34. data/spec/files/export/analysis/small_seed.zip +0 -0
  35. data/spec/openstudio/support_files_spec.rb +44 -0
  36. data/spec/reports/SPEC-OpenStudio-Analysis-Formulation.xml +8 -8
  37. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi-create-a-new-object-instance.xml +2 -2
  38. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi-test-not-localhost.xml +2 -2
  39. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi.xml +1 -1
  40. data/spec/reports/SPEC-OpenStudio-Analysis-SupportFiles.xml +15 -0
  41. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-discrete-variables.xml +3 -3
  42. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-discrete-with-dynamic-columns.xml +3 -3
  43. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-no-variables-defined.xml +6 -6
  44. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-proxy-setup-with-user.xml +2 -2
  45. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-proxy-setup.xml +2 -2
  46. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-setup-output-variables.xml +8 -8
  47. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-setup-version-0-1-9.xml +5 -5
  48. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-incomplete-variables.xml +2 -2
  49. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-variables-should-not-validate.xml +2 -2
  50. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-variables.xml +5 -5
  51. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-with-with-repeated-variable-names.xml +2 -2
  52. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-1-10.xml +3 -3
  53. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-2-0-simple.xml +5 -5
  54. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-2-0.xml +5 -5
  55. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-0-dynamic-uuid-assignments.xml +4 -4
  56. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-0-measure-existence-checks.xml +3 -3
  57. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-0-objective-functions.xml +5 -5
  58. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-3-and-short-display-names.xml +4 -4
  59. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-5-and-measure-paths.xml +4 -4
  60. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-7-and-worker-init-final-scripts.0.xml +2 -2
  61. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-3-7-and-worker-init-final-scripts.xml +4 -4
  62. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel.xml +1 -1
  63. data/spec/reports/SPEC-OpenStudio-Analysis-Workflow.xml +7 -7
  64. data/spec/reports/SPEC-OpenStudio-Analysis-WorkflowStep.xml +8 -8
  65. metadata +23 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a0b39d0cdc6f14fcccb994266696c90c554339a
4
- data.tar.gz: 481952ae7dbcdfa049acd520cf8c45fc4f5e2f61
3
+ metadata.gz: 40fd5c10c4ff7f0c700a21e8863f9289810c529e
4
+ data.tar.gz: 9a923d85c9f7bac6f9a90f904b9ab81295c59460
5
5
  SHA512:
6
- metadata.gz: 7e9c40f95f3ec9d0983fa13b5ca6fa87afe2da0ca4be3dc27ad867a76f46015c2a9b15bc086a797e6439af9f5a710a4b054c625e10dd0f2e828a15c0d9340b6b
7
- data.tar.gz: d00b2e9634b441dd53b0ff05cb595be788f4d0baaa377206503f786f046a54cfa7f4ca12d49013457d2e42aa3d8ba7d898f52262ee797e5d8da9200493a6c25c
6
+ metadata.gz: 028780fc203beed4de73fd266b872d9b0a22d0eddd5cbeb5fd9119fe773a069b8dee881b28d4dd8cd75faad9bfab3cc747b5216c7808b9b7247ad79ed20f32d6
7
+ data.tar.gz: a6b386728b1c3454cfaa1f84f27eac33ed24e1587bbead6514ba34196e4fda5d9777312f3b1a45a7de3c5c10bcda247d448bcff036fe403daa8950407d44a1df
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  OpenStudio Analysis Gem Change Log
2
2
  ==================================
3
3
 
4
+ Version 0.4.2
5
+ -------------
6
+ * Bug fix when adding measure from path, this now sets the correct argument name.
7
+ * Fix namespace conflict with OpenStudio::Logger and OpenStudio::Time
8
+ * Create method for saving the Analysis Zip file (save_analysis_zip)
9
+
4
10
  Version 0.4.1
5
11
  -------------
6
12
  * Bug fix to address the spec/files directory being prepended to the measures
@@ -1,4 +1,4 @@
1
- # OpenStudio::Analysis::Algorithm to define the algorithm parameters. The module and class names start to conflict
1
+ # OpenStudio::Analysis::Algorithm define the algorithm parameters. The module and class names start to conflict
2
2
  # with OpenStudio's namespace. Be careful adding new classes without first making sure that the namespace conflict
3
3
  # is clear.
4
4
  module OpenStudio
@@ -1,17 +1,23 @@
1
1
  # OpenStudio formulation class handles the generation of the OpenStudio Analysis format.
2
2
  module OpenStudio
3
3
  module Analysis
4
- SeedModel = Struct.new(:path)
5
- WeatherFile = Struct.new(:path)
4
+ SeedModel = Struct.new(:file)
5
+ WeatherFile = Struct.new(:file)
6
6
 
7
7
  class Formulation
8
8
  attr_reader :seed_model
9
9
  attr_reader :weather_file
10
+ attr_reader :analysis_type
10
11
  attr_accessor :display_name
11
12
  attr_accessor :workflow
12
13
  attr_accessor :algorithm
13
14
 
14
- attr_reader :analysis_type
15
+ # the attributes below are used for packaging data into the analysis zip file
16
+ attr_reader :weather_files
17
+ attr_reader :seed_models
18
+ attr_reader :worker_inits
19
+ attr_reader :worker_finalizes
20
+ attr_reader :libraries
15
21
 
16
22
  # Create an instance of the OpenStudio::Analysis::Formulation
17
23
  #
@@ -26,6 +32,14 @@ module OpenStudio
26
32
  @weather_file = WeatherFile.new
27
33
  @seed_model = SeedModel.new
28
34
  @algorithm = OpenStudio::Analysis::AlgorithmAttributes.new
35
+
36
+ # Analysis Zip attributes
37
+ @weather_files = SupportFiles.new
38
+ @seed_models = SupportFiles.new
39
+ @worker_inits = SupportFiles.new
40
+ @worker_finalizes = SupportFiles.new
41
+ @libraries = SupportFiles.new
42
+ #@initialization_scripts = SupportFiles.new
29
43
  end
30
44
 
31
45
  # Initialize or return the current workflow object
@@ -43,16 +57,16 @@ module OpenStudio
43
57
  # Path to the seed model
44
58
  #
45
59
  # @param path [String] Path to the seed model. This should be relative.
46
- def seed_model(path)
47
- @seed_model = SeedModel.new(path: path)
60
+ def seed_model(file)
61
+ @seed_model = SeedModel.new(file)
48
62
  end
49
63
 
50
64
  # Path to the weather file (or folder). If it is a folder, then the measures will look for the weather file
51
65
  # by name in that folder.
52
66
  #
53
67
  # @param path [String] Path to the weather file or folder.
54
- def weather_file(path)
55
- @weather_file = WeatherFile.new(path: path)
68
+ def weather_file(file)
69
+ @weather_file = WeatherFile.new(file)
56
70
  end
57
71
 
58
72
  # Add an output of interest to the problem formulation
@@ -73,12 +87,12 @@ module OpenStudio
73
87
  # @option output_hash [Integer] :objective_function_group If grouping objective functions, then group ID. Default: nil
74
88
  def add_output(output_hash)
75
89
  output_hash = {
76
- units: '',
77
- objective_function: false,
78
- objective_function_index: nil,
79
- objective_function_target: nil,
80
- objective_function_group: nil,
81
- scaling_factor: nil
90
+ units: '',
91
+ objective_function: false,
92
+ objective_function_index: nil,
93
+ objective_function_target: nil,
94
+ objective_function_group: nil,
95
+ scaling_factor: nil
82
96
  }.merge(output_hash)
83
97
 
84
98
  # if the objective_function index is nil and the variable is an objective function, then increment and
@@ -99,19 +113,19 @@ module OpenStudio
99
113
  # fail 'Must define an analysis type' unless @analysis_type
100
114
  if version == 1
101
115
  h = {
102
- analysis: {
103
- display_name: @display_name,
104
- name: @display_name.snake_case,
105
- output_variables: @outputs,
106
- problem: {
107
- analysis_type: @analysis_type,
108
- algorithm: algorithm.to_hash(version),
109
- workflow: workflow.to_hash(version)
110
- },
111
- seed: @seed_model[:path],
112
- weather_file: @weather_file[:path],
113
- file_format_version: version
114
- }
116
+ analysis: {
117
+ display_name: @display_name,
118
+ name: @display_name.snake_case,
119
+ output_variables: @outputs,
120
+ problem: {
121
+ analysis_type: @analysis_type,
122
+ algorithm: algorithm.to_hash(version),
123
+ workflow: workflow.to_hash(version)
124
+ },
125
+ seed: @seed_model[:file],
126
+ weather_file: @weather_file[:file],
127
+ file_format_version: version
128
+ }
115
129
  }
116
130
 
117
131
  # This is a hack right now, but after the initial hash is created go back and add in the objective functions
@@ -140,11 +154,11 @@ module OpenStudio
140
154
  end
141
155
 
142
156
  h = {
143
- data_point: {
144
- set_variable_values: static_hash,
145
- status: 'na',
146
- uuid: SecureRandom.uuid
147
- }
157
+ data_point: {
158
+ set_variable_values: static_hash,
159
+ status: 'na',
160
+ uuid: SecureRandom.uuid
161
+ }
148
162
  }
149
163
  h
150
164
  end
@@ -152,9 +166,11 @@ module OpenStudio
152
166
 
153
167
  # save the file to JSON. Will overwrite the file if it already exists
154
168
  #
169
+ # @param filename [String] Name of file to create. It will create the directory and override the file if it exists.
155
170
  # @param version [Integer] Version of the format to return
156
171
  # @return [Boolean]
157
172
  def save(filename, version = 1)
173
+ FileUtils.mkdir_p File.dirname(filename) unless Dir.exist? File.dirname(filename)
158
174
  File.open(filename, 'w') { |f| f << JSON.pretty_generate(to_hash(version)) }
159
175
 
160
176
  true
@@ -169,6 +185,140 @@ module OpenStudio
169
185
 
170
186
  true
171
187
  end
188
+
189
+ # save the analysis zip file which contains the measures, seed model, weather file, and init/final scripts
190
+ #
191
+ # @param filename [String] Name of file to create. It will create the directory and override the file if it exists.
192
+ # @return [Boolean]
193
+ def save_zip(filename)
194
+ FileUtils.mkdir_p File.dirname(filename) unless Dir.exist? File.dirname(filename)
195
+
196
+ save_analysis_zip(filename)
197
+ end
198
+
199
+ private
200
+
201
+ # Package up the seed, weather files, and measures
202
+ def save_analysis_zip(filename)
203
+ def add_directory_to_zip(zipfile, local_directory, relative_zip_directory)
204
+ # puts "Add Directory #{local_directory}"
205
+ Dir[File.join("#{local_directory}", '**', '**')].each do |file|
206
+ # puts "Adding File #{file}"
207
+ zipfile.add(file.sub(local_directory, relative_zip_directory), file)
208
+ end
209
+ zipfile
210
+ end
211
+
212
+ FileUtils.rm_f(filename) if File.exist?(filename)
213
+
214
+ Zip::File.open(filename, Zip::File::CREATE) do |zf|
215
+
216
+ ## Weather files
217
+ # TODO: eventually remove the @weather_file attribute and grab the weather file out
218
+ # of the @weather_files
219
+ puts "Adding Support Files: Weather"
220
+ if @weather_file[:file] && !@weather_files.files.find { |f| @weather_file[:file] == f[:file] }
221
+ #manually add the weather file
222
+ puts " Adding #{@weather_file[:file]}"
223
+ zf.add("./weather/#{File.basename(@weather_file[:file])}", @weather_file[:file])
224
+ end
225
+ @weather_files.each do |f|
226
+ puts " Adding #{f[:file]}"
227
+ zf.add("./weather/#{File.basename(f[:file])}", f[:file])
228
+ end
229
+
230
+ ## Seed files
231
+ puts "Adding Support Files: Seed Models"
232
+ if @seed_model[:file] && !@seed_models.files.find { |f| @seed_model[:file] == f[:file] }
233
+ #manually add the weather file
234
+ puts " Adding #{@seed_model[:file]}"
235
+ zf.add("./seed/#{File.basename(@seed_model[:file])}", @seed_model[:file])
236
+ end
237
+ @seed_models.each do |f|
238
+ puts " Adding #{f[:file]}"
239
+ zf.add("./seed/#{File.basename(f[:file])}", f[:file])
240
+ end
241
+
242
+ puts "Adding Support Files: Libraries"
243
+ @libraries.each do |lib|
244
+ fail "Libraries must specify their 'library_name' as metadata which becomes the directory upon zip" unless lib[:metadata][:library_name]
245
+
246
+ if File.directory? lib[:file]
247
+ Dir[File.join(lib[:file], '**', '**')].each do |file|
248
+ puts " Adding #{file}"
249
+ zf.add(file.sub(lib[:file], "./lib/#{lib[:metadata][:library_name]}/"), file)
250
+ end
251
+ else
252
+ # just add the file to the zip
253
+ puts " Adding #{lib[:file]}"
254
+ zf.add(lib[:file], "./lib/#{File.basename(lib[:file])}", lib[:file])
255
+ end
256
+ end
257
+
258
+ puts "Adding Support Files: Worker Initialization Scripts"
259
+ index = 0
260
+ @worker_inits.each do |f|
261
+ ordered_file_name = "#{index.to_s.rjust(2, '0')}_#{File.basename(f[:file])}"
262
+ puts " Adding #{f[:file]} as #{ordered_file_name}"
263
+ zf.add(f[:file].sub(f[:file], "./lib/worker_initialize/#{ordered_file_name}"), f[:file])
264
+
265
+ if f[:metadata][:args]
266
+ arg_file = "#{File.basename(ordered_file_name, '.*')}.args"
267
+ file = Tempfile.new('arg')
268
+ file.write(f[:metadata][:args])
269
+ zf.add("./lib/worker_initialize/#{arg_file}", file)
270
+ file.close
271
+ end
272
+
273
+ index += 1
274
+ end
275
+
276
+ puts "Adding Support Files: Worker Finalization Scripts"
277
+ index = 0
278
+ @worker_finalizes.each do |f|
279
+ ordered_file_name = "#{index.to_s.rjust(2, '0')}_#{File.basename(f[:file])}"
280
+ puts " Adding #{f[:file]} as #{ordered_file_name}"
281
+ zf.add(f[:file].sub(f[:file], "./lib/worker_finalize/#{ordered_file_name}"), f[:file])
282
+
283
+ if f[:metadata][:args]
284
+ arg_file = "#{File.basename(ordered_file_name, '.*')}.args"
285
+ file = Tempfile.new('arg')
286
+ file.write(f[:metadata][:args])
287
+ zf.add("./lib/worker_finalize/#{arg_file}", file)
288
+ file.close
289
+ end
290
+
291
+ index += 1
292
+ end
293
+
294
+ ## Measures
295
+ puts "Adding Measures"
296
+ added_measures = []
297
+ # The list of the measures should always be there, but make sure they are uniq
298
+ @workflow.each do |measure|
299
+ measure_dir_to_add = measure.measure_definition_directory
300
+
301
+ next if added_measures.include? measure_dir_to_add
302
+
303
+ puts " Adding #{File.basename(measure_dir_to_add)}"
304
+ Dir[File.join(measure_dir_to_add, '**')].each do |file|
305
+ if File.directory?(file)
306
+ if File.basename(file) == 'resources' || File.basename(file) == 'lib'
307
+ add_directory_to_zip(zf, file, "./measures/#{measure.name}/#{File.basename(file)}")
308
+ else
309
+ # puts "Skipping Directory #{File.basename(file)}"
310
+ end
311
+ else
312
+ # puts "Adding File #{file}"
313
+ # added_measures << measure_dir unless added_measures.include? measure_dir
314
+ zf.add(file.sub(measure_dir_to_add, "./measures/#{measure.name}/"), file)
315
+ end
316
+ end
317
+
318
+ added_measures << measure_dir_to_add
319
+ end
320
+ end
321
+ end
172
322
  end
173
323
  end
174
324
  end
@@ -8,7 +8,7 @@ module OpenStudio
8
8
  def initialize(options = {})
9
9
  defaults = { hostname: 'http://localhost:8080' }
10
10
  options = defaults.merge(options)
11
- @logger = Logger.new('faraday.log')
11
+ @logger = ::Logger.new('faraday.log')
12
12
 
13
13
  @hostname = options[:hostname]
14
14
 
@@ -79,7 +79,7 @@ module OpenStudio
79
79
  end
80
80
 
81
81
  def new_project(options = {})
82
- defaults = { project_name: "Project #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}" }
82
+ defaults = { project_name: "Project #{::Time.now.strftime('%Y-%m-%d %H:%M:%S')}" }
83
83
  options = defaults.merge(options)
84
84
  project_id = nil
85
85
 
@@ -0,0 +1,76 @@
1
+ # OpenStudio::Analysis::SupportFiles is a container to hold other analysis files that may need to be packaged.
2
+ # The most common use of support files are weather files, design day files, multiple seed files, worker initialization
3
+ # scripts, worker finalization scripts, and general libraries
4
+ module OpenStudio
5
+ module Analysis
6
+ class SupportFiles
7
+
8
+ attr_reader :files
9
+
10
+ # Create a new instance of the support file class
11
+ #
12
+ def initialize
13
+ @files = []
14
+ end
15
+
16
+ # Add a file to the support file list
17
+ #
18
+ # @param path_or_filename [String] Full path of the file to be added.
19
+ # @return [Boolean] Returns false if the file does not exist
20
+ def add(path_or_filename, metadata = {})
21
+ if !File.exist?(path_or_filename) && !Dir.exist?(path_or_filename)
22
+ fail "Path or file does not exist and cannot be added: #{path_or_filename}"
23
+ end
24
+
25
+ # only add if it isn't allready in the list
26
+ if @files.find_all { |f| f[:file] == path_or_filename }.empty?
27
+ @files << {file: path_or_filename, metadata: metadata}
28
+ end
29
+
30
+ true
31
+ end
32
+
33
+ # Add a glob path with the same metadata for all the items
34
+ #
35
+ # @param pattern [String] Pattern to glob. example: /home/user1/files/**/*.rb
36
+ # @return [Boolean] Returns false if the file does not exist
37
+ def add_files(pattern, metadata = {})
38
+ Dir[pattern].each do |f|
39
+ add(f, metadata)
40
+ end
41
+
42
+ true
43
+ end
44
+
45
+ # Access a file by an index
46
+ def [](index)
47
+ @files[index]
48
+ end
49
+
50
+ # Remove a file from the list
51
+ #
52
+ # @param filename [String] Full name of the file to remove
53
+ def remove(filename)
54
+ @files.delete_if { |f| f[:file] == filename }
55
+ end
56
+
57
+ # Return the number of files
58
+ #
59
+ # @return [Integer] Number of items
60
+ def size
61
+ @files.size
62
+ end
63
+
64
+ # Iterate over the files
65
+ def each
66
+ @files.each { |i| yield i }
67
+ end
68
+
69
+ # remove all the items
70
+ def clear
71
+ @files.clear
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -1,5 +1,5 @@
1
1
  module OpenStudio
2
2
  module Analysis
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  end
@@ -124,6 +124,10 @@ module OpenStudio
124
124
  end
125
125
  end
126
126
 
127
+ # Iterate over all the WorkflowItems
128
+ def each
129
+ @items.each { |i| yield i }
130
+ end
127
131
  # Find the measure by its instance name
128
132
  #
129
133
  # @params instance_name [String] instance name of the measure
@@ -54,7 +54,7 @@ module OpenStudio
54
54
  # @return [Boolean] True/false if it assigned it
55
55
  def argument_value(argument_name, value)
56
56
  a = @arguments.find_all { |a| a[:name] == argument_name }
57
- fail "could not find argument_name of #{argument_name} in measure #{name}" if a.empty?
57
+ fail "could not find argument_name of #{argument_name} in measure #{name}. Valid argument names are #{argument_names}." if a.empty?
58
58
  fail "more than one argument with the same name of #{argument_name} in measure #{name}" if a.size > 1
59
59
 
60
60
  a = a.first
@@ -90,7 +90,7 @@ module OpenStudio
90
90
  distribution[:mode] = distribution[:mean] if distribution.key? :mean
91
91
 
92
92
  a = @arguments.find_all { |a| a[:name] == argument_name }
93
- fail "could not find argument_name of #{argument_name} in measure #{name}" if a.empty?
93
+ fail "could not find argument_name of #{argument_name} in measure #{name}. Valid argument names are #{argument_names}." if a.empty?
94
94
  fail "more than one argument with the same name of #{argument_name} in measure #{name}" if a.size > 1
95
95
 
96
96
  if distribution_valid?(distribution)
@@ -264,7 +264,7 @@ module OpenStudio
264
264
  s.arguments << {
265
265
  display_name: arg[:display_name],
266
266
  display_name_short: arg[:display_name],
267
- name: arg[:local_variable],
267
+ name: arg[:name],
268
268
  value_type: var_type,
269
269
  default_value: arg[:default_value],
270
270
  value: arg[:default_value]
@@ -20,6 +20,7 @@ require 'openstudio/analysis/version'
20
20
 
21
21
  # analysis classes
22
22
  require 'openstudio/analysis'
23
+ require 'openstudio/analysis/support_files'
23
24
  require 'openstudio/analysis/formulation'
24
25
  require 'openstudio/analysis/workflow'
25
26
  require 'openstudio/analysis/workflow_step'