[GE users] DRMAA Job submission with '-C' (directive_prefix) option

Daniel Templeton Dan.Templeton at Sun.COM
Thu Jun 22 18:55:00 BST 2006


    [ The following text is in the "ISO-8859-1" character set. ]
    [ Your display is set for the "ISO-8859-10" character set.  ]
    [ Some special characters may be displayed incorrectly. ]

Sreenath,

The problem is that by default DRMAA does not interpret scripts because 
it assumes they're actually binaries.  In order to get the directives 
processed, you have to pass "-b n" into the native spec.  I have a blog 
post about it here:

http://blogs.sun.com/roller/page/templedf?entry=running_job_scripts_with_drmaa

Daniel

Sreenath Nampally wrote:
> Excuse the wrong subject in my earlier email.. Resending it.
>
> I am trying to submit the attached script (Generated dynamically by a 
> java class)
> using DRMAA but for some reason the directives ( lines starting with 
> #SGE_DIRECTIVES)
> in the script are not honored even though the job runs on the grid.
>
> If I submit the same script at the command line using
> 'qsub -b n -C "#SGE_DIRECTIVE" sge_job' , it works fine
>
> Following is the java code that submits the job using DRMAA. Is 
> 'setNativeSpecification'
> the right method to specify the directive string or is there another 
> way of doing it?
>
> Thanks for the help.
> Sree
>
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
>
>
> //Create a Session factory object
> SessionFactory factory = SessionFactory.getFactory();
> Session session = factory.getSession();
> String id = null;
> try {
> session.init(null);
> String sgeSubmitFile = "sge_job.sh";
> JobTemplate jobTemplate = session.createJobTemplate();
>
> System.out.println("The DRMAA submission file name is " + 
> sgeSubmitFile.getName());
> jobTemplate.setRemoteCommand(sgeSubmitFile.getAbsolutePath());
> jobTemplate.setNativeSpecification("-b n -C \"#SGE_DIRECTIVE\"");
> // I tried the following ways also
> //jobTemplate.setNativeSpecification("-b n -C #SGE_DIRECTIVE");
> //jobTemplate.setNativeSpecification("-b n -C '#SGE_DIRECTIVE'");
>
> System.out.println("Submitting job " + jobTemplate.toString());
> id = session.runJob(jobTemplate);
> System.out.println("Waiting for job " + id + " job finish");
> JobInfo jobInfo = session.wait(id, 300);
> System.out.println("Job " + id + " finished with exit value " + 
> jobInfo.getExitStatus());
> // Set job template to null
> jobTemplate = null;
> // Exit session
> session.exit();
> } catch (DrmaaException dre) {
> // TODO: handle exception
> dre.printStackTrace();
> System.out.println(dre.getMessage());
> throw dre;
> }
>
> ------------------------------------------------------------------------
>
> #!/bin/bash
> #
> # generated SGE submit file for HTC command 1234
> # submitted for user null
> # There are four sections to this file
> # 1. SGE Configuration settings
> # 2. Environment settings
> # 3. Running outside of SGE
> # 4. Run Command
> ############
> # Section 1: SGE Configuration
> ############
>
> # SGE Interpret this script with the Bourne shell
> #SGE_DIRECTIVE -S /usr/local/bin/bash
>
> # NOTE: you need to 'cd' to the intial dir before submitting
> #SGE_DIRECTIVE -cwd
>
> # stdout goes to 
> #SGE_DIRECTIVE -o /usr/local/scratch/sree/drmaa.stdout
> # stderr goes to 
> #SGE_DIRECTIVE -e /usr/local/scratch/sree/drmaa.stderr
>
>
> # config variables
> #SGE_DIRECTIVE -l fast
> #SGE_DIRECTIVE -p 10
> #SGE_DIRECTIVE -N sleeper.pl
>
> ############
> # Section 2: Environment Setup Configuration
> ############
> # copy current environment
> #SGE_DIRECTIVE -V 
>
> ############
> # Section 3: Uncomment to run outside of sge 
> ############
> export CKPT_DIR=/home/sgetest/pre-prodn-htc/server/working/resched
> cd /local/scratch/sree
>
> ############
> # Section 4: Run Command
> ############
> trap "sig 1" USR1
> trap "sig 2" USR2
> sig() {
>   SIGNAL=$1
>   MARATHON=false
>   # Apparently, SGE notifies the script multiple times about the 
>   # pending KILL signal, but only reschedule it on the 1st notification
>   sigcounter=`echo $(($sigcounter + 1))`
>   if [ "$sigcounter" -eq 1 ]; then
>      # Call trap.sh, which alters the job and reschedules it
> /home/sgetest/pre-prodn-htc/server/bin/trap.sh $JOB_ID $SIGNAL $CKPT_DIR ""
>      trap_ret=$?
>   fi
> }
> /usr/local/scratch/sree/sleeper.pl 
> sge_ret_val=$?
> sdate=$(date)
> if [ -e "${CKPT_DIR}/${JOB_ID}.resched" ]; then
>     rm -f ${CKPT_DIR}/${JOB_ID}.resched
> fi
> # end of submit file 
>
>   
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe at gridengine.sunsource.net
> For additional commands, e-mail: users-help at gridengine.sunsource.net
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at gridengine.sunsource.net
For additional commands, e-mail: users-help at gridengine.sunsource.net




More information about the gridengine-users mailing list