openstudio-analysis 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ae67d42886b996287c5359e182083045cfe85b6
4
- data.tar.gz: 89317f8592fb0d6d68be5d4d2b86fb8de0c33614
3
+ metadata.gz: 331135d293b11122531a3b462900a2f4f3728da2
4
+ data.tar.gz: 3d168b780e1b66e0818cf2919f7220b7b5015de9
5
5
  SHA512:
6
- metadata.gz: d07df1298aeddd96b09b58a72ae55802d5badc04c194d50cac81df509dbf817b989b758a560306109d74a867ae8fd039543230f5b1edbac45870e77ad23525c7
7
- data.tar.gz: ad4f1c8a02213360581455198bd1ffa8e19750967359ba223048b35f2a3de5296bd89e8a02de71494c2496cce8e95cfa1c277fda38caea5516e761b252c9ce75
6
+ metadata.gz: 528fcf1894bc7d1615a46ffa9c7e97eb03f7302558b58b962a31a95b16cb752382c1dd4e8ff86453bfec91790cbf12de58ab7a9e51db50a9173f9c5e69f19f64
7
+ data.tar.gz: 50b95802b1e19035ba1f1e1ff874851f4ae1b34496a53b1e7761c0c6edc11e91d539c8df2c491605ce1e9b25e7ea82cb5ca935846674a9558958730b78053498
@@ -8,6 +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
12
 
12
13
  @hostname = options[:hostname]
13
14
 
@@ -16,7 +17,8 @@ module OpenStudio
16
17
  # create connection with basic capabilities
17
18
  @conn = Faraday.new(:url => @hostname) do |faraday|
18
19
  faraday.request :url_encoded # form-encode POST params
19
- faraday.response :logger # log requests to STDOUT
20
+ faraday.use Faraday::Response::Logger, @logger
21
+ #faraday.response @logger # log requests to STDOUT
20
22
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
21
23
  end
22
24
 
@@ -24,7 +26,8 @@ module OpenStudio
24
26
  @conn_multipart = Faraday.new(:url => @hostname) do |faraday|
25
27
  faraday.request :multipart
26
28
  faraday.request :url_encoded # form-encode POST params
27
- faraday.response :logger # log requests to STDOUT
29
+ faraday.use Faraday::Response::Logger, @logger
30
+ #faraday.response :logger # log requests to STDOUT
28
31
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
29
32
  end
30
33
  end
@@ -33,7 +33,7 @@ module OpenStudio
33
33
  end
34
34
 
35
35
  # Initialize some other instance variables
36
- @version = nil
36
+ @version = '0.0.1'
37
37
  @name = nil
38
38
  @machine_name = nil
39
39
  @settings = {}
@@ -63,6 +63,9 @@ module OpenStudio
63
63
  end
64
64
 
65
65
  def validate_analysis
66
+ version_test = Semantic::Version.new @version
67
+ raise "Spreadsheet version #{@version} is no longer supported. Please upgrade your spreadsheet to at least 0.1.9" if version_test < '0.1.9'
68
+
66
69
  # Setup the paths and do some error checking
67
70
  raise "Measures directory '#{@measure_path}' does not exist" unless Dir.exists?(@measure_path)
68
71
 
@@ -135,11 +138,17 @@ module OpenStudio
135
138
  true
136
139
  end
137
140
 
138
- def save_analysis
141
+ def create_analysis_hash
139
142
  # save the format in the OpenStudio analysis json format template without
140
143
  # the correct weather files or models
141
144
  @template_json = translate_to_analysis_json_template()
142
-
145
+
146
+ @template_json
147
+ end
148
+
149
+ def save_analysis
150
+ @template_json = create_analysis_hash
151
+
143
152
  #validate_template_json
144
153
 
145
154
  # iterate over each model and save the zip and json
@@ -164,6 +173,11 @@ module OpenStudio
164
173
  # Templated analysis json file (this is what is returned)
165
174
  puts "Analysis name is #{@name}"
166
175
  openstudio_analysis_json = JSON.parse(analysis_template.result(get_binding))
176
+
177
+ openstudio_analysis_json['analysis']['problem'].merge!(@problem)
178
+ openstudio_analysis_json['analysis']['problem']['algorithm'].merge!(@algorithm)
179
+
180
+
167
181
 
168
182
  @measure_index = -1
169
183
  @variables['data'].each do |measure|
@@ -254,21 +268,21 @@ module OpenStudio
254
268
 
255
269
  Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
256
270
  @weather_files.each do |filename|
257
- puts " Adding #{filename}"
271
+ #puts " Adding #{filename}"
258
272
  zipfile.add("./weather/#{File.basename(filename)}", filename)
259
273
  end
260
274
 
261
275
  Dir.glob("#{@measure_path}/**/*.rb").each do |measure|
262
276
  next if measure.include?("spec") # don't include the spec folders nor files
263
277
  measure_name = measure.split(File::SEPARATOR).last(2).first
264
- puts " Adding ./measures/#{measure_name}/#{File.basename(measure)}"
278
+ #puts " Adding ./measures/#{measure_name}/#{File.basename(measure)}"
265
279
  zipfile.add("./measures/#{measure_name}/#{File.basename(measure)}", measure)
266
280
  end
267
281
 
268
- puts "Adding #{model[:path]}"
282
+ #puts "Adding #{model[:path]}"
269
283
  zipfile.add("./seed/#{File.basename(model[:path])}", model[:path])
270
284
 
271
- puts "Adding in other files #{@other_files.inspect}"
285
+ #puts "Adding in other files #{@other_files.inspect}"
272
286
  @other_files.each do |others|
273
287
  Dir[File.join(others[:path], '**', '**')].each do |file|
274
288
  zipfile.add(file.sub(others[:path], "./lib/#{others[:lib_zip_name]}/"), file)
@@ -385,9 +399,18 @@ module OpenStudio
385
399
  @export_path = File.expand_path(File.join(@root_path, row[1])) if row[0] == "Export Directory"
386
400
  @measure_path = File.expand_path(File.join(@root_path, row[1])) if row[0] == "Measure Directory"
387
401
  elsif b_problem_setup
388
- @problem["#{row[0].snake_case}"] = row[1] if row[0]
402
+ if row[0]
403
+ v = row[1]
404
+ v.to_i if v % 1 == 0
405
+ @problem["#{row[0].snake_case}"] = v
406
+ end
407
+
389
408
  elsif b_algorithm_setup
390
- @algorithm["#{row[0].snake_case}"] = row[1] if row[0]
409
+ if row[0]
410
+ v = row[1]
411
+ v = v.to_i if v % 1 == 0
412
+ @algorithm["#{row[0].snake_case}"] = v
413
+ end
391
414
  elsif b_weather_files
392
415
  if row[0] == "Weather File"
393
416
  @weather_files += Dir.glob(File.expand_path(File.join(@root_path, row[1])))
@@ -1,6 +1,6 @@
1
1
  module OpenStudio
2
2
  module Analysis
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  OPENSTUDIO_VERSION = "1.1.4"
5
5
  end
6
6
  end
@@ -2,17 +2,9 @@
2
2
  "analysis": {
3
3
  "display_name": "<%= @name %>",
4
4
  "name": "<%= @name.downcase.gsub(" ", "_") %>",
5
- "algorithm": {
6
- "sample_method": "lhs",
7
- "number_of_samples": <%= @problem['number_of_samples'].to_i %>
8
- },
9
5
  "parameter_space": [],
10
6
  "problem": {
11
- "number_of_samples_KEEP_HERE_UNTIL_ALGO_IS_IMPLEMENTED": <%= @problem['number_of_samples'].to_i %>,
12
- "number_of_samples": <%= @problem['number_of_samples'].to_i %>,
13
7
  "algorithm": {
14
- "number_of_samples": <%= @problem['number_of_samples'].to_i %>,
15
- "sample_method": <%= @problem['sensitivity_method'].to_i %>
16
8
  },
17
9
  "name": "Problem",
18
10
  "workflow": []
@@ -4,6 +4,8 @@ require 'uuid'
4
4
  require 'roo'
5
5
  require 'erb'
6
6
  require 'zip'
7
+ require 'semantic'
8
+ require 'logger'
7
9
 
8
10
  # core
9
11
  require 'openstudio/analysis/server_api'