t2-server 0.9.3 → 1.0.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.
@@ -1,5 +1,84 @@
1
1
  = Changes log for the T2 Ruby Gem
2
2
 
3
+ == Version 1.0.0
4
+
5
+ * Remove deprecated methods.
6
+ * Add read streaming capability to the underlying connection.
7
+ * Add a read method to stream data directly to a file.
8
+ * Stream zip data from server.
9
+ * Update t2-run-workflow so that debug is optional.
10
+ * Stream baclava data from server.
11
+ * Expose streaming capability to output ports.
12
+ * Bring port error handling inline with normal values.
13
+ * Tidy up usage of a mime-type for empty ports.
14
+ * Add methods to test for empty ports or port values.
15
+ * Add output port data streaming functionality.
16
+ * Stream output data directly to a file.
17
+ * Document the credentials classes.
18
+ * Add general stream-to-stream data downloads.
19
+ * Expose stream-to-stream methods in the Run class.
20
+ * Add upload streaming to the underlying connection.
21
+ * Stream uploads of workflows and data.
22
+ * Add streaming examples to the README.
23
+ * Make XPath searching robust to nodes not being found.
24
+ * Read interaction feed URI and query support with API.
25
+ * Read notifications from the interaction feed.
26
+ * Document the Interaction Service additions in the README.
27
+ * Add a bit more compatibility info to the Readme.
28
+ * Clean up run caching code in the Server class.
29
+ * Clean up variables and comments for run creation.
30
+ * Code clarity improvements.
31
+ * Remove duplicated download/streaming code in Run.
32
+ * Remove duplicate URI stripping code from Server.
33
+ * Improve readability of the XML fragments.
34
+ * Add a global complied XPath cache and use for Server.
35
+ * Use global XPath cache for Run class.
36
+ * Add Ruby 2.0.0 as known to work in README.
37
+ * t2-delete-runs: Minor code clean-up.
38
+ * t2-delete-runs: Add a flag to only delete finished runs.
39
+ * t2-run-workflow: Minor code clean-up.
40
+ * t2-run-workflow: Add flag for service credentials.
41
+ * Server now returns 503 when at capacity.
42
+ * Server now has a limit on concurrently running runs.
43
+ * Test for max concurrently running runs.
44
+ * t2-run-workflow: Cope with hitting max running runs.
45
+ * t2-server-stress: Cope with hitting max running runs.
46
+ * Ensure all unit tests delete runs that they create.
47
+ * Mark deleted runs as such in their Run object.
48
+ * [TAVSERV-308] Run#permissions returns nil, instead of :none
49
+ * Add a function to download a single port as a zip file.
50
+ * Added ssl_version to connection parameters
51
+ * Put a guard in to check that the SSL version is sensible.
52
+ * Add SSL version support to the command line tools.
53
+ * Add a new example connection parameter class for SSL version 3.
54
+ * Describe the connection parameters in more detail.
55
+ * Add Run#error? to check all output ports for errors.
56
+ * UnexpectedServerResponse now provides more information.
57
+ * Remove the port value caching code.
58
+ * Simplify the HTTP methods and clean up error handling.
59
+ * Split up the CLI options code.
60
+ * Improve version string parsing.
61
+ * Handle server returning Accepted on run start.
62
+ * Get the run name from the server.
63
+ * t2-server-info: Display run names in list view.
64
+ * Set the run name on the server.
65
+ * t2-run-workflow: Set name of run on server.
66
+ * t2-get-output: Get name of run from server.
67
+ * OutputPort#zip now returns nil for singletons.
68
+ * Fix well-hidden HTTPS connection setup bug.
69
+ * Use a RunCache class instead of a Hash to store local run objects.
70
+ * t2-server-info: Configurable run detail in list view.
71
+ * [TAVSERV-324] Uninitialized connection parameters.
72
+ * Move interaction code out of Server, into Run.
73
+ * Simplifications for per-run feeds.
74
+ * Get different types of notifications for a Run.
75
+ * Expose the run notification/interaction locations.
76
+ * Add Run#log to get run logs.
77
+ * Add connection timeout parameters.
78
+ * Enable interaction reply publishing.
79
+ * Read the interaction serial number from the notification.
80
+ * Enable retrieval of an interaction's input data.
81
+
3
82
  == Version 0.9.3
4
83
 
5
84
  * Correctly handle missing values in output ports.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2012 The University of Manchester, UK.
1
+ Copyright (c) 2010-2013 The University of Manchester, UK.
2
2
 
3
3
  All rights reserved.
4
4
 
@@ -4,8 +4,9 @@ Authors:: Robert Haines
4
4
  Contact:: mailto:support@mygrid.org.uk
5
5
  URL:: http://www.taverna.org.uk/
6
6
  Licence:: BSD (See LICENCE or http://www.opensource.org/licenses/bsd-license.php)
7
- Copyright:: (c) 2010-2012 The University of Manchester, UK
7
+ Copyright:: (c) 2010-2013 The University of Manchester, UK
8
8
 
9
+ {<img src="https://codeclimate.com/github/myGrid/t2-server-gem.png" />}[https://codeclimate.com/github/myGrid/t2-server-gem]
9
10
 
10
11
  == Synopsis
11
12
 
@@ -25,28 +26,41 @@ https://rubygems.org/gems/t2-server
25
26
  You can also download the source code from here:
26
27
  https://github.com/myGrid/t2-server-gem
27
28
 
28
- == Compatibility with Taverna Server versions
29
+ == Compatibility
29
30
 
30
- From version 0.9.0 this library is compatible with Taverna Server 2.3 onwards.
31
+ After the release of version 1.0.0 this gem will follow the principles of
32
+ {Semantic Versioning}[http://semver.org/]. Until that point there may be
33
+ breaking changes to the API, although these will be kept to a minimum.
34
+
35
+ === Taverna Server
36
+
37
+ Versions 0.9.x of this library are compatible with Taverna Server 2.3 and 2.4.
31
38
  It is not compatible with any earlier version of Taverna Server due to breaking
32
- changes in its REST interface. We strongly encourage all users to upgrade to
33
- the current version of Taverna Server, but if that is not possible right now
34
- then please continue to use version 0.6.1 of this library for the time being.
39
+ changes in its REST interface.
40
+
41
+ From version 1.0.0 this library is not guaranteed to be compatible with
42
+ Taverna Server 2.3. It might work but it is not supported, and may stop working
43
+ at any time.
35
44
 
36
- This version of the library should be compatible with any Ruby code that you
37
- may have already written against earlier versions but you may see some warnings
38
- about API deprecations. These are clearly marked [DEPRECATION] and will appear
39
- on your console output. Anything marked as deprecated will be removed in
40
- version 1.0.0 (and are not guaranteed to continue working even until then) so
41
- you are advised to update your code at your earliest convenience.
45
+ Version 1.0.0 of this library saw the removal of older methods that were
46
+ previously deprecated. If your code no longer works with this version then
47
+ please re-test it with version 0.9.3 and check for deprecation messages before
48
+ reporting bugs.
42
49
 
43
- == Compatibility with Ruby versions
50
+ We strongly encourage all users to upgrade to the current version of Taverna
51
+ Server, but if that is not possible right now then these are the recommended
52
+ version pairings:
53
+ * pre Taverna Server 2.3, use version 0.6.1 of the gem
54
+ * 2.3, use version 0.9.3
55
+ * 2.4 and up, use version 1.0.0
56
+
57
+ === Ruby
44
58
 
45
59
  This library is known to work with the following versions of Ruby:
46
- * 1.8.7 *
60
+ * 1.8.7
47
61
  * 1.9.2
48
62
  * 1.9.3 *
49
- * jruby 1.6.4 (in Ruby 1.8 mode)
63
+ * 2.0.0
50
64
 
51
65
  Those marked with an asterisk (*) are supported and bugs found against them
52
66
  will be fixed. Other versions may work but are not tested or supported.
@@ -54,8 +68,8 @@ will be fixed. Other versions may work but are not tested or supported.
54
68
  == Usage
55
69
 
56
70
  There are two entry points for the T2Server API:
57
- * <tt>T2Server::Run</tt> - Use this for running single jobs on a server.
58
- * <tt>T2Server::Server</tt> - Use this if you are providing a web interface to
71
+ * T2Server::Run - Use this for running single jobs on a server.
72
+ * T2Server::Server - Use this if you are providing a web interface to
59
73
  one or more Taverna 2 Server instances.
60
74
 
61
75
  In both cases the gem should be initialized by requiring the top level ruby
@@ -76,6 +90,9 @@ Connection configuration settings are passed in to various methods using the
76
90
  * <tt>:verify_peer</tt> - Use a CA to verify that the Taverna Server you are connecting to has a valid server certificate and that it is the correct one.
77
91
  * <tt>:client_certificate</tt> - A certificate to use for client certificate authentication.
78
92
  * <tt>:client_password</tt> - The password to unlock the private key of the client certificate.
93
+ * <tt>:ssl_version</tt> - The TLS/SSL version to use (<tt>:TLSv1</tt>, <tt>:SSLv23</tt> or <tt>:SSLv3</tt>)
94
+ * <tt>:open_timeout</tt> - The number of seconds to wait while opening a connection.
95
+ * <tt>:read_timeout</tt> - The number of seconds to wait while reading from a connection.
79
96
 
80
97
  And can be set like this for a standard https connection:
81
98
 
@@ -91,9 +108,10 @@ automatically.
91
108
  For convenience a number of standard sets of parameters have been defined. The
92
109
  above example is available as +DefaultConnectionParameters+. Others available
93
110
  are:
94
- * +InsecureSSLConnectionParameters+ - to ignore SSL checks.
111
+ * +InsecureSSLConnectionParameters+ - to ignore SSL checks. <b>Not recommended!</b>
95
112
  * +CustomCASSLConnectionParameters+ - for custom (self-signed) CAs.
96
113
  * +ClientAuthSSLConnectionParameters+ - for client certificate authentication.
114
+ * +SSL3ConnectionParameters+ - uses SSLv3 as the default transport layer.
97
115
 
98
116
  See the rdoc for more details on these classes.
99
117
 
@@ -106,7 +124,7 @@ These are simple to set up:
106
124
 
107
125
  === Server API example
108
126
 
109
- The Server constructor can yield the newly created object. Simple supply a URI
127
+ The Server constructor can yield the newly created object. Simply supply a URI
110
128
  and a set of connection parameters to connect to a server:
111
129
 
112
130
  T2Server::Server.new(uri, conn_params) do |server|
@@ -124,8 +142,11 @@ credentials:
124
142
  ...
125
143
  end
126
144
 
127
- An individual run can be deleted with its own <tt>delete</tt> method (see below)
128
- but all runs on a server can be deleted in one go:
145
+ The +workflow+ parameter can be the workflow itself, a filename or a File or
146
+ IO object.
147
+
148
+ An individual run can be deleted with its own <tt>delete</tt> method (see
149
+ below) but all runs on a server can be deleted in one go:
129
150
 
130
151
  server.delete_all_runs(credentials)
131
152
 
@@ -141,6 +162,9 @@ a couple of runs directly:
141
162
  ...
142
163
  end
143
164
 
165
+ As before, the +workflow+ parameter can be the workflow itself, a filename or
166
+ a File or IO object.
167
+
144
168
  Setting an input port to a run is very easy:
145
169
 
146
170
  run.input_port("port_name").value = 1
@@ -164,25 +188,69 @@ Or just wait until the run has finished:
164
188
 
165
189
  run.wait
166
190
 
167
- Then the outputs can be collected:
191
+ While a workflow is running it might produce notifications via the
192
+ {Interaction Service}[http://dev.mygrid.org.uk/wiki/display/taverna/Interaction+service].
193
+ These can be polled with:
194
+
195
+ run.notifications
196
+
197
+ If there are any new notifications that have not been responded to they will
198
+ be returned in a list to be processed. Notifications take the form of a Web
199
+ page to be displayed and the notification objects returned from the above call
200
+ hold a URI to that page. The following code prints those URIs to the console:
201
+
202
+ run.notifications.each do |i|
203
+ puts i.uri
204
+ end
205
+
206
+ When the workflow has finished executing then the outputs can be collected
207
+ into memory or saved to a file:
168
208
 
169
209
  result = run.output_port("port_name").value
210
+ run.output_port("port_name").write_value_to_file("/path/to/value.txt")
211
+
212
+ Outputs can be queried as to their type, size (in bytes) or if they contain an
213
+ error message:
214
+
215
+ run.output_port("port_name").type
216
+ run.output_port("port_name").size
217
+ run.output_port("port_name").error?
170
218
 
171
- If you have a lot of output you can grab the whole lot as a zip file:
219
+ If the output does hold an error then it can be found in the value of the
220
+ output as normal.
172
221
 
173
- zip_data = run.zip_output
222
+ If you have a lot of output you can grab the whole lot in a zip archive. This
223
+ can be downloaded into memory or saved directly to a file.
224
+
225
+ zip_data = run.zip_output # download to memory
226
+ run.zip_output("/path/to/output.zip") # save to a file
174
227
 
175
228
  Using baclava documents for setting inputs and collecting outputs is also
176
229
  supported:
177
230
 
178
231
  run.baclava_input = filename
179
232
 
180
- But make sure you request baclava output *before* starting the run:
233
+ But make sure you request baclava output *before* starting the run. Baclava
234
+ output can be downloaded into memory or saved directly to a file.
181
235
 
182
236
  run.request_baclava_output
183
237
  run.start
184
238
  run.wait
185
- output = run.baclava_output
239
+ output = run.baclava_output # download to memory
240
+ run.baclava_output("/path/to/output.baclava") # save to a file
241
+
242
+ The log from Taverna Server can be downloaded in a similar way to zip files or
243
+ Baclava documents.
244
+
245
+ log = run.log # download to memory
246
+ run.log("/path/to/log.txt") # save to a file
247
+
248
+ When downloading outputs the underlying stream can be accessed by supplying a
249
+ block to the value, zip_output, baclava_output or log methods:
250
+
251
+ run.output_port("port_name").value do |data|
252
+ print data
253
+ end
186
254
 
187
255
  A run can be deleted when no longer needed, like so:
188
256
 
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010-2012 The University of Manchester, UK.
1
+ # Copyright (c) 2010-2013 The University of Manchester, UK.
2
2
  #
3
3
  # All rights reserved.
4
4
  #
@@ -46,8 +46,8 @@ task :default => [:test]
46
46
  Jeweler::Tasks.new do |s|
47
47
  s.name = "t2-server"
48
48
  s.version = T2Server::Version::STRING
49
- s.authors = ["Robert Haines"]
50
- s.email = ["rhaines@manchester.ac.uk"]
49
+ s.authors = ["Robert Haines", "Finn Bacall"]
50
+ s.email = ["support@mygrid.org.uk"]
51
51
  s.homepage = "http://www.taverna.org.uk/"
52
52
  s.platform = Gem::Platform::RUBY
53
53
  s.summary = "Support for interacting with Taverna 2 Server."
@@ -66,8 +66,10 @@ Jeweler::Tasks.new do |s|
66
66
  s.add_development_dependency('nokogiri', '>= 1.5.0')
67
67
  s.add_development_dependency('rdoc', '>= 3.9.4')
68
68
  s.add_development_dependency('jeweler', '~> 1.8.3')
69
+ s.add_development_dependency('launchy', '~> 2.2.0')
69
70
  s.add_runtime_dependency('net-http-persistent', '~> 2.6')
70
71
  s.add_runtime_dependency('taverna-baclava', '~> 1.0.0')
72
+ s.add_runtime_dependency('ratom', '~> 0.8.2')
71
73
  s.add_runtime_dependency('hirb', '>= 0.4.0')
72
74
  end
73
75
 
@@ -95,10 +97,9 @@ end
95
97
  RDoc::Task.new do |r|
96
98
  r.main = "README.rdoc"
97
99
  lib = Dir.glob("lib/**/*.rb").delete_if do |item|
98
- item.include?("t2server.rb") or
99
100
  item.include?("/xml/") or
101
+ item.include?("run-cache.rb") or
100
102
  item.include?("connection.rb") or
101
- item.include?("credentials.rb") or
102
103
  item.include?("t2-server-cli.rb")
103
104
  end
104
105
  r.rdoc_files.include("README.rdoc", "LICENCE.rdoc", "CHANGES.rdoc", lib)
@@ -38,16 +38,20 @@ include T2Server::CLI
38
38
 
39
39
  # set up options
40
40
  options = {}
41
- conn_params, creds = register_options("Usage: t2-delete-runs [options] " +
41
+ conn_params, creds = register_options("Usage: t2-delete-runs [options] "\
42
42
  "server-address [run-ids...]") do |opt|
43
- opt.separator " Where server-address is the full URI of the server to " +
43
+ opt.separator " Where server-address is the full URI of the server to "\
44
44
  "connect to,"
45
- opt.separator " e.g.: http://example.com:8080/taverna, run-ids are the " +
45
+ opt.separator " e.g.: http://example.com:8080/taverna, run-ids are the "\
46
46
  "id numbers"
47
47
  opt.separator " of the runs you want to delete and [options] can be:"
48
48
  opt.on("--all", "Delete all runs on the server") do
49
49
  options[:all] = true
50
50
  end
51
+ opt.on("-f", "--finished", "Delete only finished runs. Combine with --all "\
52
+ "to delete all finished runs") do
53
+ options[:finished] = true
54
+ end
51
55
  end
52
56
 
53
57
  # get runs and server address from the arguments
@@ -71,29 +75,27 @@ rescue RuntimeError => e
71
75
  exit 1
72
76
  end
73
77
 
78
+ # ...get the runs...
79
+ server_runs = server.runs(creds)
80
+
74
81
  # ...and delete them!
75
- if options[:all]
82
+ for run in server_runs
76
83
  begin
77
- server.delete_all_runs(creds)
84
+ if options[:all] || runs.include?(run.id)
85
+ if options[:finished]
86
+ run.delete if run.finished?
87
+ else
88
+ run.delete
89
+ end
90
+ end
91
+ rescue T2Server::RunNotFoundError => rnf
92
+ puts "Run '#{run.id}' not found - skipping."
93
+ next
78
94
  rescue T2Server::AuthorizationError => ae
79
- puts "You are not authorized to delete runs on this server."
95
+ puts "You are not authorized to delete run '#{run.id}' - skipping."
96
+ next
80
97
  rescue T2Server::T2ServerError => e
81
- puts "There was a problem while deleting runs. " +
82
- "Some may remain on the server."
83
- end
84
- else
85
- for run in runs
86
- begin
87
- server.delete_run(run, creds)
88
- rescue T2Server::RunNotFoundError => rnf
89
- puts "Run '#{run}' not found - skipping."
90
- next
91
- rescue T2Server::AuthorizationError => ae
92
- puts "You are not authorized to delete run '#{run}' - skipping."
93
- next
94
- rescue T2Server::T2ServerError => e
95
- puts "There was a problem while deleting run '#{run}' - skipping."
96
- next
97
- end
98
+ puts "There was a problem while deleting run '#{run.id}' - skipping."
99
+ next
98
100
  end
99
101
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2010-2012 The University of Manchester, UK.
2
+ # Copyright (c) 2010-2013 The University of Manchester, UK.
3
3
  #
4
4
  # All rights reserved.
5
5
  #
@@ -53,6 +53,10 @@ conn_params, creds = register_options("Usage: t2-get-output [options] " +
53
53
  "are specified then list all the output ports.") do |val|
54
54
  ports << val.chomp
55
55
  end
56
+ opt.on("-N", "--name", "Return the name of the run. Supported in Taverna "\
57
+ "Server versions 2.5.0 and up.") do
58
+ options[:name] = true
59
+ end
56
60
  opt.on("-x", "--exitcode", "Return the exitcode of the run.") do
57
61
  options[:exitcode] = true
58
62
  end
@@ -95,6 +99,8 @@ begin
95
99
  server = T2Server::Server.new(uri, conn_params)
96
100
  run = server.run(run_id, creds)
97
101
 
102
+ puts "Run name: #{run.name}" if options[:name]
103
+
98
104
  ports = run.output_ports.keys if ports.empty?
99
105
  ports.each do |p|
100
106
  port = run.output_port(p)
@@ -112,22 +118,14 @@ begin
112
118
  p port.type
113
119
  end
114
120
 
115
- if options[:tsize]
116
- puts " Total data size: #{port.total_size}"
117
- end
121
+ puts " Total data size: #{port.total_size}" if options[:tsize]
118
122
  end
119
123
 
120
- if options[:exitcode]
121
- puts "Exitcode: #{run.exitcode}"
122
- end
124
+ puts "Exitcode: #{run.exitcode}" if options[:exitcode]
123
125
 
124
- if options[:stdout]
125
- puts "Stdout: #{run.stdout}"
126
- end
126
+ puts "Stdout: #{run.stdout}" if options[:stdout]
127
127
 
128
- if options[:stderr]
129
- puts "Stderr: #{run.stderr}"
130
- end
128
+ puts "Stderr: #{run.stderr}" if options[:stderr]
131
129
  rescue RuntimeError => e
132
130
  puts e
133
131
  exit 1