taverna-player 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +18 -0
  3. data/LICENCE.rdoc +29 -0
  4. data/README.rdoc +663 -0
  5. data/Rakefile +65 -0
  6. data/app/assets/javascripts/taverna_player/application.js +14 -0
  7. data/app/assets/javascripts/taverna_player/runs.js +42 -0
  8. data/app/assets/stylesheets/scaffold.css +56 -0
  9. data/app/assets/stylesheets/taverna_player/application.css +13 -0
  10. data/app/assets/stylesheets/taverna_player/coderay.css +120 -0
  11. data/app/controllers/taverna_player/application_controller.rb +16 -0
  12. data/app/controllers/taverna_player/runs_controller.rb +18 -0
  13. data/app/controllers/taverna_player/service_credentials_controller.rb +18 -0
  14. data/app/helpers/taverna_player/application_helper.rb +55 -0
  15. data/app/helpers/taverna_player/runs_helper.rb +84 -0
  16. data/app/models/taverna_player/interaction.rb +25 -0
  17. data/app/models/taverna_player/run.rb +117 -0
  18. data/app/models/taverna_player/run_port.rb +148 -0
  19. data/app/models/taverna_player/service_credential.rb +56 -0
  20. data/app/views/layouts/taverna_player/embedded.html.erb +27 -0
  21. data/app/views/taverna_player/runs/_button.html.erb +19 -0
  22. data/app/views/taverna_player/runs/_info.html.erb +56 -0
  23. data/app/views/taverna_player/runs/_info.json.jbuilder +2 -0
  24. data/app/views/taverna_player/runs/_inputs.html.erb +34 -0
  25. data/app/views/taverna_player/runs/_inputs.json.jbuilder +8 -0
  26. data/app/views/taverna_player/runs/_interaction.html.erb +68 -0
  27. data/app/views/taverna_player/runs/_outputs.html.erb +41 -0
  28. data/app/views/taverna_player/runs/_poll.html.erb +27 -0
  29. data/app/views/taverna_player/runs/create.json.jbuilder +3 -0
  30. data/app/views/taverna_player/runs/embedded/_button.html.erb +19 -0
  31. data/app/views/taverna_player/runs/embedded/_info.html.erb +25 -0
  32. data/app/views/taverna_player/runs/embedded/_inputs.html.erb +32 -0
  33. data/app/views/taverna_player/runs/embedded/_outputs.html.erb +32 -0
  34. data/app/views/taverna_player/runs/embedded/new.html.erb +58 -0
  35. data/app/views/taverna_player/runs/embedded/show.html.erb +39 -0
  36. data/app/views/taverna_player/runs/embedded/show.js.erb +35 -0
  37. data/app/views/taverna_player/runs/index.html.erb +40 -0
  38. data/app/views/taverna_player/runs/index.json.jbuilder +1 -0
  39. data/app/views/taverna_player/runs/new.html.erb +56 -0
  40. data/app/views/taverna_player/runs/new.json.jbuilder +1 -0
  41. data/app/views/taverna_player/runs/show.html.erb +29 -0
  42. data/app/views/taverna_player/runs/show.js.erb +25 -0
  43. data/app/views/taverna_player/runs/show.json.jbuilder +25 -0
  44. data/app/views/taverna_player/service_credentials/_form.html.erb +53 -0
  45. data/app/views/taverna_player/service_credentials/edit.html.erb +18 -0
  46. data/app/views/taverna_player/service_credentials/index.html.erb +41 -0
  47. data/app/views/taverna_player/service_credentials/new.html.erb +17 -0
  48. data/app/views/taverna_player/service_credentials/show.html.erb +36 -0
  49. data/config/routes.rb +34 -0
  50. data/db/migrate/20130313105546_create_taverna_player_runs.rb +16 -0
  51. data/db/migrate/20130315163019_create_taverna_player_run_ports.rb +15 -0
  52. data/db/migrate/20130318170744_add_attachment_file_to_taverna_player_run_ports.rb +6 -0
  53. data/db/migrate/20130319183634_create_delayed_jobs.rb +22 -0
  54. data/db/migrate/20130320102600_add_status_message_to_taverna_player_runs.rb +5 -0
  55. data/db/migrate/20130321100110_add_depth_and_metadata_to_taverna_player_run_ports.rb +6 -0
  56. data/db/migrate/20130704095504_add_attachment_results_to_taverna_player_runs.rb +5 -0
  57. data/db/migrate/20130705142704_add_embedded_to_taverna_player_runs.rb +5 -0
  58. data/db/migrate/20130714140911_create_taverna_player_interactions.rb +13 -0
  59. data/db/migrate/20130717083653_add_proxy_to_taverna_player_runs.rb +6 -0
  60. data/db/migrate/20130717155415_add_stop_to_taverna_player_runs.rb +5 -0
  61. data/db/migrate/20130811152840_add_attachment_log_to_taverna_player_runs.rb +5 -0
  62. data/db/migrate/20130811211725_change_taverna_player_runs_state_column.rb +5 -0
  63. data/db/migrate/20130812155839_add_name_to_taverna_player_runs.rb +5 -0
  64. data/db/migrate/20130918135348_create_taverna_player_service_credentials.rb +15 -0
  65. data/db/migrate/20130919154200_add_displayed_to_taverna_player_interactions.rb +5 -0
  66. data/db/migrate/20131007153209_add_job_ref_to_taverna_player_runs.rb +13 -0
  67. data/db/migrate/20131010094537_add_reply_caching_to_taverna_player_interactions.rb +19 -0
  68. data/db/migrate/20131017141514_add_failure_message_to_taverna_player_run.rb +5 -0
  69. data/db/migrate/20131018152940_add_serial_number_to_taverna_player_interactions.rb +5 -0
  70. data/db/migrate/20131018160715_add_parent_run_id_to_taverna_player_runs.rb +5 -0
  71. data/db/migrate/20131102113933_add_page_uri_to_taverna_player_interaction.rb +5 -0
  72. data/db/migrate/20131105115218_remove_proxy_from_taverna_player_runs.rb +11 -0
  73. data/db/migrate/20131105141934_change_taverna_player_interactions_output_value_column_name.rb +5 -0
  74. data/db/migrate/20131112165520_add_user_to_taverna_player_run.rb +5 -0
  75. data/lib/generators/taverna_player/callbacks_generator.rb +25 -0
  76. data/lib/generators/taverna_player/controllers_generator.rb +30 -0
  77. data/lib/generators/taverna_player/install_generator.rb +30 -0
  78. data/lib/generators/taverna_player/job_generator.rb +26 -0
  79. data/lib/generators/taverna_player/models_generator.rb +27 -0
  80. data/lib/generators/taverna_player/renderers_generator.rb +26 -0
  81. data/lib/generators/taverna_player/views_generator.rb +27 -0
  82. data/lib/generators/templates/ReadMe.txt +118 -0
  83. data/lib/generators/templates/callbacks/render_callbacks.rb +56 -0
  84. data/lib/generators/templates/callbacks/worker_callbacks.rb +31 -0
  85. data/lib/generators/templates/controllers/runs_controller.rb +20 -0
  86. data/lib/generators/templates/controllers/service_credentials_controller.rb +20 -0
  87. data/lib/generators/templates/initializer.rb +154 -0
  88. data/lib/generators/templates/models/run.rb +20 -0
  89. data/lib/tasks/delete-cancelled-runs.rake +26 -0
  90. data/lib/tasks/delete-old-embedded-runs.rake +26 -0
  91. data/lib/taverna-player.rb +139 -0
  92. data/lib/taverna_player/concerns/controllers/runs_controller.rb +281 -0
  93. data/lib/taverna_player/concerns/controllers/service_credentials_controller.rb +89 -0
  94. data/lib/taverna_player/concerns/models/run.rb +205 -0
  95. data/lib/taverna_player/engine.rb +23 -0
  96. data/lib/taverna_player/model_proxy.rb +51 -0
  97. data/lib/taverna_player/output_renderer.rb +96 -0
  98. data/lib/taverna_player/render_callbacks.rb +41 -0
  99. data/lib/taverna_player/version.rb +15 -0
  100. data/lib/taverna_player/worker.rb +325 -0
  101. data/script/delayed_job +5 -0
  102. data/script/rails +8 -0
  103. data/taverna_player.gemspec +46 -0
  104. data/test/dummy/Rakefile +7 -0
  105. data/test/dummy/app/assets/javascripts/application.js +16 -0
  106. data/test/dummy/app/assets/stylesheets/application.css +14 -0
  107. data/test/dummy/app/controllers/application_controller.rb +15 -0
  108. data/test/dummy/app/controllers/home_controller.rb +16 -0
  109. data/test/dummy/app/controllers/taverna_player/runs_controller.rb +25 -0
  110. data/test/dummy/app/controllers/taverna_player/service_credentials_controller.rb +25 -0
  111. data/test/dummy/app/controllers/workflows_controller.rb +17 -0
  112. data/test/dummy/app/models/user.rb +15 -0
  113. data/test/dummy/app/models/workflow.rb +32 -0
  114. data/test/dummy/app/views/home/index.html.erb +18 -0
  115. data/test/dummy/app/views/layouts/application.html.erb +43 -0
  116. data/test/dummy/app/views/workflows/index.html.erb +35 -0
  117. data/test/dummy/config.ru +4 -0
  118. data/test/dummy/config/application.rb +58 -0
  119. data/test/dummy/config/boot.rb +10 -0
  120. data/test/dummy/config/database.yml +25 -0
  121. data/test/dummy/config/environment.rb +5 -0
  122. data/test/dummy/config/environments/development.rb +37 -0
  123. data/test/dummy/config/environments/production.rb +67 -0
  124. data/test/dummy/config/environments/test.rb +37 -0
  125. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  126. data/test/dummy/config/initializers/inflections.rb +15 -0
  127. data/test/dummy/config/initializers/mime_types.rb +5 -0
  128. data/test/dummy/config/initializers/secret_token.rb +7 -0
  129. data/test/dummy/config/initializers/session_store.rb +8 -0
  130. data/test/dummy/config/initializers/taverna_player.example.rb +40 -0
  131. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  132. data/test/dummy/config/locales/en.yml +5 -0
  133. data/test/dummy/config/routes.rb +22 -0
  134. data/test/dummy/db/migrate/20130314103555_create_workflows.rb +12 -0
  135. data/test/dummy/db/migrate/20130318141557_create_taverna_player_runs.taverna_player.rb +17 -0
  136. data/test/dummy/db/migrate/20130318141558_create_taverna_player_run_ports.taverna_player.rb +16 -0
  137. data/test/dummy/db/migrate/20130318173013_add_attachment_file_to_taverna_player_run_ports.taverna_player.rb +7 -0
  138. data/test/dummy/db/migrate/20130319183816_create_delayed_jobs.taverna_player.rb +23 -0
  139. data/test/dummy/db/migrate/20130320102635_add_status_message_to_taverna_player_runs.taverna_player.rb +6 -0
  140. data/test/dummy/db/migrate/20130321161859_add_depth_and_metadata_to_taverna_player_run_ports.taverna_player.rb +7 -0
  141. data/test/dummy/db/migrate/20130704100146_add_attachment_results_to_taverna_player_runs.taverna_player.rb +6 -0
  142. data/test/dummy/db/migrate/20130705142816_add_embedded_to_taverna_player_runs.taverna_player.rb +6 -0
  143. data/test/dummy/db/migrate/20130714142144_create_taverna_player_interactions.taverna_player.rb +14 -0
  144. data/test/dummy/db/migrate/20130717084809_add_proxy_to_taverna_player_runs.taverna_player.rb +7 -0
  145. data/test/dummy/db/migrate/20130718102707_add_stop_to_taverna_player_runs.taverna_player.rb +6 -0
  146. data/test/dummy/db/migrate/20130811204449_add_attachment_log_to_taverna_player_runs.taverna_player.rb +6 -0
  147. data/test/dummy/db/migrate/20130811212709_change_taverna_player_runs_state_column.taverna_player.rb +6 -0
  148. data/test/dummy/db/migrate/20130812161152_add_name_to_taverna_player_runs.taverna_player.rb +6 -0
  149. data/test/dummy/db/migrate/20130918155525_create_taverna_player_service_credentials.taverna_player.rb +16 -0
  150. data/test/dummy/db/migrate/20130919155202_add_displayed_to_taverna_player_interactions.taverna_player.rb +6 -0
  151. data/test/dummy/db/migrate/20131007153659_add_job_ref_to_taverna_player_runs.taverna_player.rb +14 -0
  152. data/test/dummy/db/migrate/20131016123941_add_reply_caching_to_taverna_player_interactions.taverna_player.rb +20 -0
  153. data/test/dummy/db/migrate/20131017141614_add_failure_message_to_taverna_player_run.taverna_player.rb +6 -0
  154. data/test/dummy/db/migrate/20131018153316_add_serial_number_to_taverna_player_interactions.taverna_player.rb +6 -0
  155. data/test/dummy/db/migrate/20131018164614_add_parent_run_id_to_taverna_player_runs.taverna_player.rb +6 -0
  156. data/test/dummy/db/migrate/20131102114343_add_page_uri_to_taverna_player_interaction.taverna_player.rb +6 -0
  157. data/test/dummy/db/migrate/20131105115724_remove_proxy_from_taverna_player_runs.taverna_player.rb +12 -0
  158. data/test/dummy/db/migrate/20131105142417_change_taverna_player_interactions_output_value_column_name.taverna_player.rb +6 -0
  159. data/test/dummy/db/migrate/20131112165815_add_user_to_taverna_player_run.taverna_player.rb +6 -0
  160. data/test/dummy/db/migrate/20131114130937_create_users.rb +10 -0
  161. data/test/dummy/db/schema.rb +123 -0
  162. data/test/dummy/lib/callbacks.rb +35 -0
  163. data/test/dummy/log/.gitkeep +0 -0
  164. data/test/dummy/public/404.html +26 -0
  165. data/test/dummy/public/422.html +26 -0
  166. data/test/dummy/public/500.html +25 -0
  167. data/test/dummy/public/favicon.ico +0 -0
  168. data/test/dummy/script/delayed_job +5 -0
  169. data/test/dummy/script/rails +6 -0
  170. data/test/dummy/test/functional/home_controller_test.rb +28 -0
  171. data/test/dummy/test/functional/workflows_controller_test.rb +21 -0
  172. data/test/fixtures/files/crassostrea_gigas.csv +737 -0
  173. data/test/fixtures/taverna_player/interactions.yml +32 -0
  174. data/test/fixtures/taverna_player/run_ports.yml +54 -0
  175. data/test/fixtures/taverna_player/runs.yml +69 -0
  176. data/test/fixtures/taverna_player/service_credentials.yml +25 -0
  177. data/test/fixtures/users.yml +16 -0
  178. data/test/fixtures/workflows.yml +32 -0
  179. data/test/functional/taverna_player/runs_controller_test.rb +316 -0
  180. data/test/functional/taverna_player/service_credentials_controller_test.rb +99 -0
  181. data/test/taverna_player_test.rb +25 -0
  182. data/test/test_helper.rb +33 -0
  183. data/test/unit/helpers/taverna_player/application_helper_test.rb +70 -0
  184. data/test/unit/helpers/taverna_player/runs_helper_test.rb +45 -0
  185. data/test/unit/taverna_player/interaction_test.rb +47 -0
  186. data/test/unit/taverna_player/run_port_test.rb +309 -0
  187. data/test/unit/taverna_player/run_test.rb +196 -0
  188. data/test/unit/taverna_player/service_credential_test.rb +64 -0
  189. data/test/workflows/hello.t2flow +164 -0
  190. data/test/workflows/list_with_errors.t2flow +107 -0
  191. data/test/workflows/pass_through.t2flow +12 -0
  192. metadata +539 -0
@@ -0,0 +1,18 @@
1
+ Gemfile.lock
2
+ .bundle/
3
+ log/*.log
4
+ pkg/
5
+ test/dummy/db/*.sqlite3
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ test/dummy/.sass-cache
9
+ test/dummy/public/system/
10
+ test/dummy/config/initializers/taverna_player.rb
11
+
12
+ *~
13
+ rdoc/
14
+ .buildpath
15
+ .project
16
+ .settings
17
+ .idea
18
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in taverna_player.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # These gems are used by the dummy application
9
+ gem "jquery-rails"
10
+ gem "taverna-t2flow", "~> 0.4.5"
11
+
12
+ # Declare any dependencies that are still in development here instead of in
13
+ # your gemspec. These might include edge Rails or gems from your path or
14
+ # Git. Remember to move these dependencies to your gemspec before releasing
15
+ # your gem to rubygems.org.
16
+
17
+ # To use debugger
18
+ # gem 'debugger'
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2013 The University of Manchester, UK.
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice,
9
+ this list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ * Neither the names of The University of Manchester nor the names of its
16
+ contributors may be used to endorse or promote products derived from this
17
+ software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,663 @@
1
+ = Taverna Player
2
+
3
+ Authors:: Robert Haines
4
+ Contact:: mailto:support@mygrid.org.uk
5
+ URL:: http://www.taverna.org.uk
6
+ Licence:: BSD (See LICENCE or http://www.opensource.org/licenses/bsd-license.php)
7
+ Copyright:: (c) 2013 The University of Manchester, UK
8
+
9
+ {<img src="https://codeclimate.com/github/myGrid/taverna-player.png" />}[https://codeclimate.com/github/myGrid/taverna-player]
10
+
11
+ == Synopsis
12
+
13
+ Taverna Player is a Ruby on Rails plugin to run Taverna workflows on a Taverna
14
+ Server.
15
+
16
+ Taverna Player handles all aspects of running a workflow including:
17
+ * Gathering inputs and upload to Taverna Server
18
+ * Monitoring the run
19
+ * Presenting workflow interactions to the user
20
+ * Gathering and download of workflow outputs
21
+
22
+ It, purposefully, does not:
23
+ * Manage workflows
24
+ * Manage users
25
+
26
+ == Getting started
27
+
28
+ These instructions assume that you are familiar with Rails and its concepts.
29
+ Also, knowledge of {Rails Engines}[http://guides.rubyonrails.org/engines.html]
30
+ and how they integrate with other Rails applications will be useful.
31
+
32
+ Taverna Player works with Rails 3.2. Add it to your Gemfile with:
33
+ gem "taverna-player"
34
+
35
+ And run the <tt>bundle install</tt> command to install it.
36
+
37
+ Next you need to run the install generator:
38
+ rails generate taverna_player:install
39
+
40
+ This installs an initializer (into your application's
41
+ <tt>config/initializers</tt> directory) which describes all of Taverna Player's
42
+ configuration options and there are some things that MUST be configured before
43
+ it will work - see below for more information. The install generator also
44
+ prints out a list of other steps for setting up Taverna Player; these are
45
+ repeated and detailed below.
46
+
47
+ == Running Taverna Player
48
+
49
+ Once you have Taverna Player installed and configured in your Rails application
50
+ it will largely take care of itself. The nature of Rails Engines is that they
51
+ become part of the containing application relatively seamlessly.
52
+
53
+ The only extra step required for full operation of Taverna Player is to start
54
+ the delayed_job script so that workflows are actually run. Even if you already
55
+ use delayed_job in your application it is worth checking this section because
56
+ Taverna Player uses its own named queue to run jobs.
57
+
58
+ === In development
59
+
60
+ If you simply want to have a single worker running while testing then you can
61
+ use the rake task supplied by delayed_job:
62
+
63
+ rake jobs:work
64
+
65
+ === In production
66
+
67
+ In production you will want to run lots of workers for maximum throughput. A
68
+ good starting number of concurrent workers will probably be the number of
69
+ workflows that your Taverna Server can run at the same time. Any lower than
70
+ this and you are not running Taverna Server at its configured capacity; any
71
+ higher and you just end up with workers waiting for Taverna Server to have
72
+ space for them anyway. You might pick up some efficiencies starting new
73
+ workflow runs while the results of those just finished are being collected but
74
+ it is probably not worth having more than one or two extra workers for this.
75
+
76
+ So if your Taverna Server can run 20 concurrent workflows at once then you
77
+ would start your workers like this:
78
+
79
+ RAILS_ENV=production bundle exec ./script/delayed_job -n 20 --queue=player start
80
+
81
+ See the documentation for {delayed_job}[https://rubygems.org/gems/delayed_job]
82
+ for more options and information.
83
+
84
+ == Hooking Taverna Player into your Rails application
85
+
86
+ Mount the Taverna Player engine in your <tt>config/routes.rb</tt>. For example:
87
+
88
+ mount TavernaPlayer::Engine, :at => "/"
89
+
90
+ You can also nest the Taverna Player runs resources within your workflows
91
+ resources if you wish, like this:
92
+
93
+ resources :workflows do
94
+ resources :runs, :controller => "TavernaPlayer::Runs", :except => :edit
95
+ end
96
+
97
+ The runs resources in Taverna Player do not provide an edit view by default
98
+ so, unless you add it yourself by overriding the controller you should add the
99
+ <tt>:except</tt> clause to the routes.
100
+
101
+ Perform Taverna Player's migrations:
102
+
103
+ rake taverna_player:install:migrations
104
+ rake db:migrate
105
+
106
+ Make sure you have defined root_url to something in your
107
+ <tt>config/routes.rb</tt>. For example:
108
+
109
+ root :to => "home#index"
110
+
111
+ Add Taverna Player's assets to your application's manifests.
112
+
113
+ In app/assets/javascripts/application.js:
114
+
115
+ //= require taverna_player/application
116
+
117
+ In app/assets/stylesheets/application.css
118
+
119
+ *= require taverna_player/application
120
+
121
+ And everything should be found by the asset pipeline automatically.
122
+
123
+ Make sure you have flash messages in your main layout
124
+ (usually <tt>app/views/layouts/application.html.erb</tt>). For example:
125
+
126
+ <p class="notice"><%= notice %></p>
127
+ <p class="alert"><%= alert %></p>
128
+
129
+ Taverna Player uses delayed_job to run workflows on a Taverna Server. If your
130
+ application is not already using delayed_job then you can install the
131
+ delayed_job script in your <tt>script</tt> directory with:
132
+
133
+ rails generate taverna_player:job
134
+
135
+ Taverna Player comes with some very simple, unstyled views and layouts. If you
136
+ wish to override these with your own customized views you can copy them into
137
+ your application with:
138
+
139
+ rails generate taverna_player:views
140
+
141
+ The views are copied to the <tt>app/views/taverna_player</tt> directory so that
142
+ they take precedence over the default ones. You can delete any that you do not
143
+ need to customize but there are no penalties for leaving them there. There is
144
+ more information on overriding views below.
145
+
146
+ If you need to override the Taverna Player controllers, to implement user
147
+ authorization for example, you can copy some customizable stubs with:
148
+
149
+ rails generate taverna_player:controllers
150
+
151
+ The stubs are copied to the <tt>app/controllers/taverna_player</tt> directory
152
+ so that they take precedence over the default ones. You can delete any that you
153
+ do not need to customize but there are no penalties for leaving them there.
154
+ There is more information on overriding controllers below.
155
+
156
+ If you need to override the Taverna Player Run model, to add columns to the
157
+ table for example, you can copy a customizable stub with:
158
+
159
+ rails generate taverna_player:models
160
+
161
+ The stub is copied to the <tt>app/models/taverna_player</tt> directory so that
162
+ it takes precedence over the default one. There is more information on
163
+ overriding models below.
164
+
165
+ If you want to use pre- and post-run callbacks you can setup some basic stubs
166
+ with:
167
+
168
+ rails generate taverna_player:callbacks
169
+
170
+ They will be saved to <tt>lib/taverna_player_callbacks.rb</tt>. Don't forget to
171
+ then require and register them in the Taverna Player initializer. There is more
172
+ information on callbacks below.
173
+
174
+ You can add to, or change, the workflow run outputs render methods to better
175
+ suit your particular application. To copy the defaults that Taverna Player
176
+ ships with into your application for customization run:
177
+
178
+ rails generate taverna_player:renderers
179
+
180
+ They will be saved to <tt>lib/taverna_player_renderers.rb</tt>. Don't forget to
181
+ then require and register them in the Taverna Player initializer. There is more
182
+ information on renderers below.
183
+
184
+ == Taverna Player initializer
185
+
186
+ The {default initializer}[https://github.com/myGrid/taverna-player/blob/master/lib/generators/templates/initializer.rb]
187
+ that is installed by the install generator requires minimal configuration for
188
+ simple set ups. It is fully commented with everything that needs to be set but
189
+ further explanations are given below.
190
+
191
+ === Essential (required) configuration
192
+
193
+ Firstly, Taverna Player needs to know what the model is that represents
194
+ workflows within your application and it needs to know how to get a workflow
195
+ file out of that model so it can run it. If your workflow model is called
196
+ "Workflow" and the method to get the workflow filename from that model is
197
+ called "file_name" then the following will configure this correctly:
198
+
199
+ config.workflow_model_proxy("Workflow") do |proxy|
200
+ proxy.file_method_name = :file_name
201
+ end
202
+
203
+ Secondly, Taverna Player needs to know where your Taverna Server is and how to
204
+ authenticate to it:
205
+
206
+ config.server_address = "http://localhost:8080/taverna"
207
+ config.server_username = "taverna"
208
+ config.server_password = "taverna"
209
+
210
+ Make sure you do not commit this information into your repository!
211
+
212
+ This should usually be enough to get Taverna Player up and running within your
213
+ application but there are lots of other configuration options detailed below.
214
+
215
+ === Optional configuration
216
+
217
+ ==== Taverna Server
218
+
219
+ There are two settings to control how often Taverna Player communicates with
220
+ Taverna Server:
221
+
222
+ config.server_poll_interval = 5
223
+ config.server_retry_interval = 10
224
+
225
+ The first specifies, in seconds, how often <em>each run</em> is polled. Polling
226
+ is used to check a run's status (has it finished yet?) and check for
227
+ interactions. If you have long running workflows then it is probably worth
228
+ setting this value higher; If you have lots of interactions then keeping it low
229
+ is good to improve the responsiveness for users. Keep in mind that as polling
230
+ is for each run then setting this value very low will produce a lot of polling
231
+ requests when you have lots of running workflows.
232
+
233
+ The second specifies, in seconds, how long to wait before retrying an operation
234
+ that Taverna Server has rejected due to its current load. This can happen in
235
+ two places:
236
+ * Creating the run. Each Taverna Server has a limit (usually quite high) to
237
+ how many workflow runs it can support at a time - this is the entire set of
238
+ runs resident on the server in any state (initialized, running or finished).
239
+ If it is at this limit then it will refuse requests to create any more.
240
+ * Starting the run. Each Taverna Server also has a limit to how many workflow
241
+ runs it can have actually running at once - runs that are yet to start, or
242
+ that have finished do not count towards this total. If it is at this limit
243
+ then it will refuse requests to start any more.
244
+ Neither of these situations are fatal errors however, so Taverna Player will
245
+ back off for the specified time and then try again. It is worth tailoring this
246
+ number to the sort of workflows you will be running. For long-running,
247
+ batch-style workflows then it can be set quite high but if you have workflows
248
+ that make use of interactions (so you have users watching the workflows
249
+ running) then it should probably be set lower.
250
+
251
+ There are a number of options for configuring the connection to the Taverna
252
+ Server. These are actually provided by the underlying
253
+ {t2-server client library}[https://rubygems.org/gems/t2-server] and surfaced
254
+ here for extra control. They are
255
+ {documented in more detail}[http://mygrid.github.io/t2-server-gem/] elsewhere
256
+ but broadly fall into two categories: Security and timeouts.
257
+
258
+ The following are all concerned with connecting to a secure Taverna Server and
259
+ will be set to your Ruby/OS defaults if you leave them alone. If you use a
260
+ self-signed certificate for your server, or you require client certificate
261
+ authentication you will need to edit them appropriately.
262
+
263
+ config.server_connection[:verify_peer] = true
264
+ config.server_connection[:ca_file] = "/etc/certs/my-cert.crt"
265
+ config.server_connection[:ca_path] = "/etc/certs/"
266
+ config.server_connection[:client_certificate] = "client-cert.crt"
267
+ config.server_connection[:client_password] = "P@5$w0Rd!"
268
+ config.server_connection[:ssl_version] = :TLSv1
269
+
270
+ The following are timeout options and should be set with care. The underlying
271
+ operating system defaults (usually 300 seconds each) will be used if they are
272
+ not set explicitly.
273
+
274
+ config.server_connection[:open_timeout] = 300
275
+ config.server_connection[:read_timeout] = 300
276
+
277
+ ==== Users
278
+
279
+ If your application has users then there is some basic support for that
280
+ out-of-the-box in Taverna Player. You can tell Taverna Player what your user
281
+ model is called with (example "User" here):
282
+
283
+ config.user_model_proxy = "User"
284
+
285
+ And you can tell it how to discover who your current user is by specifying a
286
+ callback. If you are using {Devise}[https://rubygems.org/gems/devise]
287
+ (recommended) for your authentication then you would supply the provided
288
+ "current_user" method like this:
289
+
290
+ config.current_user_callback = :current_user
291
+
292
+ With this set up then when a run is created Taverna Player will set the owner
293
+ of that run to be the current logged in user if there is one.
294
+
295
+ Note that this does not automatically mean that Taverna Player is checking that
296
+ users are authenticated! If you require this or if you have more complex
297
+ requirements then you will need to override the Run model and the Runs
298
+ controller. See below for more details.
299
+
300
+ ==== Files
301
+
302
+ Taverna Player needs to store various files for each run's inputs and outputs.
303
+ The {paperclip}[https://rubygems.org/gems/paperclip] gem is used to provide
304
+ these facilities and the only configuration required is to specify where you
305
+ want it to store its files:
306
+
307
+ config.file_store = ":rails_root/public/system"
308
+
309
+ Use ":rails_root" for the root of your application, or specify a full path for
310
+ anywhere else.
311
+
312
+ ==== Run callbacks and renderers
313
+
314
+ These are described in their own sections, below.
315
+
316
+ == Overriding the default views
317
+
318
+ If you use the generator, described above, to copy the views into your
319
+ application they will be used in preference to the default ones. This means
320
+ that any changes you make will be immediately reflected in the output of your
321
+ application. See the
322
+ {Rails documentation}[http://guides.rubyonrails.org/engines.html#overriding-views]
323
+ for more information on overriding views.
324
+
325
+ The supplied views provide a good example of how to maintain a current view of
326
+ the state of a run and handle any workflow interactions that may occur during
327
+ a run. It is worth understanding how they work before pulling them apart for
328
+ your own needs.
329
+
330
+ == Overriding the default models and controllers
331
+
332
+ You can override the following core components:
333
+ * Run (model)
334
+ * RunsController
335
+ * ServiceCredentialsController
336
+
337
+ Use the generators, detailed above, to create stubs for you to expand. These
338
+ components have been designed for overriding with the decorator pattern using
339
+ {ActiveSupport::Concern}[http://api.rubyonrails.org/classes/ActiveSupport/Concern.html].
340
+ This allows for things to be overridden but still have the same name (as is
341
+ required for such things within Rails). Please also see the information about
342
+ overriding models and controllers in the
343
+ {Rails documentation}[http://guides.rubyonrails.org/engines.html#overriding-models-and-controllers].
344
+
345
+ The vitally important thing is to preserve the +include+ statement within your
346
+ overriding code. For example, the RunsController stub looks like this:
347
+
348
+ module TavernaPlayer
349
+ class RunsController < TavernaPlayer::ApplicationController
350
+ # Do not remove the next line.
351
+ include TavernaPlayer::Concerns::Controllers::RunsController
352
+
353
+ # Extend the RunsController here.
354
+ end
355
+ end
356
+
357
+ You can add code both before and after the +include+ statement but anything
358
+ before it might be overridden by the original code itself if there are name
359
+ clashes.
360
+
361
+ If you wanted to add a before filter to authenticate your users you would add
362
+ that line before the +include+ statement, for example.
363
+
364
+ == Run callbacks
365
+
366
+ Taverna Player provides four points around a workflow run for you to specify
367
+ callbacks to be run:
368
+ * Pre-run: This is called directly before Taverna Server is contacted.
369
+ * Post-run: This is called after all operations on Taverna Server have been
370
+ completed when the run finishes normally.
371
+ * Run-cancelled: This is called after all operations on Taverna Server have
372
+ been completed when the run has been cancelled by the user.
373
+ * Run-failed: This is called after all operations on Taverna Server have been
374
+ completed when the run has failed.
375
+
376
+ Each of these callbacks is provided with the current run object as its
377
+ parameter and can be set in the initializer by providing the name of the method
378
+ (string or symbol) to run or a Proc object:
379
+
380
+ config.pre_run_callback = :player_pre_run_callback
381
+ config.post_run_callback = "player_post_run_callback"
382
+ config.run_cancelled_callback = Proc.new { |run| puts "Cancelled: #{run.name}" }
383
+ config.run_failed_callback = :player_run_failed_callback
384
+
385
+ *Important!* If your callback fails then the run itself will "fail". This may
386
+ or may not matter for the run-failed callback but if your pre-run callback
387
+ fails then the run will never get to Taverna Server! How can it? Your pre-run
388
+ callback may have been setting up vital resources for your run; Taverna Player
389
+ can not second-guess this so "fails" the run.
390
+
391
+ For this reason it is not recommended to put a lot of complex functionality
392
+ into the callbacks. An ideal use would be to gather statistics from the run
393
+ (average time, how many times a user runs it, etc) once it has finished.
394
+
395
+ An example callback that just prints out the run's name and workflow id would
396
+ be:
397
+
398
+ def player_run_callback(run)
399
+ w = Workflow.find(run.workflow_id)
400
+ puts "Callback called for run '#{run.name}' of workflow '#{w.id}'"
401
+ end
402
+
403
+ A set of example callbacks can be installed with the generator detailed above.
404
+ Don't forget to make sure any callback code is <tt>require</tt>d somewhere and
405
+ the callbacks themselves registered in the initializer.
406
+
407
+ == Rendering outputs
408
+
409
+ Workflows can produce results in many different formats and Taverna Player
410
+ tries to accomodate this as best it can. It provides basic facilities for
411
+ rendering as many result types as it can and these are extendible wherever
412
+ possible.
413
+
414
+ === Output helper
415
+
416
+ A very basic output helper is provided, <tt>show_output</tt>, which can be
417
+ used in your views. This will format the output of each workflow output port in
418
+ a generic way. If it is a singleton output then it is displayed normally. If it
419
+ is a list output then the list is rendered as a HTML ordered list
420
+ (<tt><ol></tt>).
421
+
422
+ If you require anything more complex then you will have to override this helper
423
+ or provide your own and call it from your views.
424
+
425
+ === Type renderers
426
+
427
+ Taverna Player has a system of specific type renderers to handle different
428
+ types of output. A number of defaults are supplied but these can be replaced
429
+ and added to if required.
430
+
431
+ To install a set of example renderers you can use the generator detailed above.
432
+
433
+ To register a renderer for use add it into the renderers block in the
434
+ initializer:
435
+
436
+ config.output_renderers do |renderers|
437
+ ...
438
+ end
439
+
440
+ So to just register a single default renderer method (called
441
+ "my_default_renderer") you would do this:
442
+
443
+ config.output_renderers do |renderers|
444
+ renderers.default(:my_default_renderer)
445
+ end
446
+
447
+ And it would be used to render every type of output. A more sensible example
448
+ would be to have a renderer for PNG-type images and a renderer for text
449
+ outputs as well:
450
+
451
+ config.output_renderers do |renderers|
452
+ renderers.default(:my_default_renderer)
453
+ renderers.add("text/plain", :text_renderer, true)
454
+ renderers.add("image/png", :show_image)
455
+ end
456
+
457
+ This does three things:
458
+ * Registers a renderer for PNG images. This could be as simple as wrapping it
459
+ in an <tt><img ../></tt> tag.
460
+ * Registers a renderer for outputs of type "text/plain" and <em>sets this as
461
+ the default renderer for all other types beginning with "text"</em>. That is
462
+ what the final parameter set to +true+ does.
463
+ * Registers a default renderer for all other types. This should probably give
464
+ an explanation as to why the output cannot be shown in the browser with a
465
+ link to download the output to the user's computer.
466
+
467
+ Note the use of MIME types for specifying all types.
468
+
469
+ Obviously outputs such as images and text are so common that Taverna Player
470
+ provides these renderers for you and has them set up and registered by default.
471
+ You would only need to override them if you wanted extra information to be
472
+ displayed as well, such as sizes next to images, etc.
473
+
474
+ Note that it is not a good idea to register a single image renderer for all
475
+ "image" types as many cannot be shown in most browsers, e.g. TIFF images.
476
+ The default set of registered renderers is shown in the default initializer
477
+ but, as an example, here is how it handles the images that most browsers can
478
+ show:
479
+
480
+ renderers.add("image/jpeg", :show_image)
481
+ renderers.add("image/png", :show_image)
482
+ renderers.add("image/gif", :show_image)
483
+ renderers.add("image/bmp", :show_image)
484
+
485
+ Note that the same renderer callback is used for each one.
486
+
487
+ === Writing your own renderers
488
+
489
+ To be a renderer callback a method must accept two parameters (in this order):
490
+ 1. The content to be rendered.
491
+ 1. The MIME type of the content.
492
+
493
+ In the case of text outputs the content will likely (depending on the output
494
+ helper you use, described above) be the entire text content of the output. In
495
+ most other cases it will probably be a URI or path to the actual content for
496
+ use in, for example, an <tt><img .../></tt> tag.
497
+
498
+ The type is provided in case a renderer wishes to be general and differentiate
499
+ between different subtypes.
500
+
501
+ Note that all renderer callbacks are called by Taverna Player in a context that
502
+ includes the {ActionView::Helpers}[http://api.rubyonrails.org/classes/ActionView/Helpers.html]
503
+ so your callbacks have access to them too, including helpers from third-party
504
+ gems that register their helpers correctly.
505
+
506
+ === Example type renderers
507
+
508
+ These are some of the supplied renderers that are registered by default in
509
+ Taverna Player.
510
+
511
+ ==== Plain text
512
+
513
+ Taverna Player provides a plain text renderer that formats text with a
514
+ monospaced font, converts URI-like things to clickable links and respects
515
+ carriage returns and newlines. It looks something like this:
516
+
517
+ def format_text(content, type)
518
+ # Use CodeRay to format text so that newlines are respected.
519
+ content = CodeRay.scan(content, :text).div(:css => :class)
520
+
521
+ # Use auto_link to turn URI-like text into links.
522
+ auto_link(content, :html => { :target => '_blank' }, :sanitize => false)
523
+ end
524
+
525
+ The {coderay}[https://rubygems.org/gems/coderay] gem is used to format the
526
+ text, preserving newlines and the
527
+ {rails_autolink}[https://rubygems.org/gems/rails_autolink] gem is used to
528
+ convert URI-like text into clickable links.
529
+
530
+ This renderer is registered as the default for all "text" media types.
531
+
532
+ ==== XML
533
+
534
+ This renderer catches "text/XML" outputs:
535
+
536
+ def format_xml(content, type)
537
+ # Make sure XML is indented consistently.
538
+ out = String.new
539
+ REXML::Document.new(content).write(out, 1)
540
+ CodeRay.scan(out, :xml).div(:css => :class, :line_numbers => :table)
541
+ end
542
+
543
+ It uses {REXML}[http://ruby-doc.org/stdlib-1.9.3/libdoc/rexml/rdoc/index.html]
544
+ to format the XML and {coderay}[https://rubygems.org/gems/coderay] to
545
+ syntax-highlight it.
546
+
547
+ Note that for XML to be detected as XML it must, as per the standard, include
548
+ the XML declaration, e.g.:
549
+
550
+ <?xml version="1.0" ?>
551
+
552
+ ==== Images
553
+
554
+ As described above, images are just dropped into an <tt><img ../></tt> tag:
555
+
556
+ def show_image(content, type)
557
+ # Can't use image_tag() here because the image doesn't really exist (it's
558
+ # in a zip file, really) and this confuses the Rails asset pipeline.
559
+ tag("img", :src => content)
560
+ end
561
+
562
+ Note the comment about the Rails asset pipeline in there if you are writing
563
+ your own image renderer and are using the asset pipeline.
564
+
565
+ The content parameter here gives the path to the image to be displayed.
566
+
567
+ ==== Other types catch-all
568
+
569
+ The default renderer for other, or unknown types, is:
570
+
571
+ def cannot_inline(content, type)
572
+ "Sorry but we cannot show this type of content in the browser. Please " +
573
+ link_to("download it", content) + " to view it on your local machine."
574
+ end
575
+
576
+ == Service Credentials
577
+
578
+ <b>Please see the notes in the limitations section below!</b>
579
+
580
+ At the moment the Service Credentials facilities are basic and provided purely
581
+ to allow access to services which are ostensibly public but still require a
582
+ login of some kind.
583
+
584
+ In practice very few services that will be used via public tools such as
585
+ Taverna Player are in use so this should not affect most users at this time.
586
+ It is the intention to fill this gap in functionality as soon as possible,
587
+ however.
588
+
589
+ If you do have services in your workflows that require such a login then you
590
+ can add them through the Service Credentials model. The types of credential
591
+ that Taverna Server can accept are detailed in the
592
+ {Client Library Documentation}[http://mygrid.github.io/t2-server-gem/] but
593
+ Taverna Player supports a subset:
594
+
595
+ === REST
596
+
597
+ REST services are commonly secured via HTTP Basic or HTTP Digest authentication
598
+ and Taverna treats these two schemes in the same way. Simply register the
599
+ username and password with the host name of the server on which the service is
600
+ running:
601
+
602
+ https://example.com:8443/
603
+
604
+ The above example shows a https server running on port 8443. If the service is
605
+ on port 80 for http or port 443 for https then you don’t need to specify the
606
+ port.
607
+
608
+ If there are services on the same host that require different credentials then
609
+ you will need to specify the realm for which each set of credentials applies.
610
+ This is done by adding the name of the realm to the end of the host name with
611
+ a # separating them:
612
+
613
+ https://example.com:8443/#realm
614
+
615
+ === SOAP
616
+
617
+ SOAP services are commonly secured via WS-Security. Simply register the WSDL
618
+ address of the service with your username and password:
619
+
620
+ https://example.com:8443/services/MyService?wsdl
621
+
622
+ === R server
623
+
624
+ You can authenticate to R Servers in almost exactly the same way as for REST
625
+ services - only the protocol scheme is different. So instead of http or https
626
+ it is rserve:
627
+
628
+ rserve://example.com:6311
629
+
630
+ == Limitations and to-do list
631
+
632
+ The most serious limitation is with the Service Credentials. Because Taverna
633
+ Server needs to be given the credentials in plaintext (which is why you should
634
+ always use HTTPS) we have to store them as such. For the time being it is
635
+ recommended to only use them for services that are ostensibly public, but with
636
+ a login requirement. An example of this might be a R server on the local
637
+ machine, which is only available locally, but nevertheless requires a login.
638
+
639
+ Service Credentials are also intended, at the moment, to be a global resource.
640
+ They are not per-user. Every workflow run will be given these credentials.
641
+
642
+ Service Credentials only provide username/password type credentials at the
643
+ moment.
644
+
645
+ === To do
646
+
647
+ In no particular order:
648
+
649
+ * Taverna Player as a service. Allow usage of Taverna Player via a fully
650
+ RESTful interface with JSON and XML support (in progress).
651
+ * User specific (and therefore private) credentials wallet for secure services.
652
+ * Comprehensive Taverna Server administration panel. This would allow admin
653
+ users to view and manage runs directly on the Taverna Server along with
654
+ other such admin tasks.
655
+
656
+ == Support
657
+
658
+ Please email {support@mygrid.org.uk}[mailto:support@mygrid.org.uk] for any
659
+ questions relating to Taverna Player.
660
+
661
+ Bug reports or feature requests may be submitted to the
662
+ {public issue tracker}[https://github.com/myGrid/taverna-player/issues] at
663
+ GitHub.