Skip to content
Ricardo Graciani edited this page Jul 31, 2013 · 8 revisions

DIRAC FAQs

How to set "ApplicationStatus" from my running Job?

You have to use an instance of a JobReport object initialized with the JobID of the running job. To do so you can use a code like the following:

from DIRAC.Core.Base import Script
Script.parseCommandLine()

import DIRAC
from DIRAC.WorkloadManagementSystem.Client.JobReport        import JobReport
import os

# Get the JOBID from the environment (set by the JobWrapper)
jobID = os.environ.get('JOBID',False )
if not jobID:
  DIRAC.gLogger.error( 'JOBID not properly defined' )
else:
  # Create an instance of the JobWrapper
  jobReport = JobReport( jobID, 'MyApp' )
  # Update the Application Status
  jobReport.setApplicationStatus( '%s Running' % jobID )

If you want to report different States of your running application, you may call the setApplicationStatus as many times as you need.

How to set use the JobID in the name of my std.out/err files?

You can make the std.out/err of your jobs to be named using the JobID as part of their name. This will allow you to retrieve them (or to save them as OutputData) into a single directory without them being overwritten. By default the names "std.out" and "std.err" are used and, thus they have to be kept in separated directories.

If you are using a JDL to submit your job, you need to add the following lines:

StdOutput = "my%j.out";
StdError = "%j.err";
    OutputSandbox =
    {
        "%j.err",
        "%j.out"
    };

If you are using Job objects, follow this example:

from DIRAC.Interfaces.API.Job import Job
myJob = Job( stdout = "%j.out", stderr="%j.err" )

If you want to keep then permanently in a StorageElement, you can use the following lines in your JDL:

OutputData = "%j.out";
OutputPath = "DIRAC/OutputPath";

And if your are using the Job interface:

myJob.setOutputData( ["%j.out","%j.err" ], outputPath = 'DIRAC/OutputPath')

In all cases, after the job is received by the JobManager and receives a JobID, it will parse the JDL and replace every appearance of "%j" by the assigned JobID, thus obtaining the expected result.

Clone this wiki locally