11#!/usr/bin/env python
2- """ This template will become the job wrapper that's actually executed.
2+ """This template will become the job wrapper that's actually executed.
33
4- The JobWrapperTemplate is completed and invoked by the jobAgent and uses functionalities from JobWrapper module.
5- It has to be an executable.
4+ The JobWrapperTemplate is completed and invoked by the jobAgent and uses functionalities from JobWrapper module.
5+ It has to be an executable.
66
7- The JobWrapperTemplate will reschedule the job according to certain criteria:
8- - the working directory could not be created
9- - the jobWrapper initialization phase failed
10- - the inputSandbox download failed
11- - the resolution of the inpt data failed
12- - the JobWrapper ended with the status DErrno.EWMSRESC
7+ The JobWrapperTemplate will reschedule the job according to certain criteria:
8+ - the working directory could not be created
9+ - the jobWrapper initialization phase failed
10+ - the inputSandbox download failed
11+ - the resolution of the inpt data failed
1312"""
13+
1414import json
1515import os
1616import sys
2424Script .parseCommandLine ()
2525
2626from DIRAC import gLogger
27+
28+ from DIRAC .WorkloadManagementSystem .JobWrapper import JobWrapper as JW
2729from DIRAC .WorkloadManagementSystem .Client .JobReport import JobReport
2830from DIRAC .WorkloadManagementSystem .JobWrapper .JobWrapperUtilities import (
2931 createAndEnterWorkingDirectory ,
@@ -52,7 +54,7 @@ def execute(jobID: int, arguments: dict, jobReport: JobReport):
5254 if "InputSandbox" in arguments ["Job" ]:
5355 jobReport .commit ()
5456 if not transferInputSandbox (job , arguments ["Job" ]["InputSandbox" ]):
55- return 1
57+ return JW . INITIALIZATION_FAILED
5658 else :
5759 gLogger .verbose ("Job has no InputSandbox requirement" )
5860
@@ -61,7 +63,7 @@ def execute(jobID: int, arguments: dict, jobReport: JobReport):
6163 if "InputData" in arguments ["Job" ]:
6264 if arguments ["Job" ]["InputData" ]:
6365 if not resolveInputData (job ):
64- return 1
66+ return JW . INITIALIZATION_FAILED
6567 else :
6668 gLogger .verbose ("Job has a null InputData requirement:" )
6769 gLogger .verbose (arguments )
@@ -71,7 +73,7 @@ def execute(jobID: int, arguments: dict, jobReport: JobReport):
7173 jobReport .commit ()
7274
7375 if not executePayload (job ):
74- return 1
76+ return JW . INITIALIZATION_FAILED
7577
7678 if "OutputSandbox" in arguments ["Job" ] or "OutputData" in arguments ["Job" ]:
7779 if not processJobOutputs (job ):
@@ -85,7 +87,7 @@ def execute(jobID: int, arguments: dict, jobReport: JobReport):
8587##########################################################
8688
8789
88- ret = - 3
90+ ret = JW . JOBWRAPPER_EXCEPTION
8991try :
9092 jsonFileName = os .path .realpath (__file__ ) + ".json"
9193 with open (jsonFileName ) as f :
@@ -105,9 +107,9 @@ def execute(jobID: int, arguments: dict, jobReport: JobReport):
105107 gLogger .exception ("JobWrapperTemplate exception" )
106108 try :
107109 jobReport .commit ()
108- ret = - 1
110+ ret = JW . SUBMISSION_FAILED
109111 except Exception : # pylint: disable=broad-except
110112 gLogger .exception ("Could not commit the job report" )
111- ret = - 2
113+ ret = JW . SUBMISSION_REPORT_FAILED
112114
113115sys .exit (ret )
0 commit comments