7 from clustercontrolbase
import ClusterBase
8 from validationscript
import Script
13 A class that provides the controls for running jobs on a (remote)
14 Sun Grid Engine cluster. It provides two methods:
15 - is_job_finished(job): Returns True or False, depending on whether the job
16 has finished execution
17 - execute(job): Takes a job and executes it by sending it to the cluster
23 Check if qsub is available
29 print(
"drmaa library is not installed, please ues 'pip3 install "
32 except RuntimeError
as re:
33 print(
"drmaa library not properly configured")
40 Returns name of this job contol
42 return "cluster-drmaa"
47 Returns description of this job control
49 return "Batch submission via the drmaa interface to Grid Engine"
53 The default constructor.
54 - Holds the current working directory, which is also the location of
55 the shellscripts that are being sent to the cluster.
56 - Initializes a logger which writes to validate_basf2.py's log.
57 - Finds the revision of basf2 that will be set up on the cluster.
63 'requirement_storage}G '
85 This method can be used if path names are different on submission
87 @param path: The past that needs to be adjusted
88 @return: The adjusted path
96 The cluster should always be available to accept new jobs.
97 @return: Will always return True if the function can be called
102 def execute(self, job: Script, options=
'', dry=
False, tag=
'current'):
104 Takes a Script object and a string with options and runs it on the
105 cluster, either with ROOT or with basf2, depending on the file type.
107 @param job: The steering file object that should be executed
108 @param options: Options that will be given to the basf2 command
109 @param dry: Whether to perform a dry run or not
110 @param tag: The folder within the results directory
119 print(str(drmaa.Session))
121 with drmaa.Session()
as session:
122 print(
"got session ")
135 f
'Creating job template for wrapper script {shell_script_name}'
137 jt = session.createJobTemplate()
138 jt.remoteCommand = shell_script_name
140 jt.nativeSpecification = native_spec_string
143 jobid = session.runJob(jt)
145 f
"Script {job.name} started with job id {jobid}"
149 session.deleteJobTemplate(jt)
154 Checks whether the '.done'-file has been created for a job. If so, it
155 returns True, else it returns False.
156 Also deletes the .done-File once it has returned True.
158 @param job: The job of which we want to know if it finished
159 @return: (True if the job has finished, exit code). If we can't find the
160 exit code in the '.done'-file, the returncode will be -666.
161 If the job is not finished, the exit code is returned as 0.
168 if job.job_id
is None:
169 print(
"Job has not been started with cluster drmaaa because "
173 with drmaa.Session()
as session:
177 status = session.jobStatus(job.job_id)
178 except drmaa.errors.InvalidJobException:
179 print(
"Job info for jobid {} cannot be retrieved, assuming "
180 "job has terminated".format(job.job_id))
182 (donefile_exists, donefile_returncode) = \
188 return [
True, donefile_returncode]
194 if status == drmaa.JobState.DONE:
197 if status == drmaa.JobState.FAILED: