rbbt-rest 1.3.4 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 149f96d6cd3121af4c1948eb970b3ef15caa2ff9
4
- data.tar.gz: c9c8e18ecbda7f195325212a64f5ae9ccbb1a631
3
+ metadata.gz: 08aa70a66616d766753916da78c7439a4ec800c5
4
+ data.tar.gz: 29ce9753938dcaf1890744d51a0b65bc694721c6
5
5
  SHA512:
6
- metadata.gz: 634d3acb1114b6baaeaf19d104465c5765ec6d075c08168181584c10b9688e7d076bda718e89a3ba4b75976f42edce43726637fe9378d4dca0e551730e6afc50
7
- data.tar.gz: 5440ddd934f2a1ef148f7a2c0f2c95f81d2341f9d0cbdcd3a4cb0ddbe8501d54f33694bb4eee638711190e85be93c3a40522f70a8896c38412b2e9481c8f1147
6
+ metadata.gz: 4d24e26e939eedc02ebb6c7f60651d1404f4da0900a5cc97e06809885efbfd3d292dff3006fc98dc2d5c26ca4808123ea30a5e50594a082e8b046a54191b10cc
7
+ data.tar.gz: 6562147f6e34262b00f5ebf4105e404ab10a37e169a4510844d4c3921b353dc2c2a7f237a6355613c1b57bebe921449e46340b77c6c1c89d22c0c1115b851fd3
@@ -18,14 +18,15 @@ class WorkflowRESTClient
18
18
  begin
19
19
  yield
20
20
  rescue Exception => e
21
- raise $! unless e.respond_to? :response
22
- klass, message = e.response.split " => "
21
+ raise e unless e.respond_to? :response
23
22
  begin
23
+ klass, message = e.response.to_s.split " => "
24
24
  klass = Kernel.const_get klass
25
+ raise klass.new message
25
26
  rescue
26
- raise message
27
+ raise e
27
28
  end
28
- raise klass.new message
29
+ raise $!
29
30
  end
30
31
  end
31
32
 
@@ -17,15 +17,21 @@ class WorkflowRESTClient
17
17
  end
18
18
 
19
19
  def info
20
- init_job unless url
21
- info = WorkflowRESTClient.get_json(File.join(url, 'info'))
22
- info = WorkflowRESTClient.fix_hash(info)
23
- info[:status] = info[:status].to_sym if String === info[:status]
24
- info
20
+ @info ||= begin
21
+ init_job unless url
22
+ info = WorkflowRESTClient.get_json(File.join(url, 'info'))
23
+ info = WorkflowRESTClient.fix_hash(info)
24
+ info[:status] = info[:status].to_sym if String === info[:status]
25
+ info
26
+ end
25
27
  end
26
28
 
27
29
  def status
28
- info[:status]
30
+ begin
31
+ info[:status]
32
+ ensure
33
+ @info = nil
34
+ end
29
35
  end
30
36
 
31
37
  def done?
@@ -58,6 +64,8 @@ class WorkflowRESTClient
58
64
  TSV.open(StringIO.new(res))
59
65
  when :annotations
60
66
  Annotated.load_tsv(TSV.open(StringIO.new(res)))
67
+ when :array
68
+ res.split("\n")
61
69
  else
62
70
  JSON.parse res
63
71
  end
@@ -65,9 +73,9 @@ class WorkflowRESTClient
65
73
 
66
74
  def get
67
75
  params ||= {}
68
- params = params.merge(:_format => [:string, :boolean, :tsv, :annotations].include?(result_type) ? :raw : :json )
76
+ params = params.merge(:_format => [:string, :boolean, :tsv, :annotations,:array].include?(result_type.to_sym) ? :raw : :json )
69
77
  begin
70
- WorkflowRESTClient.get_raw(url, params)
78
+ WorkflowRESTClient.get_raw(url, params)
71
79
  rescue => e
72
80
  raise e.response
73
81
  end
@@ -82,9 +90,7 @@ class WorkflowRESTClient
82
90
  res = WorkflowRESTClient.capture_exception do
83
91
  RestClient.post(URI.encode(File.join(base_url, task.to_s)), inputs.merge(:_cache_type => :exec, :_format => [:string, :boolean, :tsv, :annotations].include?(result_type) ? :raw : :json))
84
92
  end
85
- loaded = load_res res
86
- exit
87
- loaded
93
+ load_res res
88
94
  end
89
95
 
90
96
  def fork
@@ -114,8 +120,21 @@ class WorkflowRESTClient
114
120
  self
115
121
  end
116
122
 
123
+ def recursive_clean
124
+ init_job unless url
125
+ begin
126
+ WorkflowRESTClient.get_raw(url, :_update => :recursive_clean) unless @is_exec
127
+ rescue Exception
128
+ end
129
+ self
130
+ end
131
+
117
132
  def clean
118
- WorkflowRESTClient.get_raw(url, :_update => :clean) unless @is_exec
133
+ init_job unless url
134
+ begin
135
+ WorkflowRESTClient.get_raw(url, :_update => :clean) unless @is_exec
136
+ rescue Exception
137
+ end
119
138
  self
120
139
  end
121
140
  end
@@ -138,6 +138,7 @@ module Sinatra
138
138
  end
139
139
 
140
140
  error Exception do |e|
141
+ raise e unless @format == :html
141
142
  halt 500, [e.class.to_s, e.message] * " => "
142
143
  end
143
144
  end
@@ -39,6 +39,7 @@ module Sinatra
39
39
  Log.debug "Adding #{ workflow } to REST server"
40
40
 
41
41
  add_workflow_resource(workflow) if add_resource
42
+ workflow.documentation
42
43
 
43
44
 
44
45
  self.instance_eval workflow.libdir.lib['sinatra.rb'].read, workflow.libdir.lib['sinatra.rb'].find if workflow.respond_to?(:libdir) and File.exists? workflow.libdir.lib['sinatra.rb']
@@ -138,6 +139,7 @@ module Sinatra
138
139
  job = workflow.load_id(File.join(task, job))
139
140
 
140
141
  clean_job(workflow, job) if update == :clean
142
+ recursive_clean_job(workflow, job) if update == :recursive_clean
141
143
 
142
144
  begin
143
145
  started = job.info.any?
@@ -34,7 +34,7 @@ module WorkflowRESTHelpers
34
34
  when workflow.asynchronous_exports.include?(task)
35
35
  :asynchronous
36
36
  else
37
- raise "No known export type for #{ workflow } #{ task }"
37
+ raise "No known export type for #{ workflow } #{ task }. Accesses denied"
38
38
  end
39
39
  end
40
40
 
@@ -147,6 +147,7 @@ module WorkflowRESTHelpers
147
147
  job = workflow.job(task, jobname, inputs)
148
148
 
149
149
  job.clean if update == :clean
150
+ job.recursive_clean if update == :recursive_clean
150
151
 
151
152
  execution_type = execution_type(workflow, task)
152
153
  case execution_type
@@ -175,6 +176,15 @@ module WorkflowRESTHelpers
175
176
  end
176
177
  end
177
178
 
179
+ def recursive_clean_job(workflow, job)
180
+ job.recursive_clean
181
+
182
+ if ajax
183
+ halt 200
184
+ else
185
+ redirect to(File.join("/", workflow.to_s, job.task_name.to_s))
186
+ end
187
+ end
178
188
  def clean_job(workflow, job)
179
189
  job.clean
180
190
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez