taverna-player 0.8.0 → 0.9.0
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 +8 -8
- data/.travis.yml +6 -0
- data/CHANGES.rdoc +28 -0
- data/CITATION +20 -0
- data/Gemfile +0 -12
- data/README.rdoc +30 -16
- data/Rakefile +1 -0
- data/app/controllers/taverna_player/workflows_controller.rb +18 -0
- data/app/helpers/taverna_player/application_helper.rb +2 -2
- data/app/models/taverna_player/run.rb +35 -3
- data/app/models/taverna_player/workflow.rb +41 -0
- data/app/views/taverna_player/workflows/_info.json.jbuilder +1 -0
- data/{test/dummy/app/views → app/views/taverna_player}/workflows/index.html.erb +1 -1
- data/app/views/taverna_player/workflows/index.json.jbuilder +1 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20140917165505_create_taverna_player_workflows.rb +12 -0
- data/lib/generators/taverna_player/controllers_generator.rb +5 -6
- data/lib/generators/taverna_player/models_generator.rb +3 -3
- data/lib/generators/templates/callbacks/worker_callbacks.rb +5 -5
- data/{test/dummy/app → lib/generators/templates}/controllers/workflows_controller.rb +7 -4
- data/{test/dummy/test/functional/workflows_controller_test.rb → lib/generators/templates/models/workflow.rb} +6 -7
- data/lib/generators/templates/player_initializer.rb +5 -4
- data/lib/taverna-player.rb +11 -1
- data/lib/taverna_player/concerns/controllers/runs_controller.rb +1 -1
- data/lib/taverna_player/concerns/controllers/workflows_controller.rb +41 -0
- data/lib/taverna_player/concerns/models/run.rb +42 -14
- data/lib/taverna_player/concerns/models/run_port.rb +2 -1
- data/lib/taverna_player/concerns/models/workflow.rb +44 -0
- data/lib/taverna_player/model_proxy.rb +14 -8
- data/lib/taverna_player/version.rb +1 -1
- data/taverna_player.gemspec +1 -0
- data/test/dummy/app/views/layouts/application.html.erb +1 -1
- data/test/dummy/config/initializers/taverna_player.rb +1 -4
- data/test/dummy/config/routes.rb +1 -7
- data/test/dummy/db/migrate/20140917165846_drop_workflows.rb +9 -0
- data/test/dummy/db/migrate/20140917170017_create_taverna_player_workflows.taverna_player.rb +13 -0
- data/test/dummy/db/schema.rb +9 -9
- data/test/dummy/lib/callbacks.rb +4 -4
- data/test/fixtures/delayed_jobs.yml +45 -0
- data/test/fixtures/taverna_player/interactions.yml +3 -3
- data/test/fixtures/taverna_player/run_ports.yml +7 -12
- data/test/fixtures/taverna_player/runs.yml +43 -13
- data/test/fixtures/{workflows.yml → taverna_player/workflows.yml} +1 -4
- data/test/fixtures/users.yml +2 -3
- data/test/functional/taverna_player/runs_controller_test.rb +42 -15
- data/test/functional/taverna_player/workflows_controller_test.rb +37 -0
- data/test/unit/helpers/taverna_player/application_helper_test.rb +1 -1
- data/test/unit/taverna_player/interaction_test.rb +2 -2
- data/test/unit/taverna_player/model_proxy_test.rb +58 -0
- data/test/unit/taverna_player/run_test.rb +103 -23
- data/test/unit/taverna_player/worker_test.rb +2 -0
- metadata +39 -12
- data/test/dummy/app/models/workflow.rb +0 -32
@@ -1,5 +1,5 @@
|
|
1
1
|
#------------------------------------------------------------------------------
|
2
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
2
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
3
3
|
#
|
4
4
|
# BSD Licenced. See LICENCE.rdoc for details.
|
5
5
|
#
|
@@ -19,8 +19,8 @@ module TavernaPlayer
|
|
19
19
|
"customization."
|
20
20
|
|
21
21
|
def copy_models
|
22
|
-
|
23
|
-
copy_file file, "app/models/taverna_player/#{file}"
|
22
|
+
%w(run run_port workflow).each do |file|
|
23
|
+
copy_file "#{file}.rb", "app/models/taverna_player/#{file}.rb"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#------------------------------------------------------------------------------
|
2
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
2
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
3
3
|
#
|
4
4
|
# BSD Licenced. See LICENCE.rdoc for details.
|
5
5
|
#
|
@@ -11,21 +11,21 @@
|
|
11
11
|
#------------------------------------------------------------------------------
|
12
12
|
|
13
13
|
def player_pre_run_callback(run)
|
14
|
-
w = Workflow.find(run.workflow_id)
|
14
|
+
w = TavernaPlayer::Workflow.find(run.workflow_id)
|
15
15
|
puts "Pre-run callback called for run '#{run.name}' of workflow '#{w.id}'"
|
16
16
|
end
|
17
17
|
|
18
18
|
def player_post_run_callback(run)
|
19
|
-
w = Workflow.find(run.workflow_id)
|
19
|
+
w = TavernaPlayer::Workflow.find(run.workflow_id)
|
20
20
|
puts "Post-run callback called for run '#{run.name}' of workflow '#{w.id}'"
|
21
21
|
end
|
22
22
|
|
23
23
|
def player_run_cancelled_callback(run)
|
24
|
-
w = Workflow.find(run.workflow_id)
|
24
|
+
w = TavernaPlayer::Workflow.find(run.workflow_id)
|
25
25
|
puts "Run-cancelled callback called for run '#{run.name}' of workflow '#{w.id}'"
|
26
26
|
end
|
27
27
|
|
28
28
|
def player_run_failed_callback(run)
|
29
|
-
w = Workflow.find(run.workflow_id)
|
29
|
+
w = TavernaPlayer::Workflow.find(run.workflow_id)
|
30
30
|
puts "Run-failed callback called for run '#{run.name}' of workflow '#{w.id}'"
|
31
31
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#------------------------------------------------------------------------------
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright (c) 2014 The University of Manchester, UK.
|
3
3
|
#
|
4
4
|
# BSD Licenced. See LICENCE.rdoc for details.
|
5
5
|
#
|
@@ -10,8 +10,11 @@
|
|
10
10
|
# Author: Robert Haines
|
11
11
|
#------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
module TavernaPlayer
|
14
|
+
class WorkflowsController < TavernaPlayer::ApplicationController
|
15
|
+
# Do not remove the next line.
|
16
|
+
include TavernaPlayer::Concerns::Controllers::WorkflowsController
|
17
|
+
|
18
|
+
# Extend the WorkflowsController here.
|
16
19
|
end
|
17
20
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#------------------------------------------------------------------------------
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright (c) 2014 The University of Manchester, UK.
|
3
3
|
#
|
4
4
|
# BSD Licenced. See LICENCE.rdoc for details.
|
5
5
|
#
|
@@ -10,12 +10,11 @@
|
|
10
10
|
# Author: Robert Haines
|
11
11
|
#------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
|
13
|
+
module TavernaPlayer
|
14
|
+
class Workflow < ActiveRecord::Base
|
15
|
+
# Do not remove the next line.
|
16
|
+
include TavernaPlayer::Concerns::Models::Workflow
|
14
17
|
|
15
|
-
|
16
|
-
test "should get index" do
|
17
|
-
get :index
|
18
|
-
assert_response :success
|
18
|
+
# Extend the Workflow model here.
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
TavernaPlayer.setup do |config|
|
4
4
|
|
5
|
-
# This
|
6
|
-
# application and the listed methods should also be mapped if necessary.
|
7
|
-
|
8
|
-
|
5
|
+
# This can be set to the name of a workflow model class in the main
|
6
|
+
# application and the listed methods should also be mapped if necessary. The
|
7
|
+
# default behaviour is to use the Workflow model provided by Taverna Player.
|
8
|
+
config.workflow_model_proxy = "TavernaPlayer::Workflow"
|
9
|
+
#config.workflow_model_proxy("TavernaPlayer::Workflow") do |proxy|
|
9
10
|
# This is the method that returns the name of the workflow file. Your
|
10
11
|
# model MUST provide this otherwise a workflow cannot be run.
|
11
12
|
#proxy.file_method_name = :file
|
data/lib/taverna-player.rb
CHANGED
@@ -33,10 +33,14 @@ module TavernaPlayer
|
|
33
33
|
mattr_accessor :server_address, :server_password, :server_username
|
34
34
|
|
35
35
|
# This should be set to the name of the workflow model class in the main
|
36
|
-
# application via the workflow_model_proxy method below.
|
36
|
+
# application via the workflow_model_proxy method below. Defaults to the
|
37
|
+
# internal Taverna Player Workflow model (TavernaPlayer::Workflow).
|
37
38
|
mattr_reader :workflow_proxy
|
39
|
+
@@workflow_proxy =
|
40
|
+
ModelProxy.new("TavernaPlayer::Workflow", [:file, :title, :inputs])
|
38
41
|
|
39
42
|
# :call-seq:
|
43
|
+
# workflow_model_proxy = workflow_class
|
40
44
|
# workflow_model_proxy(workflow_class) {|proxy| ...}
|
41
45
|
#
|
42
46
|
# Set up a proxy to the main application's workflow model. The class name
|
@@ -48,6 +52,12 @@ module TavernaPlayer
|
|
48
52
|
yield @@workflow_proxy if block_given?
|
49
53
|
end
|
50
54
|
|
55
|
+
# :stopdoc:
|
56
|
+
def self.workflow_model_proxy=(workflow_class)
|
57
|
+
TavernaPlayer.workflow_model_proxy(workflow_class)
|
58
|
+
end
|
59
|
+
# :startdoc:
|
60
|
+
|
51
61
|
# This should be set to the name of the user model class in the main
|
52
62
|
# application via the user_model_proxy method below. Defaults to nil.
|
53
63
|
mattr_reader :user_proxy
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2014 The University of Manchester, UK.
|
3
|
+
#
|
4
|
+
# BSD Licenced. See LICENCE.rdoc for details.
|
5
|
+
#
|
6
|
+
# Taverna Player was developed in the BioVeL project, funded by the European
|
7
|
+
# Commission 7th Framework Programme (FP7), through grant agreement
|
8
|
+
# number 283359.
|
9
|
+
#
|
10
|
+
# Author: Robert Haines
|
11
|
+
#------------------------------------------------------------------------------
|
12
|
+
|
13
|
+
module TavernaPlayer
|
14
|
+
module Concerns
|
15
|
+
module Controllers
|
16
|
+
module WorkflowsController
|
17
|
+
|
18
|
+
extend ActiveSupport::Concern
|
19
|
+
|
20
|
+
included do
|
21
|
+
respond_to :html, :json
|
22
|
+
|
23
|
+
before_filter :find_workflows, :only => :index
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def find_workflows
|
28
|
+
@workflows = Workflow.all
|
29
|
+
end
|
30
|
+
|
31
|
+
end # included
|
32
|
+
|
33
|
+
# GET /workflows
|
34
|
+
def index
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -24,10 +24,10 @@ module TavernaPlayer
|
|
24
24
|
|
25
25
|
# Each run is spawned from a workflow. This provides the link to the
|
26
26
|
# workflow model in the parent app, whatever it calls its model.
|
27
|
-
belongs_to :workflow, :class_name => TavernaPlayer.workflow_proxy.class_name
|
27
|
+
belongs_to :workflow, :class_name => TavernaPlayer.workflow_proxy.class_name
|
28
28
|
|
29
29
|
unless TavernaPlayer.user_proxy.nil?
|
30
|
-
belongs_to :user, :class_name => TavernaPlayer.user_proxy.class_name
|
30
|
+
belongs_to :user, :class_name => TavernaPlayer.user_proxy.class_name
|
31
31
|
end
|
32
32
|
|
33
33
|
has_many :inputs, :class_name => "TavernaPlayer::RunPort::Input",
|
@@ -85,6 +85,7 @@ module TavernaPlayer
|
|
85
85
|
after_create :populate_child_inputs, :if => :has_parent?
|
86
86
|
after_create :enqueue
|
87
87
|
before_destroy :complete?
|
88
|
+
after_destroy :destroy_failed_delayed_jobs
|
88
89
|
|
89
90
|
private
|
90
91
|
|
@@ -110,7 +111,14 @@ module TavernaPlayer
|
|
110
111
|
def enqueue
|
111
112
|
worker = TavernaPlayer::Worker.new(self)
|
112
113
|
job = Delayed::Job.enqueue worker, :queue => TavernaPlayer.job_queue_name
|
113
|
-
|
114
|
+
|
115
|
+
self.delayed_job = job
|
116
|
+
self.status_message_key = "pending"
|
117
|
+
save
|
118
|
+
end
|
119
|
+
|
120
|
+
def destroy_failed_delayed_jobs
|
121
|
+
delayed_job.destroy unless delayed_job.nil?
|
114
122
|
end
|
115
123
|
|
116
124
|
end # included
|
@@ -137,22 +145,25 @@ module TavernaPlayer
|
|
137
145
|
#
|
138
146
|
# See the note above about the :cancelled state.
|
139
147
|
def cancel
|
140
|
-
return
|
148
|
+
return unless incomplete?
|
141
149
|
|
142
|
-
#
|
143
|
-
|
144
|
-
|
150
|
+
# Set the stop flag for all cases.
|
151
|
+
self.stop = true
|
152
|
+
|
153
|
+
# If the run has a delayed job and it hasn't been locked yet, or it
|
154
|
+
# has failed, then we just remove it from the queue directly and
|
155
|
+
# mark the run as cancelled.
|
145
156
|
unless delayed_job.nil?
|
146
157
|
delayed_job.with_lock do
|
147
|
-
if delayed_job.locked_by.nil?
|
158
|
+
if delayed_job.locked_by.nil? || !delayed_job.failed_at.nil?
|
148
159
|
delayed_job.destroy
|
149
|
-
|
150
|
-
|
160
|
+
self.state = :cancelled
|
161
|
+
self.status_message_key = "cancelled"
|
151
162
|
end
|
152
163
|
end
|
153
164
|
end
|
154
165
|
|
155
|
-
|
166
|
+
save
|
156
167
|
end
|
157
168
|
|
158
169
|
# Return state as a symbol. If a run is running, but has been asked to
|
@@ -181,6 +192,14 @@ module TavernaPlayer
|
|
181
192
|
I18n.t("taverna_player.status.#{key}")
|
182
193
|
end
|
183
194
|
|
195
|
+
def pending?
|
196
|
+
state == :pending
|
197
|
+
end
|
198
|
+
|
199
|
+
def initialized?
|
200
|
+
state == :initialized
|
201
|
+
end
|
202
|
+
|
184
203
|
def running?
|
185
204
|
state == :running
|
186
205
|
end
|
@@ -205,10 +224,19 @@ module TavernaPlayer
|
|
205
224
|
state == :failed
|
206
225
|
end
|
207
226
|
|
208
|
-
|
209
|
-
|
227
|
+
def job_failed?
|
228
|
+
!delayed_job.nil? && !delayed_job.failed_at.nil?
|
229
|
+
end
|
230
|
+
|
231
|
+
# This is used as a catch-all for pending?, initialized? and running?
|
232
|
+
def incomplete?
|
233
|
+
running? || pending? || initialized?
|
234
|
+
end
|
235
|
+
|
236
|
+
# This is used as a catch-all for finished, cancelled, failed,
|
237
|
+
# job_failed? and timeout
|
210
238
|
def complete?
|
211
|
-
finished? || cancelled? || failed? || timeout?
|
239
|
+
finished? || cancelled? || failed? || job_failed? || timeout?
|
212
240
|
end
|
213
241
|
|
214
242
|
def has_parent?
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2014 The University of Manchester, UK.
|
3
|
+
#
|
4
|
+
# BSD Licenced. See LICENCE.rdoc for details.
|
5
|
+
#
|
6
|
+
# Taverna Player was developed in the BioVeL project, funded by the European
|
7
|
+
# Commission 7th Framework Programme (FP7), through grant agreement
|
8
|
+
# number 283359.
|
9
|
+
#
|
10
|
+
# Author: Robert Haines
|
11
|
+
#------------------------------------------------------------------------------
|
12
|
+
|
13
|
+
module TavernaPlayer
|
14
|
+
module Concerns
|
15
|
+
module Models
|
16
|
+
module Workflow
|
17
|
+
|
18
|
+
extend ActiveSupport::Concern
|
19
|
+
|
20
|
+
included do
|
21
|
+
attr_accessible :author, :description, :file, :title
|
22
|
+
|
23
|
+
has_many :runs, :class_name => "TavernaPlayer::Run"
|
24
|
+
end # included
|
25
|
+
|
26
|
+
def inputs
|
27
|
+
workflow = File.open(file)
|
28
|
+
model = T2Flow::Parser.new.parse(workflow)
|
29
|
+
|
30
|
+
result = []
|
31
|
+
model.sources.each do |i|
|
32
|
+
description = i.descriptions.nil? ? "" : i.descriptions.join
|
33
|
+
example = i.example_values.nil? ? "" : i.example_values.join
|
34
|
+
result << { :name => i.name, :description => description,
|
35
|
+
:example => example }
|
36
|
+
end
|
37
|
+
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#------------------------------------------------------------------------------
|
2
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
2
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
3
3
|
#
|
4
4
|
# BSD Licenced. See LICENCE.rdoc for details.
|
5
5
|
#
|
@@ -15,21 +15,27 @@ module TavernaPlayer
|
|
15
15
|
attr_reader :class_name
|
16
16
|
|
17
17
|
def initialize(class_name, method_names = [])
|
18
|
-
|
19
|
-
begin
|
20
|
-
@class_name = Object.const_get(class_name)
|
21
|
-
rescue NameError
|
22
|
-
@class_name = class_name.constantize
|
23
|
-
end
|
24
|
-
end
|
18
|
+
@class_name = root_name(class_name.to_s)
|
25
19
|
|
26
20
|
method_names.each do |name|
|
27
21
|
add_method(name.to_sym)
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|
25
|
+
def class_const
|
26
|
+
@const ||= begin
|
27
|
+
Object.const_get(@class_name)
|
28
|
+
rescue NameError
|
29
|
+
@class_name.constantize
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
31
33
|
private
|
32
34
|
|
35
|
+
def root_name(name)
|
36
|
+
name.start_with?("::") ? name : "::#{name}"
|
37
|
+
end
|
38
|
+
|
33
39
|
def add_method(name)
|
34
40
|
setter = "#{name}_method_name=".to_sym
|
35
41
|
mapper = name
|
data/taverna_player.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.add_dependency "rails", "~> 3.2.12"
|
37
37
|
s.add_dependency "jquery-rails", "~> 3.0"
|
38
38
|
s.add_dependency "paperclip", "~> 4.1"
|
39
|
+
s.add_dependency "taverna-t2flow", "~> 0.5.1"
|
39
40
|
s.add_dependency "t2-server", "~> 1.1"
|
40
41
|
s.add_dependency "delayed_job_active_record", "~> 4.0"
|
41
42
|
s.add_dependency "daemons", "~> 1.1.9"
|
@@ -26,7 +26,7 @@
|
|
26
26
|
<br />
|
27
27
|
|
28
28
|
<%= link_to "Home", main_app.root_path %> |
|
29
|
-
<%= link_to "Workflows",
|
29
|
+
<%= link_to "Workflows", taverna_player.workflows_path %> |
|
30
30
|
<%= link_to "Runs", taverna_player.runs_path %> |
|
31
31
|
<%= link_to "Service Credentials", taverna_player.service_credentials_path %> |
|
32
32
|
<%= link_to "Job Queue", taverna_player.job_queue_path %>
|
@@ -13,11 +13,8 @@
|
|
13
13
|
# Taverna Player configuration
|
14
14
|
|
15
15
|
TavernaPlayer.setup do |config|
|
16
|
-
config.workflow_model_proxy("Workflow") do |proxy|
|
17
|
-
proxy.file_method_name = :file
|
18
|
-
end
|
19
16
|
config.user_model_proxy = "User"
|
20
|
-
config.current_user_callback = Proc.new { User.
|
17
|
+
config.current_user_callback = Proc.new { User.first }
|
21
18
|
|
22
19
|
# Move admin resources into their own namespace.
|
23
20
|
config.admin_scope = "admin"
|
data/test/dummy/config/routes.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#------------------------------------------------------------------------------
|
2
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
2
|
+
# Copyright (c) 2013, 2014 The University of Manchester, UK.
|
3
3
|
#
|
4
4
|
# BSD Licenced. See LICENCE.rdoc for details.
|
5
5
|
#
|
@@ -11,12 +11,6 @@
|
|
11
11
|
#------------------------------------------------------------------------------
|
12
12
|
|
13
13
|
Rails.application.routes.draw do
|
14
|
-
|
15
14
|
root :to => "home#index"
|
16
|
-
|
17
|
-
resources :workflows, :only => :index do
|
18
|
-
resources :runs, :controller => "TavernaPlayer::Runs", :except => :edit
|
19
|
-
end
|
20
|
-
|
21
15
|
mount TavernaPlayer::Engine, :at => "/"
|
22
16
|
end
|