t2-server 0.1.0 → 0.1.1

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.
data/README.rdoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = Taverna[http://www.taverna.org.uk/] 2 Server Interaction Gem
2
2
 
3
3
  Authors:: Robert Haines
4
- Gem Version:: 0.1.0
4
+ Gem Version:: 0.1.1
5
5
  API Version:: 2.2a1
6
6
  Contact:: mailto:rhaines@manchester.ac.uk
7
7
  URL:: http://taverna.sourceforge.net/
data/bin/run_workflow CHANGED
@@ -61,6 +61,7 @@ end
61
61
  inputs = {}
62
62
  wkf_file = ""
63
63
  print_output = true
64
+ baclava_out = ""
64
65
  opts = OptionParser.new do |opt|
65
66
  opt.banner = "Usage: run_workflow [options] server-address"
66
67
  opt.separator ""
@@ -75,7 +76,19 @@ opts = OptionParser.new do |opt|
75
76
  input, value = val.chomp.split(':')
76
77
  inputs[input] = value
77
78
  end
78
- opt.on("-p", "--[no-]print", "Print outputs to the console. On by default") do |val|
79
+ opt.on("-b BACLAVA", "--baclava-in=BACLAVA", "Set baclava file for input port values") do |val|
80
+ inputs[:baclava] = val
81
+ end
82
+ opt.on("-o", "--baclava-out[=BACLAVA]", "Return outputs in baclava format." +
83
+ " A filename may be specified or 'out.xml' is used") do |val|
84
+ if val != nil and val.include? "."
85
+ baclava_out = val
86
+ else
87
+ baclava_out = "out.xml"
88
+ end
89
+ end
90
+ opt.on("-p", "--[no-]print", "Print outputs to the console. On by default " +
91
+ "unless baclava output is selected") do |val|
79
92
  print_output = val
80
93
  end
81
94
  opt.on_tail("-h", "-?", "--help", "Show this message") do
@@ -117,11 +130,19 @@ puts "Created run with uuid: #{run.uuid}"
117
130
  puts "Created at #{run.create_time}"
118
131
 
119
132
  # set inputs
120
- inputs.each do |input, value|
121
- puts "Set input '#{input}' to #{value}"
122
- run.set_input(input, value)
133
+ if inputs.has_key?(:baclava)
134
+ run.upload_baclava_file(inputs[:baclava])
135
+ puts "Uploaded baclava input file"
136
+ else
137
+ inputs.each do |input, value|
138
+ puts "Set input '#{input}' to #{value}"
139
+ run.set_input(input, value)
140
+ end
123
141
  end
124
142
 
143
+ # output baclava?
144
+ run.set_baclava_output(baclava_out) unless baclava_out == ""
145
+
125
146
  # start run and wait until it is finished
126
147
  run.start
127
148
  puts "Started at #{run.start_time}"
@@ -138,8 +159,15 @@ if stdout != "" then puts "Stdout:\n#{stdout}" end
138
159
  if stderr != "" then puts "Stderr:\n#{stderr}" end
139
160
 
140
161
  if exitcd == 0
141
- puts "Outputs:"
142
- get_outputs(run, print_output)
162
+ if baclava_out != ""
163
+ File.open(baclava_out, "w") do |file|
164
+ file.syswrite(run.get_baclava_output)
165
+ end
166
+ puts "Baclava file written to '#{baclava_out}'"
167
+ else
168
+ puts "Outputs:"
169
+ get_outputs(run, print_output)
170
+ end
143
171
  end
144
172
 
145
173
  # delete run
data/lib/t2server/run.rb CHANGED
@@ -46,6 +46,9 @@ module T2Server
46
46
  # download.
47
47
  class Run
48
48
  private_class_method :new
49
+
50
+ # The identifier of this run on the server. It is currently a UUID
51
+ # (version 4).
49
52
  attr_reader :uuid
50
53
 
51
54
  # :stopdoc:
@@ -61,7 +64,8 @@ module T2Server
61
64
  @server = server
62
65
  @uuid = uuid
63
66
  @workflow = ""
64
- @baclava = false
67
+ @baclava_in = false
68
+ @baclava_out = ""
65
69
 
66
70
  @links = get_attributes(@server.get_run_attribute(uuid, ""))
67
71
  #@links.each {|key, val| puts "#{key}: #{val}"}
@@ -315,11 +319,39 @@ module T2Server
315
319
  state = status
316
320
  raise RunStateError.new(state, STATE[:initialized]) if state != STATE[:initialized]
317
321
 
318
- @baclava = true
322
+ @baclava_in = true
319
323
  rename = upload_file(filename)
320
324
  @server.set_run_attribute(@uuid, @links[:baclava], rename)
321
325
  end
322
326
 
327
+ # :call-seq:
328
+ # run.set_baclava_output(name="out.xml") -> bool
329
+ #
330
+ # Set the server to save the outputs of this run in baclava format. The
331
+ # filename can be specified with the _name_ parameter otherwise a default
332
+ # of 'out.xml' is used. This must be done before the run is started.
333
+ def set_baclava_output(name="out.xml")
334
+ state = status
335
+ raise RunStateError.new(state, STATE[:initialized]) if state != STATE[:initialized]
336
+
337
+ @baclava_out = name.strip_path
338
+ @server.set_run_attribute(@uuid, @links[:output], @baclava_out)
339
+ end
340
+
341
+ # :call-seq:
342
+ # run.get_baclava_output -> string
343
+ #
344
+ # Get the outputs of this run in baclava format. This can only be done if
345
+ # the output has been requested in baclava format by #set_baclava_output
346
+ # before starting the run.
347
+ def get_baclava_output
348
+ state = status
349
+ raise RunStateError.new(state, STATE[:finished]) if state != STATE[:finished]
350
+
351
+ raise AttributeNotFoundError.new("#{@links[:wdir]}/#{@baclava_out}") if @baclava_out == ""
352
+ @server.get_run_attribute(@uuid, "#{@links[:wdir]}/#{@baclava_out}")
353
+ end
354
+
323
355
  # :call-seq:
324
356
  # run.ls(dir="") -> [[dirs], [objects]]
325
357
  #
@@ -42,7 +42,14 @@ module T2Server
42
42
  # instances.
43
43
  class Server
44
44
  private_class_method :new
45
- attr_reader :uri, :run_limit
45
+
46
+ # The URI of this server instance as a String.
47
+ attr_reader :uri
48
+
49
+ # The maximum number of runs that this server will allow at any one time.
50
+ # Runs in any state (+Initialized+, +Running+ and +Finished+) are counted
51
+ # against this maximum.
52
+ attr_reader :run_limit
46
53
 
47
54
  # list of servers we know about
48
55
  @@servers = []
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t2-server
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robert Haines
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-02 00:00:00 +01:00
18
+ date: 2010-09-03 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,10 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 49
30
30
  segments:
31
31
  - 0
32
- version: "0"
32
+ - 8
33
+ - 7
34
+ version: 0.8.7
33
35
  type: :development
34
36
  version_requirements: *id001
35
37
  description: This gem provides access to the Taverna 2 Server REST interface from Ruby.