|
4 | 4 | The following methods are available in the Service interface |
5 | 5 | """ |
6 | 6 |
|
7 | | -import DIRAC.Core.Utilities.TimeUtilities as TimeUtilities |
8 | 7 | from DIRAC import S_ERROR, S_OK |
9 | 8 | from DIRAC.ConfigurationSystem.Client.Helpers import Registry |
10 | 9 | from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations |
11 | 10 | from DIRAC.Core.DISET.RequestHandler import RequestHandler |
12 | 11 | from DIRAC.Core.Utilities.DEncode import ignoreEncodeWarning |
13 | 12 | from DIRAC.Core.Utilities.JEncode import strToIntDict |
14 | 13 | from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader |
15 | | -from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations |
16 | 14 | from DIRAC.WorkloadManagementSystem.Client.PilotManagerClient import PilotManagerClient |
17 | 15 | from DIRAC.WorkloadManagementSystem.Service.JobPolicy import RIGHT_GET_INFO, JobPolicy |
| 16 | +from DIRAC.WorkloadManagementSystem.Utilities.JobParameters import getJobParameters |
18 | 17 |
|
19 | 18 |
|
20 | 19 | class JobMonitoringHandlerMixin: |
@@ -444,48 +443,8 @@ def export_getJobParameters(self, jobIDs, parName=None): |
444 | 443 | if not isinstance(jobIDs, list): |
445 | 444 | jobIDs = [jobIDs] |
446 | 445 | jobIDs = [int(jobID) for jobID in jobIDs] |
447 | | - if self.vo: # a user is connecting, with a proxy |
448 | | - res = self.elasticJobParametersDB.getJobParameters(jobIDs, self.vo, parName) |
449 | | - if not res["OK"]: |
450 | | - return res |
451 | | - parameters = res["Value"] |
452 | | - else: # a service is connecting, no proxy, e.g. StalledJobAgent |
453 | | - q = f"SELECT JobID, VO FROM Jobs WHERE JobID IN ({','.join([str(jobID) for jobID in jobIDs])})" |
454 | | - res = self.jobDB._query(q) |
455 | | - if not res["OK"]: |
456 | | - return res |
457 | | - if not res["Value"]: |
458 | | - return S_OK({}) |
459 | | - # get the VO for each jobID |
460 | | - voDict = {} |
461 | | - for jobID, vo in res["Value"]: |
462 | | - if vo not in voDict: |
463 | | - voDict[vo] = [] |
464 | | - voDict[vo].append(jobID) |
465 | | - # get the parameters for each VO |
466 | | - parameters = {} |
467 | | - for vo, jobIDs in voDict.items(): |
468 | | - res = self.elasticJobParametersDB.getJobParameters(jobIDs, vo, parName) |
469 | | - if not res["OK"]: |
470 | | - return res |
471 | | - parameters.update(res["Value"]) |
472 | | - |
473 | | - # Need anyway to get also from JobDB, for those jobs with parameters registered in MySQL or in both backends |
474 | | - res = self.jobDB.getJobParameters(jobIDs, parName) |
475 | | - if not res["OK"]: |
476 | | - return res |
477 | | - parametersM = res["Value"] |
478 | | - |
479 | | - # and now combine |
480 | | - final = dict(parametersM) |
481 | | - # if job in JobDB, update with parameters from ES if any |
482 | | - for jobID in final: |
483 | | - final[jobID].update(parameters.get(jobID, {})) |
484 | | - # if job in ES and not in JobDB, take ES |
485 | | - for jobID in parameters: |
486 | | - if jobID not in final: |
487 | | - final[jobID] = parameters[jobID] |
488 | | - return S_OK(final) |
| 446 | + |
| 447 | + return getJobParameters(jobIDs, parName, self.vo or "") |
489 | 448 |
|
490 | 449 | ############################################################################## |
491 | 450 | types_getAtticJobParameters = [int] |
|
0 commit comments