17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/rbbt/workflow/soap.rb', line 17
def initialize(workflow, *args)
super(workflow.to_s, *args)
@workflow = workflow
@workflow.synchronous_exports.each do |name| synchronous name end
@workflow.asynchronous_exports.each do |name| asynchronous name end
@workflow.stream_exports.each do |name| asynchronous name end
desc "Job management: Check the status of a job"
param_desc :jobid => "Job identifier", :return => "Status code. Special status codes are: 'done' and 'error'"
serve :status, [:jobid], :jobid => :string, :return => :string do |jobid|
(job(jobid).status || :queued).to_s
end
desc "Job management: Return an array with the messages issued by the job"
param_desc :jobid => "Job identifier", :return => "Array with message strings"
serve :messages, ['jobid'], :job => :string, :return => :array do |jobid|
job(jobid).messages || []
end
desc "Job management: Return a YAML string containing arbitrary information set up by the job"
param_desc :jobid => "Job identifier", :return => "Hash with arbitrary values in YAML format"
serve :info, ['jobid'], :jobid => :string, :return => :string do |jobid|
job(jobid).info.to_yaml
end
desc "Job management: Load job result as string "
param_desc :jobid => "Job identifier", :return => "String containing the result of the job"
serve :load_string, %w(jobid), :jobid => :string, :return => :string do |jobid|
Open.read(job(jobid).path)
end
desc "Job management: Abort the job"
param_desc :jobid => "Job identifier"
serve :abort, %w(jobid), :jobid => :string, :return => false do |jobid|
job(jobid).abort
end
desc "Job management: Check if the job is done. Could have finished successfully, with error, or have been aborted"
param_desc :jobid => "Job identifier", :return => "True if the job has status 'done', 'error' or 'aborted'"
serve :done, %w(jobid), :jobid => :string, :return => :boolean do |jobid|
[:done, :error, :aborted].include?((job(jobid).status || :queued).to_sym)
end
desc "Job management: Check if the job has finished with error. The last message is the error message"
param_desc :jobid => "Job identifier", :return => "True if the job has status 'error'"
serve :error, %w(jobid), :jobid => :string, :return => :boolean do |jobid|
job(jobid).status.to_sym == :error
end
desc "Job management: Check if the job has finished with error. The last message is the error message"
param_desc :jobid => "Job identifier", :return => "True if the job has status 'error'"
serve :clean, %w(jobid), :jobid => :string, :return => nil do |jobid|
job(jobid).clean
nil
end
end
|