opentox-ruby-api-wrapper 1.6.0 → 1.6.1

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.
@@ -23,9 +23,9 @@ module OpenTox
23
23
  end
24
24
 
25
25
  public
26
- def self.find(uri)
26
+ def self.find( uri, accept_header='application/rdf+xml' )
27
27
  task = Task.new(uri)
28
- task.reload
28
+ task.reload( accept_header )
29
29
  return task
30
30
  end
31
31
 
@@ -36,8 +36,8 @@ module OpenTox
36
36
  return task
37
37
  end
38
38
 
39
- def reload
40
- result = RestClientWrapper.get(uri, {:accept => 'application/rdf+xml'}, false)#'application/x-yaml'})
39
+ def reload( accept_header='application/rdf+xml' )
40
+ result = RestClientWrapper.get(uri, {:accept => accept_header}, false)#'application/x-yaml'})
41
41
  @http_code = result.code
42
42
  reload_from_data(result, result.content_type, uri)
43
43
  end
@@ -95,8 +95,8 @@ module OpenTox
95
95
  def wait_for_completion(dur=0.3)
96
96
 
97
97
  if (@uri.match(@@config[:services]["opentox-task"]))
98
- due_to_time = Time.parse(@due_to_time)
99
- running_time = due_to_time - Time.parse(@date)
98
+ due_to_time = (@due_to_time.is_a?(Time) ? @due_to_time : Time.parse(@due_to_time))
99
+ running_time = due_to_time - (@date.is_a?(Time) ? @date : Time.parse(@date))
100
100
  else
101
101
  # the date of the external task cannot be trusted, offest to local time might be to big
102
102
  due_to_time = Time.new + EXTERNAL_TASK_MAX_DURATION
@@ -4,12 +4,12 @@
4
4
  #
5
5
  # Example MySql:
6
6
  #
7
- :database:
8
- :adapter: mysql
9
- :database: production
10
- :username: root
11
- :password: opentox
12
- :host: localhost
7
+ :database:
8
+ :adapter: mysql
9
+ :database: production
10
+ :username: root
11
+ :password: opentox
12
+ :host: localhost
13
13
  #
14
14
  # Example 1: Using external test services
15
15
  #
@@ -22,42 +22,44 @@
22
22
  # opentox-validation: "http://opentox.informatik.uni-freiburg.de/validation/"
23
23
  #
24
24
  # Example 2: Using local services
25
- :base_dir: /home/ist/webservices
26
- :webserver: passenger
27
- :services:
28
- opentox-compound: "http://localhost/compound/"
29
- opentox-dataset: "http://localhost/dataset/"
30
- opentox-algorithm: "http://localhost/algorithm/"
31
- opentox-model: "http://localhost/model/"
32
- opentox-task: "http://localhost/task/"
33
- opentox-validation: "http://localhost/validation/"
25
+ :base_dir: /home/ist/webservices
26
+ :webserver: passenger
27
+ :services:
28
+ opentox-compound: "http://localhost/compound/"
29
+ opentox-dataset: "http://localhost/dataset/"
30
+ opentox-algorithm: "http://localhost/algorithm/"
31
+ opentox-model: "http://localhost/model/"
32
+ opentox-task: "http://localhost/task/"
33
+ opentox-validation: "http://localhost/validation/"
34
34
  #
35
35
  # Accept headers:
36
36
  #
37
- :accept_headers:
38
- opentox-compound:
39
- - "chemical/x-daylight-smiles"
40
- - "chemical/x-inchi"
41
- - "chemical/x-mdl-sdfile"
42
- - "image/gif"
43
- - "text/plain"
44
- opentox-dataset:
45
- - "application/x-yaml"
46
- - "application/rdf+xml"
47
- opentox-algorithm:
48
- - "application/x-yaml"
49
- - "application/rdf+xml"
50
- opentox-model:
51
- - "application/x-yaml"
52
- - "application/rdf+xml"
53
- opentox-task:
54
- - "application/x-yaml"
55
- - "application/rdf+xml"
56
- opentox-validation:
57
- - "application/x-yaml"
58
- - "application/rdf+xml"
37
+ :accept_headers:
38
+ opentox-compound:
39
+ - "chemical/x-daylight-smiles"
40
+ - "chemical/x-inchi"
41
+ - "chemical/x-mdl-sdfile"
42
+ - "image/gif"
43
+ - "text/plain"
44
+ opentox-dataset:
45
+ - "application/x-yaml"
46
+ - "application/rdf+xml"
47
+ opentox-algorithm:
48
+ - "application/x-yaml"
49
+ - "application/rdf+xml"
50
+ opentox-model:
51
+ - "application/x-yaml"
52
+ - "application/rdf+xml"
53
+ opentox-task:
54
+ - "application/x-yaml"
55
+ - "application/rdf+xml"
56
+ opentox-validation:
57
+ - "application/x-yaml"
58
+ - "application/rdf+xml"
59
59
 
60
60
  # Timeouts:
61
- #
62
- :default_task_max_duration: 3600
63
- :external_task_max_duration: 3600
61
+ :default_task_max_duration: 3600
62
+ :external_task_max_duration: 3600
63
+
64
+ # Uncomment for verbose logging
65
+ # :logger: debug
@@ -28,6 +28,13 @@ module OpenTox
28
28
  return false
29
29
  end
30
30
  end
31
+
32
+ def self.median(array)
33
+ return nil if array.empty?
34
+ array.sort!
35
+ m_pos = array.size / 2
36
+ return array.size % 2 == 1 ? array[m_pos] : (array[m_pos-1] + array[m_pos])/2
37
+ end
31
38
 
32
39
  end
33
40
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentox-ruby-api-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 0
10
- version: 1.6.0
9
+ - 1
10
+ version: 1.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christoph Helma, Martin Guetlein
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-19 00:00:00 +02:00
18
+ date: 2010-08-09 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -243,21 +243,21 @@ dependencies:
243
243
  type: :runtime
244
244
  version_requirements: *id016
245
245
  - !ruby/object:Gem::Dependency
246
- name: dm-core
246
+ name: rjb
247
247
  prerelease: false
248
248
  requirement: &id017 !ruby/object:Gem::Requirement
249
249
  none: false
250
250
  requirements:
251
251
  - - ">="
252
252
  - !ruby/object:Gem::Version
253
- hash: 1
253
+ hash: 3
254
254
  segments:
255
- - 1
256
- version: "1"
255
+ - 0
256
+ version: "0"
257
257
  type: :runtime
258
258
  version_requirements: *id017
259
259
  - !ruby/object:Gem::Dependency
260
- name: dm-serializer
260
+ name: dm-core
261
261
  prerelease: false
262
262
  requirement: &id018 !ruby/object:Gem::Requirement
263
263
  none: false
@@ -271,7 +271,7 @@ dependencies:
271
271
  type: :runtime
272
272
  version_requirements: *id018
273
273
  - !ruby/object:Gem::Dependency
274
- name: dm-timestamps
274
+ name: dm-serializer
275
275
  prerelease: false
276
276
  requirement: &id019 !ruby/object:Gem::Requirement
277
277
  none: false
@@ -285,7 +285,7 @@ dependencies:
285
285
  type: :runtime
286
286
  version_requirements: *id019
287
287
  - !ruby/object:Gem::Dependency
288
- name: dm-types
288
+ name: dm-timestamps
289
289
  prerelease: false
290
290
  requirement: &id020 !ruby/object:Gem::Requirement
291
291
  none: false
@@ -299,7 +299,7 @@ dependencies:
299
299
  type: :runtime
300
300
  version_requirements: *id020
301
301
  - !ruby/object:Gem::Dependency
302
- name: dm-migrations
302
+ name: dm-types
303
303
  prerelease: false
304
304
  requirement: &id021 !ruby/object:Gem::Requirement
305
305
  none: false
@@ -313,7 +313,7 @@ dependencies:
313
313
  type: :runtime
314
314
  version_requirements: *id021
315
315
  - !ruby/object:Gem::Dependency
316
- name: dm-mysql-adapter
316
+ name: dm-migrations
317
317
  prerelease: false
318
318
  requirement: &id022 !ruby/object:Gem::Requirement
319
319
  none: false
@@ -327,9 +327,23 @@ dependencies:
327
327
  type: :runtime
328
328
  version_requirements: *id022
329
329
  - !ruby/object:Gem::Dependency
330
- name: haml
330
+ name: dm-mysql-adapter
331
331
  prerelease: false
332
332
  requirement: &id023 !ruby/object:Gem::Requirement
333
+ none: false
334
+ requirements:
335
+ - - ">="
336
+ - !ruby/object:Gem::Version
337
+ hash: 1
338
+ segments:
339
+ - 1
340
+ version: "1"
341
+ type: :runtime
342
+ version_requirements: *id023
343
+ - !ruby/object:Gem::Dependency
344
+ name: haml
345
+ prerelease: false
346
+ requirement: &id024 !ruby/object:Gem::Requirement
333
347
  none: false
334
348
  requirements:
335
349
  - - ">="
@@ -339,11 +353,11 @@ dependencies:
339
353
  - 3
340
354
  version: "3"
341
355
  type: :runtime
342
- version_requirements: *id023
356
+ version_requirements: *id024
343
357
  - !ruby/object:Gem::Dependency
344
358
  name: cucumber
345
359
  prerelease: false
346
- requirement: &id024 !ruby/object:Gem::Requirement
360
+ requirement: &id025 !ruby/object:Gem::Requirement
347
361
  none: false
348
362
  requirements:
349
363
  - - ">="
@@ -353,11 +367,11 @@ dependencies:
353
367
  - 0
354
368
  version: "0"
355
369
  type: :development
356
- version_requirements: *id024
370
+ version_requirements: *id025
357
371
  - !ruby/object:Gem::Dependency
358
372
  name: jeweler
359
373
  prerelease: false
360
- requirement: &id025 !ruby/object:Gem::Requirement
374
+ requirement: &id026 !ruby/object:Gem::Requirement
361
375
  none: false
362
376
  requirements:
363
377
  - - ">="
@@ -367,7 +381,7 @@ dependencies:
367
381
  - 0
368
382
  version: "0"
369
383
  type: :development
370
- version_requirements: *id025
384
+ version_requirements: *id026
371
385
  description: Ruby wrapper for the OpenTox REST API (http://www.opentox.org)
372
386
  email: helma@in-silico.ch
373
387
  executables:
@@ -398,11 +412,12 @@ files:
398
412
  - lib/model.rb
399
413
  - lib/opentox-ruby-api-wrapper.rb
400
414
  - lib/opentox.owl
415
+ - lib/ot-logger.rb
416
+ - lib/overwrite.rb
401
417
  - lib/owl.rb
402
418
  - lib/rest_client_wrapper.rb
403
419
  - lib/spork.rb
404
420
  - lib/task.rb
405
- - lib/tasks/opentox.rb
406
421
  - lib/templates/config.yaml
407
422
  - lib/templates/users.yaml
408
423
  - lib/utils.rb
@@ -1,107 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'opentox-ruby-api-wrapper.rb')
2
-
3
- namespace :opentox do
4
-
5
- namespace :services do
6
-
7
- desc "Run opentox services"
8
- task :start do
9
- @@config[:services].each do |service,uri|
10
- dir = File.join(@@config[:base_dir], service)
11
- server = @@config[:webserver]
12
- case server
13
- when /thin|mongrel|webrick/
14
- port = uri.sub(/^.*:/,'').sub(/\/$/,'')
15
- Dir.chdir dir
16
- pid_file = File.join(TMP_DIR,"#{service}.pid")
17
- begin
18
- `#{server} --trace --rackup config.ru start -p #{port} -e #{ENV['RACK_ENV']} -P #{pid_file} -d &`
19
- puts "#{service} started on localhost:#{port} in #{ENV['RACK_ENV']} environment with PID file #{pid_file}."
20
- rescue
21
- puts "Cannot start #{service} on port #{port}."
22
- end
23
- when 'passenger'
24
- FileUtils.mkdir_p File.join(dir, 'tmp')
25
- FileUtils.touch File.join(dir, 'tmp/restart.txt')
26
- puts "#{service} restarted."
27
- else
28
- puts "not yet implemented"
29
- end
30
- end
31
- end
32
-
33
- desc "Stop opentox services"
34
- task :stop do
35
- server = @@config[:webserver]
36
- if server =~ /thin|mongrel|webrick/
37
- @@config[:services].each do |service,uri|
38
- port = uri.sub(/^.*:/,'').sub(/\/$/,'')
39
- pid_file = File.join(TMP_DIR,"#{service}.pid")
40
- begin
41
- puts `#{server} stop -P #{pid_file}`
42
- puts "#{service} stopped on localhost:#{port}"
43
- rescue
44
- puts "Cannot stop #{service} on port #{port}."
45
- end
46
- end
47
- end
48
- end
49
-
50
- desc "Restart opentox services"
51
- task :restart => [:stop, :start]
52
-
53
- end
54
-
55
- desc "Run all OpenTox tests"
56
- task :test do
57
- @@config[:services].each do |service,uri|
58
- dir = File.join(@@config[:base_dir], service)
59
- Dir.chdir dir
60
- puts "Running tests in #{dir}"
61
- `rake test -t 1>&2`
62
- end
63
- end
64
-
65
- end
66
-
67
- desc "Start service in current directory"
68
- task :start do
69
- service = File.basename(Dir.pwd).intern
70
- server = @@config[:webserver]
71
- case server
72
- when /thin|mongrel|webrick/
73
- port = @@config[:services][service].sub(/^.*:/,'').sub(/\/$/,'')
74
- pid_file = File.join(TMP_DIR,"#{service}.pid")
75
- begin
76
- `#{server} --trace --rackup config.ru start -p #{port} -e #{ENV['RACK_ENV']} -P #{pid_file} -d &`
77
- puts "#{service} started on localhost:#{port} in #{ENV['RACK_ENV']} environment with PID file #{pid_file}."
78
- rescue
79
- puts "Cannot start #{service} on port #{port}."
80
- end
81
- when 'passenger'
82
- FileUtils.mkdir_p File.join(dir, 'tmp')
83
- FileUtils.touch File.join(dir, 'tmp/restart.txt')
84
- puts "#{service} restarted."
85
- else
86
- puts "not yet implemented"
87
- end
88
- end
89
-
90
- desc "Stop service in current directory"
91
- task :stop do
92
- service = File.basename(Dir.pwd).intern
93
- server = @@config[:webserver]
94
- if server =~ /thin|mongrel|webrick/
95
- port = @@config[:services][service].sub(/^.*:/,'').sub(/\/$/,'')
96
- pid_file = File.join(TMP_DIR,"#{service}.pid")
97
- begin
98
- puts `thin stop -P #{pid_file}`
99
- puts "#{service} stopped on localhost:#{port}"
100
- rescue
101
- puts "Cannot stop #{service} on port #{port}."
102
- end
103
- end
104
- end
105
-
106
- desc "Restart service in current directory"
107
- task :restart => [:stop, :start]