@@ -141,68 +141,6 @@ def getNumberOfGPUs(siteName=None, gridCE=None, queue=None):
141141 return 0
142142
143143
144- def getJobParameters (jobIDs : list [int ], parName : str | None , vo : str = "" ) -> dict :
145- """Utility to get a job parameter for a list of jobIDs pertaining to a VO.
146- If the jobID is not in the JobParametersDB, it will be looked up in the JobDB.
147-
148- Requires direct access to the JobParametersDB and JobDB.
149-
150- :param jobIDs: list of jobIDs
151- :param parName: name of the parameter to be retrieved
152- :param vo: VO of the jobIDs
153- :return: dictionary with jobID as key and the parameter as value
154- :rtype: dict
155- """
156- from DIRAC .WorkloadManagementSystem .DB .JobParametersDB import JobParametersDB
157- from DIRAC .WorkloadManagementSystem .DB .JobDB import JobDB
158-
159- elasticJobParametersDB = JobParametersDB ()
160- jobDB = JobDB ()
161-
162- if vo : # a user is connecting, with a proxy
163- res = elasticJobParametersDB .getJobParameters (jobIDs , vo , parName )
164- if not res ["OK" ]:
165- return res
166- parameters = res ["Value" ]
167- else : # a service is connecting, no proxy, e.g. StalledJobAgent
168- q = f"SELECT JobID, VO FROM Jobs WHERE JobID IN ({ ',' .join ([str (jobID ) for jobID in jobIDs ])} )"
169- res = jobDB ._query (q )
170- if not res ["OK" ]:
171- return res
172- if not res ["Value" ]:
173- return S_OK ({})
174- # get the VO for each jobID
175- voDict = {}
176- for jobID , vo in res ["Value" ]:
177- if vo not in voDict :
178- voDict [vo ] = []
179- voDict [vo ].append (jobID )
180- # get the parameters for each VO
181- parameters = {}
182- for vo , jobIDs in voDict .items ():
183- res = elasticJobParametersDB .getJobParameters (jobIDs , vo , parName )
184- if not res ["OK" ]:
185- return res
186- parameters .update (res ["Value" ])
187-
188- # Need anyway to get also from JobDB, for those jobs with parameters registered in MySQL or in both backends
189- res = jobDB .getJobParameters (jobIDs , parName )
190- if not res ["OK" ]:
191- return res
192- parametersM = res ["Value" ]
193-
194- # and now combine
195- final = dict (parametersM )
196- # if job in JobDB, update with parameters from ES if any
197- for jobID in final :
198- final [jobID ].update (parameters .get (jobID , {}))
199- # if job in ES and not in JobDB, take ES
200- for jobID in parameters :
201- if jobID not in final :
202- final [jobID ] = parameters [jobID ]
203- return S_OK (final )
204-
205-
206144def getAvailableRAM (siteName = None , gridCE = None , queue = None ):
207145 """Gets the available RAM on a certain CE/queue/node (what the pilot administers)
208146
0 commit comments