class T2Server::Run
An interface for easily running jobs on a Taverna 2 Server
with minimal setup and configuration required.
A run can be in one of three states:
-
:initialized - The run has been accepted by the server. It may not yet be ready to run though as its input port may not have been set.
-
:running - The run is being run by the server.
-
:finished - The run has finished running and its outputs are available for download.
Attributes
The identifier of this run on the server.
The identifier of this run on the server.
The server instance that this run is hosted on.
Public Class Methods
Create a new run in the :initialized state. The run will be created on the server with address supplied by server. This can either be a String of the form http://example.com:8888/blah
or an already created instance of T2Server::Server
. The workflow may be supplied as a string in t2flow format, a filename or a File or IO object. User credentials and connection parameters can be supplied if required but are both optional. If server is an instance of T2Server::Server
then connection_parameters will be ignored.
This method will yield the newly created Run
if a block is given.
# File lib/t2-server/run.rb 155 def Run.create(server, workflow, *rest) 156 credentials = nil 157 uri = nil 158 conn_params = nil 159 160 rest.each do |param| 161 case param 162 when URI 163 uri = param 164 when ConnectionParameters 165 conn_params = param 166 when HttpCredentials 167 credentials = param 168 end 169 end 170 171 # If server is not a Server object, get one. 172 server = Server.new(server, conn_params) if server.class != Server 173 174 # If we are not given a URI to a run then we know we need to create one. 175 uri ||= server.initialize_run(workflow, credentials) 176 177 # Create the run object and yield it if necessary. 178 run = new(server, uri, credentials) 179 yield(run) if block_given? 180 run 181 end
Public Instance Methods
Provide a client certificate credential for the secure service at the specified URI. You will need to provide the password to unlock the private key. You will also need to provide the 'alias' or 'friendlyName' of the key you wish to use if it differs from the default. The URI of the credential on the server is returned. Only the owner of a run may supply credentials for it. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 833 def add_keypair_credential(uri, filename, password, 834 name = "Imported Certificate", type = :pkcs12) 835 return unless owner? 836 837 type = type.to_s.upcase 838 contents = Base64.encode64(IO.read(filename)) 839 840 # basic uri checks 841 uri = _check_cred_uri(uri) 842 843 value = xml_keypair_cred_fragment(uri, name, contents, type, password) 844 845 @server.create(links[:sec_creds], value, "application/xml", @credentials) 846 end
Provide a username and password credential for the secure service at the specified URI. The URI of the credential on the server is returned. Only the owner of a run may supply credentials for it. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 803 def add_password_credential(uri, username, password) 804 return unless owner? 805 806 # Is this a new credential, or an update? 807 cred_uri = credential(uri) 808 809 # basic uri checks 810 uri = _check_cred_uri(uri) 811 812 value = xml_password_cred_fragment(uri, username, password) 813 814 if cred_uri.nil? 815 @server.create(links[:sec_creds], value, "application/xml", 816 @credentials) 817 else 818 @server.update(cred_uri, value, "application/xml", @credentials) 819 end 820 end
Add a trusted identity (server public key) to verify peers when using https connections to Web Services. The URI of the trust on the server is returned. Only the owner of a run may add a trust. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 913 def add_trust(filename, type = :x509) 914 return unless owner? 915 916 type = type.to_s.upcase 917 918 contents = Base64.encode64(IO.read(filename)) 919 920 value = xml_trust_fragment(contents, type) 921 @server.create(links[:sec_trusts], value, "application/xml", @credentials) 922 end
Use a baclava file for the workflow inputs.
# File lib/t2-server/run.rb 470 def baclava_input=(filename) 471 state = status 472 raise RunStateError.new(state, :initialized) if state != :initialized 473 474 file = upload_file(filename) 475 result = @server.update(links[:baclava], file, "text/plain", @credentials) 476 477 @baclava_in = true if result 478 479 result 480 end
Have the inputs to this run been set by a baclava document?
# File lib/t2-server/run.rb 510 def baclava_input? 511 @baclava_in 512 end
Get the outputs of this run in baclava format. This can only be done if the output has been requested in baclava format by set_baclava_output before starting the run.
Calling this method with no parameters will simply return a blob of XML
data. Providing a filename will stream the data directly to that file and return the number of bytes written. Passing in an object that has a write
method (for example, an instance of File or IO) will stream the XML
data directly to that object and return the number of bytes that were streamed. Passing in a block will allow access to the underlying data stream:
run.baclava_output do |chunk| print chunk end
Raises RunStateError
if the run has not finished running.
# File lib/t2-server/run.rb 554 def baclava_output(param = nil, &block) 555 raise ArgumentError, 556 'both a parameter and block given for baclava_output' if param && block 557 558 state = status 559 raise RunStateError.new(state, :finished) if state != :finished 560 561 raise AccessForbiddenError.new("baclava output") if !@baclava_out 562 563 baclava_uri = Util.append_to_uri_path(links[:wdir], BACLAVA_FILE) 564 download_or_stream(param, baclava_uri, "*/*", &block) 565 end
Get the creation time of this run as an instance of class Time.
# File lib/t2-server/run.rb 703 def create_time 704 Time.parse(@server.read(links[:createtime], "text/plain", @credentials)) 705 end
Return the URI of the credential set for the supplied service, if any. Only the owner of a run may query its credentials. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 876 def credential(uri) 877 return unless owner? 878 879 credentials[uri] 880 end
Return a hash (service_uri => credential_uri) of all the credentials provided for this run. Only the owner of a run may query its credentials. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 854 def credentials 855 return unless owner? 856 857 creds = {} 858 doc = xml_document(@server.read(links[:sec_creds], "application/xml", 859 @credentials)) 860 861 xpath_find(doc, @@xpaths[:sec_cred]).each do |c| 862 uri = URI.parse(xml_node_content(xpath_first(c, @@xpaths[:sec_suri]))) 863 cred_uri = URI.parse(xml_node_attribute(c, "href")) 864 creds[uri] = cred_uri 865 end 866 867 creds 868 end
Delete this run from the server.
# File lib/t2-server/run.rb 230 def delete 231 @server.delete(@uri, @credentials) 232 @deleted = true 233 end
Delete all credentials associated with this workflow run. Only the owner of a run may delete its credentials. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 900 def delete_all_credentials 901 return unless owner? 902 903 @server.delete(links[:sec_creds], @credentials) 904 end
Delete all trusted identities associated with this workflow run. Only the owner of a run may delete its trusts. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 964 def delete_all_trusts 965 return unless owner? 966 967 @server.delete(links[:sec_trusts], @credentials) 968 end
Delete the credential that has been provided for the specified service. Only the owner of a run may delete its credentials. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 888 def delete_credential(uri) 889 return unless owner? 890 891 @server.delete(credentials[uri], @credentials) 892 end
Delete the trust with the provided URI. Only the owner of a run may delete its trusts. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 952 def delete_trust(uri) 953 return unless owner? 954 955 @server.delete(uri, @credentials) 956 end
Has this run been deleted from the server?
# File lib/t2-server/run.rb 239 def deleted? 240 @deleted 241 end
Are there errors in this run's outputs? Returns false if the run is not finished yet.
# File lib/t2-server/run.rb 689 def error? 690 return false unless finished? 691 692 output_ports.values.each do |output| 693 return true if output.error? 694 end 695 696 false 697 end
Get the return code of the run. Zero indicates success.
# File lib/t2-server/run.rb 378 def exitcode 379 @server.read(links[:exitcode], "text/plain", @credentials).to_i 380 end
Return the expiry time of this run as an instance of class Time.
# File lib/t2-server/run.rb 284 def expiry 285 Time.parse(@server.read(links[:expiry], "text/plain", @credentials)) 286 end
Set the expiry time of this run to time. time should either be a Time object or something that the Time class can parse. If the value given does not specify a date then today's date will be assumed. If a time/date in the past is specified, the expiry time will not be changed.
# File lib/t2-server/run.rb 295 def expiry=(time) 296 unless time.instance_of? Time 297 time = Time.parse(time) 298 end 299 300 # need to massage the xmlschema format slightly as the server cannot 301 # parse timezone offsets with a colon (eg +00:00) 302 date_str = time.xmlschema(2) 303 date_str = date_str[0..-4] + date_str[-2..-1] 304 @server.update(links[:expiry], date_str, "text/plain", @credentials) 305 end
Get the finish time of this run as an instance of class Time.
# File lib/t2-server/run.rb 719 def finish_time 720 Time.parse(@server.read(links[:finishtime], "text/plain", @credentials)) 721 end
Is this run in the :finished state?
# File lib/t2-server/run.rb 680 def finished? 681 status == :finished 682 end
Set the server to save the outputs of this run in baclava format. This must be done before the run is started.
# File lib/t2-server/run.rb 487 def generate_baclava_output 488 return if @baclava_out 489 state = status 490 raise RunStateError.new(state, :initialized) if state != :initialized 491 492 @baclava_out = @server.update(links[:output], BACLAVA_FILE, "text/plain", 493 @credentials) 494 end
Has this run been set to return results in baclava format?
# File lib/t2-server/run.rb 518 def generate_baclava_output? 519 @baclava_out 520 end
Toggle the generation of provenance for this run on or off. This must be done before the run is started. Once the run has completed provenance can be retrieved with Run#provenance
.
Requesting baclava output for a run will override this setting.
# File lib/t2-server/run.rb 575 def generate_provenance(toggle = true) 576 return @provenance if @provenance == toggle || links[:gen_prov].nil? 577 state = status 578 raise RunStateError.new(state, :initialized) if state != :initialized 579 580 result = @server.update(links[:gen_prov], toggle.to_s, "text/plain", 581 @credentials) 582 583 # If changing the setting worked then return the new setting, otherwise 584 # return the old one. 585 @provenance = result ? toggle : @provenance 586 end
Has this run been set to generate provenance output?
# File lib/t2-server/run.rb 592 def generate_provenance? 593 @provenance 594 end
Grant the user the stated permission. A permission can be one of :none
, :read
, :update
or :destroy
. Only the owner of a run may grant permissions on it. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 742 def grant_permission(username, permission) 743 return unless owner? 744 745 value = xml_permissions_fragment(username, permission.to_s) 746 @server.create(links[:sec_perms], value, "application/xml", @credentials) 747 end
Is this run in the :initialized state?
# File lib/t2-server/run.rb 664 def initialized? 665 status == :initialized 666 end
Get port.
# File lib/t2-server/run.rb 255 def input_port(port) 256 input_ports[port] 257 end
Return a hash (name, port) of all the input ports this run expects.
# File lib/t2-server/run.rb 247 def input_ports 248 @input_ports ||= _get_input_port_info 249 end
Get the internal Taverna Server
log from this run.
Calling this method with no parameters will simply return a text string. Providing a filename will stream the data directly to that file and return the number of bytes written. Passing in an object that has a write
method (for example, an instance of File or IO) will stream the text directly to that object and return the number of bytes that were streamed. Passing in a block will allow access to the underlying data stream:
run.log do |chunk| print chunk end
# File lib/t2-server/run.rb 416 def log(param = nil, &block) 417 raise ArgumentError, 418 'both a parameter and block given for baclava_output' if param && block 419 420 download_or_stream(param, links[:logfile], "text/plain", &block) 421 end
Create a directory in the run's working directory on the server. This could be used to store input data.
# File lib/t2-server/run.rb 428 def mkdir(dir) 429 dir = Util.strip_path_slashes(dir) 430 431 @server.mkdir(links[:wdir], dir, @credentials) 432 end
Get the name of this run.
Initially this name is derived by Taverna Server
from the name annotation in the workflow file and the time at which the run was initialized. It can be set with the name=
method.
For Taverna Server
versions prior to version 2.5.0 this is a no-op and the empty string is returned for consistency.
# File lib/t2-server/run.rb 203 def name 204 return "" if links[:name].nil? 205 @server.read(links[:name], "text/plain", @credentials) 206 end
Set the name of this run. true
is returned upon success. The maximum length of names supported by the server is 48 characters. Anything longer than 48 characters will be truncated before upload.
Initially this name is derived by Taverna Server
from the name annotation in the workflow file and the time at which the run was initialized.
For Taverna Server
versions prior to version 2.5.0 this is a no-op but true
is still returned for consistency.
# File lib/t2-server/run.rb 221 def name=(name) 222 return true if links[:name].nil? 223 @server.update(links[:name], name[0...48], "text/plain", @credentials) 224 end
Poll the server for notifications and return them in a list. Returns the empty list if there are none, or if the server does not support the Interaction
Service.
The type
parameter is used to select which types of notifications are returned as follows:
-
:requests
-Interaction
requests. -
:replies
-Interaction
replies. -
:new_requests
-Interaction
requests that are new since the last time they were polled (default). -
:all
- All interaction requests and replies.
# File lib/t2-server/run.rb 1028 def notifications(type = :new_requests) 1029 return [] if links[:feed].nil? 1030 1031 @interaction_reader ||= Interaction::Feed.new(self) 1032 1033 if type == :new_requests 1034 @interaction_reader.new_requests 1035 else 1036 @interaction_reader.notifications(type) 1037 end 1038 end
Get output port port.
# File lib/t2-server/run.rb 276 def output_port(port) 277 output_ports[port] if finished? 278 end
Return a hash (name, port) of all the output ports this run has. Until the run is finished this method will return nil.
# File lib/t2-server/run.rb 264 def output_ports 265 if finished? && @output_ports.nil? 266 @output_ports = _get_output_port_info 267 end 268 269 @output_ports 270 end
Get the username of the owner of this run. The owner is the user who created the run on the server.
# File lib/t2-server/run.rb 188 def owner 189 @owner ||= _get_run_owner 190 end
Are the credentials being used to access this run those of the owner? The owner of the run can give other users certain access rights to their runs but only the owner can change these rights - or even see what they are. Sometimes it is useful to know if the user accessing the run is actually the owner of it or not.
# File lib/t2-server/run.rb 731 def owner? 732 @credentials.username == owner 733 end
Return the permission granted to the supplied username, if any. Only the owner of a run may query its permissions. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 777 def permission(username) 778 return unless owner? 779 780 permissions[username] || :none 781 end
Return a hash (username => permission) of all the permissions set for this run. Only the owner of a run may query its permissions. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 755 def permissions 756 return unless owner? 757 758 perms = {} 759 doc = xml_document(@server.read(links[:sec_perms], "application/xml", 760 @credentials)) 761 762 xpath_find(doc, @@xpaths[:sec_perm]).each do |p| 763 user = xml_node_content(xpath_first(p, @@xpaths[:sec_uname])) 764 perm = xml_node_content(xpath_first(p, @@xpaths[:sec_uperm])).to_sym 765 perms[user] = perm 766 end 767 768 perms 769 end
Get the provenance of this run from the server in zip format.
Calling this method with no parameters will simply return a blob of zipped data. Providing a filename will stream the data directly to that file and return the number of bytes written. Passing in an object that has a write
method (for example, an instance of File or IO) will stream the data directly to that object and return the number of bytes that were streamed. Passing in a block will allow access to the underlying data stream:
run.provenance do |chunk| print chunk end
Raises RunStateError
if the run has not finished running.
# File lib/t2-server/run.rb 616 def provenance(param = nil, &block) 617 raise ArgumentError, 618 'both a parameter and block given for provenance' if param && block 619 620 state = status 621 raise RunStateError.new(state, :finished) if state != :finished 622 623 raise AccessForbiddenError.new("provenance") unless @provenance 624 download_or_stream(param, links[:run_bundle], "*/*", &block) 625 end
Revoke whatever permissions that have been granted to the user. Only the owner of a run may revoke permissions on it. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 789 def revoke_permission(username) 790 return unless owner? 791 792 uri = Util.append_to_uri_path(links[:sec_perms], username) 793 @server.delete(uri, @credentials) 794 end
Is this run in the :running state?
# File lib/t2-server/run.rb 672 def running? 673 status == :running 674 end
Start this run on the server. Returns true if the run was started, false otherwise.
Raises RunStateError
if the run is not in the :initialized state.
# File lib/t2-server/run.rb 342 def start 343 state = status 344 raise RunStateError.new(state, :initialized) if state != :initialized 345 346 # set all the inputs 347 _check_and_set_inputs unless baclava_input? 348 349 begin 350 @server.update(links[:status], Status.to_text(:running), "text/plain", 351 @credentials) 352 rescue ServerAtCapacityError => sace 353 false 354 end 355 end
Get the start time of this run as an instance of class Time.
# File lib/t2-server/run.rb 711 def start_time 712 Time.parse(@server.read(links[:starttime], "text/plain", @credentials)) 713 end
Get the status of this run. Status can be one of :initialized, :running or :finished.
# File lib/t2-server/run.rb 324 def status 325 return :deleted if @deleted 326 return :finished if @finished 327 328 state = Status.to_sym(@server.read(links[:status], "text/plain", 329 @credentials)) 330 331 @finished = (state == :finished) 332 state 333 end
Get anything that the run printed to the standard error stream.
# File lib/t2-server/run.rb 394 def stderr 395 @server.read(links[:stderr], "text/plain", @credentials) 396 end
Get anything that the run printed to the standard out stream.
# File lib/t2-server/run.rb 386 def stdout 387 @server.read(links[:stdout], "text/plain", @credentials) 388 end
Return a list of all the URIs of trusts that have been registered for this run. At present there is no way to differentiate between trusts without noting the URI returned when originally uploaded. Only the owner of a run may query its trusts. nil
is returned if a user other than the owner uses this method.
# File lib/t2-server/run.rb 932 def trusts 933 return unless owner? 934 935 t_uris = [] 936 doc = xml_document(@server.read(links[:sec_trusts], "application/xml", 937 @credentials)) 938 939 xpath_find(doc, @@xpaths[:sec_trust]). each do |t| 940 t_uris << URI.parse(xml_node_attribute(t, "href")) 941 end 942 943 t_uris 944 end
Upload data to the server and store it in remote_file
. The remote directory to put this file in can also be specified, but if it is it must first have been created by a call to Run#mkdir
.
Returns the URI of the file on the server in which the data has been stored.
# File lib/t2-server/run.rb 461 def upload_data(data, remote_name, remote_directory = "") 462 location_uri = Util.append_to_uri_path(links[:wdir], remote_directory) 463 @server.upload_data(data, remote_name, location_uri, @credentials) 464 end
Upload a file, with name filename, to the server. Possible values that can be passed in via params are:
-
:dir - The directory to upload to. If this is not left blank the corresponding directory will need to have been created by
Run#mkdir
. -
:rename - Save the file on the server with a different name.
The name of the file on the server is returned.
# File lib/t2-server/run.rb 444 def upload_file(filename, params={}) 445 location = params[:dir] || "" 446 uri = Util.append_to_uri_path(links[:wdir], location) 447 rename = params[:rename] || "" 448 file_uri = @server.upload_file(filename, uri, rename, @credentials) 449 Util.get_path_leaf_from_uri(file_uri) 450 end
Wait (block) for this run to finish. How often (in seconds) the run is tested for completion can be specified with check_interval.
Raises RunStateError
if the run is still in the :initialized state.
# File lib/t2-server/run.rb 364 def wait(interval = 1) 365 state = status 366 raise RunStateError.new(state, :running) if state == :initialized 367 368 # wait 369 until finished? 370 sleep(interval) 371 end 372 end
Get the workflow that this run represents.
# File lib/t2-server/run.rb 311 def workflow 312 if @workflow == "" 313 @workflow = @server.read(links[:workflow], "application/xml", 314 @credentials) 315 end 316 @workflow 317 end
Get the working directory of this run directly from the server in zip format.
Calling this method with no parameters will simply return a blob of zipped data. Providing a filename will stream the data directly to that file and return the number of bytes written. Passing in an object that has a write
method (for example, an instance of File or IO) will stream the zip data directly to that object and return the number of bytes that were streamed. Passing in a block will allow access to the underlying data stream:
run.zip_output do |chunk| print chunk end
Raises RunStateError
if the run has not finished running.
# File lib/t2-server/run.rb 648 def zip_output(param = nil, port = "", &block) 649 raise ArgumentError, 650 "both a parameter and block given for zip_output" if param && block 651 652 state = status 653 raise RunStateError.new(state, :finished) if state != :finished 654 655 path = port.empty? ? "out" : "out/#{port}" 656 output_uri = Util.append_to_uri_path(links[:wdir], path) 657 download_or_stream(param, output_uri, "application/zip", &block) 658 end
Private Instance Methods
Check each input to see if it requires a list input and call the requisite upload method for the entire set of inputs.
# File lib/t2-server/run.rb 1048 def _check_and_set_inputs 1049 lists = false 1050 input_ports.each_value do |port| 1051 if port.depth > 0 1052 lists = true 1053 break 1054 end 1055 end 1056 1057 lists ? _fake_lists : _set_all_inputs 1058 end
Check that the uri passed in is suitable for credential use:
* rserve uris must not have a path. * http(s) uris must have at least "/" as their path.
# File lib/t2-server/run.rb 1110 def _check_cred_uri(uri) 1111 u = URI(uri) 1112 1113 case u.scheme 1114 when "rserve" 1115 u.path = "" 1116 when /https?/ 1117 u.path = "/" if u.path == "" 1118 end 1119 1120 u.to_s 1121 end
Fake being able to handle lists as inputs by converting everything into one big baclava document and uploading that. This has to be done for all inputs or none at all. The inputs must have been set prior to this call using the InputPort
API.
# File lib/t2-server/run.rb 1085 def _fake_lists 1086 data_map = {} 1087 1088 input_ports.each_value do |port| 1089 next unless port.set? 1090 1091 if port.file? 1092 unless port.remote_file? 1093 file = File.read(port.file) 1094 data_map[port.name] = Taverna::Baclava::Node.new(file) 1095 end 1096 else 1097 data_map[port.name] = Taverna::Baclava::Node.new(port.value) 1098 end 1099 end 1100 1101 # Create and upload the baclava data. 1102 baclava = Taverna::Baclava::Writer.write(data_map) 1103 upload_data(baclava, "in.baclava") 1104 @server.update(links[:baclava], "in.baclava", "text/plain", @credentials) 1105 end
# File lib/t2-server/run.rb 1123 def _get_input_port_info 1124 port_desc = @server.read(links[:inputexp], "application/xml", 1125 @credentials) 1126 1127 doc = xml_document(port_desc) 1128 1129 _get_port_info(doc, :port_in) 1130 end
# File lib/t2-server/run.rb 1215 def _get_io_properties_links(links) 1216 links[:io] = Util.append_to_uri_path(links[:listeners], "io") 1217 [:stdout, :stderr, :exitcode].each do |res| 1218 links[res] = Util.append_to_uri_path(links[:io], "properties/#{res}") 1219 end 1220 end
# File lib/t2-server/run.rb 1132 def _get_output_port_info 1133 begin 1134 port_desc = @server.read(links[:output], "application/xml", @credentials) 1135 rescue AttributeNotFoundError => anfe 1136 return {} 1137 end 1138 1139 doc = xml_document(port_desc) 1140 1141 _get_port_info(doc, :port_out) 1142 end
# File lib/t2-server/run.rb 1144 def _get_port_info(doc, type) 1145 ports = {} 1146 1147 xpath_find(doc, @@xpaths[type]).each do |desc| 1148 port = if type == :port_out 1149 OutputPort.new(self, desc) 1150 else 1151 InputPort.new(self, desc) 1152 end 1153 ports[port.name] = port 1154 end 1155 1156 ports 1157 end
# File lib/t2-server/run.rb 1159 def _get_run_description 1160 if @run_doc.nil? 1161 @run_doc = xml_document(@server.read(@uri, "application/xml", 1162 @credentials)) 1163 end 1164 1165 @run_doc 1166 end
# File lib/t2-server/run.rb 1174 def _get_run_links 1175 doc = _get_run_description 1176 1177 # first parse out the basic stuff 1178 links = get_uris_from_doc(doc, [:expiry, :workflow, :status, 1179 :createtime, :starttime, :finishtime, :wdir, :inputs, :output, 1180 :securectx, :listeners, :name, :feed, :gen_prov, :run_bundle]) 1181 1182 # Working dir links 1183 _get_wdir_links(links) 1184 1185 # get inputs 1186 inputs = @server.read(links[:inputs], "application/xml",@credentials) 1187 doc = xml_document(inputs) 1188 1189 links.merge! get_uris_from_doc(doc, [:baclava, :inputexp]) 1190 1191 # IO properties links 1192 _get_io_properties_links(links) 1193 1194 # Security properties links - only available to the owner of a run 1195 if owner? 1196 _get_security_links(links) 1197 end 1198 1199 links 1200 end
# File lib/t2-server/run.rb 1168 def _get_run_owner 1169 doc = _get_run_description 1170 1171 xpath_attr(doc, @@xpaths[:run_desc], "owner") 1172 end
# File lib/t2-server/run.rb 1222 def _get_security_links(links) 1223 securectx = @server.read(links[:securectx], "application/xml", 1224 @credentials) 1225 doc = xml_document(securectx) 1226 1227 links.merge! get_uris_from_doc(doc, 1228 [:sec_creds, :sec_perms, :sec_trusts]) 1229 end
# File lib/t2-server/run.rb 1202 def _get_wdir_links(links) 1203 # Logs directory 1204 links[:logdir] = Util.append_to_uri_path(links[:wdir], "logs") 1205 1206 # Log file 1207 links[:logfile] = Util.append_to_uri_path(links[:logdir], "detail.log") 1208 1209 # Interaction working directory, if we have a feed. 1210 unless links[:feed].nil? 1211 links[:feeddir] = Util.append_to_uri_path(links[:wdir], "interactions") 1212 end 1213 end
Set all the inputs on the server. The inputs must have been set prior to this call using the InputPort
API.
# File lib/t2-server/run.rb 1062 def _set_all_inputs 1063 input_ports.each_value do |port| 1064 next unless port.set? 1065 1066 uri = Util.append_to_uri_path(links[:inputs], "input/#{port.name}") 1067 if port.file? 1068 # If we're using a local file upload it first then set the port to 1069 # use a remote file. 1070 port.remote_file = upload_file(port.file) unless port.remote_file? 1071 1072 xml_value = xml_input_fragment(port.file, :file) 1073 else 1074 xml_value = xml_input_fragment(port.value) 1075 end 1076 1077 @server.update(uri, xml_value, "application/xml", @credentials) 1078 end 1079 end
# File lib/t2-server/run.rb 1231 def download_or_stream(param, uri, type, &block) 1232 if param.respond_to? :write 1233 @server.read_to_stream(param, uri, type, @credentials) 1234 elsif param.instance_of? String 1235 @server.read_to_file(param, uri, type, @credentials) 1236 else 1237 @server.read(uri, type, @credentials, &block) 1238 end 1239 end
# File lib/t2-server/run.rb 1042 def links 1043 @links ||= _get_run_links 1044 end