Submit Script

Submit the 3DOrchestrate job to the DRM system for execution.

This page discusses:

Description

The submit wrapper script should use command-line options to form an appropriate command to submit the execution job to the DRM system. 3DOrchestrate writes the command arguments and command output to the 3DOrchestrate Distribution Server log file.

Syntax

<submitPath> [<options...>] <stationCommand>

where:

<submitPath> Command specified by the property fiper.system.<drm-name>.submitCommandScriptPath (in the the SMAExeServer.properties file).
<options...>

UI options defined in your <drm-name>_options.xml file. For example: -os Windows -numcores 4.

For example, in the following property (option) definition in a DRM options file:

<!-- Integer input field with default value:  Cores -->
   <Property id="2" name="-numcores" required="true" type="integer" ReadOnlyFlag="false">
      <DisplayName nlsID="input.Title" nlsFile="CustomDRM">Cores</DisplayName>
      <Value>1</Value>
      <Description>Number of cores to utilize</Description>
   </Property>

The name="-numcores" attribute of the <Property> element defines the exact command-line argument and the <Value>1</Value> element defines the value associated with that argument. So for this example, the corresponding option to pass to your submit script is:

-numcores 1
<stationCommand>String specified by the property fiper.system.<drm-name>.transStationCommand.

Return

The submit script should return JavaScript Object Notation (JSON) in the following format:

{
   drmjobid:"<DRM_JOB_ID>",
   jobstatus:"<DRM_JOB_STATUS>",
   message:"<MESSAGE>"
}

where:

<DRM_JOB_ID> ID string of the job.
<DRM_JOB_STATUS>

Job status: either SUCCESS or FAILED.

When <DRM_JOB_STATUS> is SUCCESS, 3DOrchestrate continues to execute the job.

When <DRM_JOB_STATUS> is FAILED, 3DOrchestrate fails the job and records the DRM message in the job log.

<MESSAGE> Any message from the DRM system.
Note: If the submit script is erroneous, 3DOrchestrate fails the job and logs the DRM message in the 3DOrchestrate Distribution Server log file.

Example

An example Perl script for the submit command for IBM Spectrum LSF is shown below.

#!/usr/bin/env perl
#
#SCRIPT ARGUMENTS:  
#    $0 <drm args from xml> <transtation command>
#
#DEBUG OUTPUT: 
#    written to catalina.out when fiper.system.<DRM_NAME>.debugLog=true
#
#SCRIPT OUTPUT
#
#  JSON:
#    {
#       drmjobid: "<DRM_JOB_ID>",
#       jobstatus:"<DRM_JOB_STATUS>",
#       message:  "<MESSAGE>"
#    }
#  where:
#       <DRM_JOB_ID>     =    DRM Job ID
#       <DRM_JOB_STATUS> =    DRM Job Status, Status could be any of the following:
#	                              SUCCESS
#	                              FAILED
#       <MESSAGE>        =    DRM message

use strict;
use JSON;

my %jobInfo;
my $stderrFile = "/tmp/bsub.$$";
my $jobID;
my $status;
my $message;

my @newARGV;
for (my $i=0; $i<=$#ARGV; $i++) {
  #print "$ARGV[$i]\n";
  if ($ARGV[$i] eq "-aba_mem") {
      push(@newARGV,"-R");
      push(@newARGV,"\"rusage\[aba_mem=$ARGV[$i+1]\]\"");
      $i++;
  } elsif ($ARGV[$i] eq "-cputype") {
      push(@newARGV,"-R");
      push(@newARGV,"\"select\[cputype=$ARGV[$i+1]\]\"");
      $i++;
  } elsif ($ARGV[$i] eq "-ppn") {
      push(@newARGV,"-R");
      push(@newARGV,"\"span\[ptile=$ARGV[$i+1]\]\"");
      $i++;
  } elsif ($ARGV[$i] eq "-x") {
      if ($ARGV[$i+1] =~ /true/i) {
         push(@newARGV,"-x");
      }
      $i++;
  } else {
      push(@newARGV,$ARGV[$i]);
  }
}

#if no bsub command is specified, this script will hang due to bsub prompt.
open(BSUB, "bsub @newARGV 2>$stderrFile |");
while(<BSUB>) {
   chomp;
   if (/Job\s+\<(\d+)\>\s+is\s+submitted/) {
        $jobID = $1;
        $status = "SUCCESS";
        $message = "Job submitted successfully.";
   }   
}
close BSUB;

$status = "FAILED" if ($jobID eq "");

if (-e "$stderrFile") {
   open(FILE,"$stderrFile");
   my @file = <FILE>;
   my $file = join(" ",@file);
   close FILE;
   unlink $stderrFile;
   $message = "$file $message";
}

$jobInfo{'drmjobid'}  = $jobID;
$jobInfo{'jobstatus'} = $status;
$jobInfo{'message'}   = $message;

my $json = encode_json \%jobInfo;

print "$json" ;

exit 1 if ($status eq "FAILED");
exit 0;