|
9 | 9 | With this information the utility can calculate in normalized units the
|
10 | 10 | CPU time remaining for a given slot.
|
11 | 11 | """
|
| 12 | +import os |
12 | 13 | import shlex
|
13 | 14 |
|
14 | 15 | import DIRAC
|
@@ -136,6 +137,47 @@ def _getBatchSystemPlugin(self):
|
136 | 137 | jobID = batchSystemInfo.get("JobID")
|
137 | 138 | parameters = batchSystemInfo.get("Parameters")
|
138 | 139 |
|
| 140 | + ########################################################################################### |
| 141 | + # TODO: remove the following block in v9.0 |
| 142 | + # This is a temporary fix for the case where the batch system is not set in the configuration |
| 143 | + if not type: |
| 144 | + self.log.warn( |
| 145 | + "Batch system info not set in local configuration: trying to guess from environment variables." |
| 146 | + ) |
| 147 | + self.log.warn("Consider updating your pilot version before switching to v9.0.") |
| 148 | + batchSystemInfo = { |
| 149 | + "LSF": { |
| 150 | + "JobID": "LSB_JOBID", |
| 151 | + "Parameters": { |
| 152 | + "BinaryPath": "LSB_BINDIR", |
| 153 | + "Host": "LSB_HOSTS", |
| 154 | + "InfoPath": "LSB_ENVDIR", |
| 155 | + "Queue": "LSB_QUEUE", |
| 156 | + }, |
| 157 | + }, |
| 158 | + "PBS": {"JobID": "PBS_JOBID", "Parameters": {"BinaryPath": "PBS_O_PATH", "Queue": "PBS_O_QUEUE"}}, |
| 159 | + "SGE": {"JobID": "SGE_TASK_ID", "Parameters": {"BinaryPath": "SGE_BINARY_PATH", "Queue": "QUEUE"}}, |
| 160 | + "SLURM": {"JobID": "SLURM_JOB_ID", "Parameters": {}}, |
| 161 | + "HTCondor": {"JobID": "HTCONDOR_JOBID", "Parameters": {"InfoPath": "_CONDOR_JOB_AD"}}, |
| 162 | + } |
| 163 | + type = None |
| 164 | + for batchSystem, attributes in batchSystemInfo.items(): |
| 165 | + if attributes["JobID"] in os.environ: |
| 166 | + type = batchSystem |
| 167 | + jobID = os.environ[attributes["JobID"]] |
| 168 | + parameters = {} |
| 169 | + for parameterName, parameterVariable in attributes["Parameters"].items(): |
| 170 | + parameters[parameterName] = os.environ.get(parameterVariable) |
| 171 | + break |
| 172 | + |
| 173 | + if not type and "MACHINEFEATURES" in os.environ and "JOBFEATURES" in os.environ: |
| 174 | + # Only use MJF if legacy batch system information not available for now |
| 175 | + type = "MJF" |
| 176 | + jobID = os.environ.get("JOB_ID") |
| 177 | + parameters = {"Queue": os.environ.get("QUEUE")} |
| 178 | + |
| 179 | + ########################################################################################### |
| 180 | + |
139 | 181 | if not type or type == "Unknown":
|
140 | 182 | self.log.warn(f"Batch system type for site {DIRAC.siteName()} is not currently supported")
|
141 | 183 | return S_ERROR(DErrno.ERESUNK, "Current batch system is not supported")
|
|
0 commit comments