|
11 | 11 | * *CompressJDLs*: Enable compression of JDLs when they are stored in the database, default *False*.
|
12 | 12 |
|
13 | 13 | """
|
| 14 | +from __future__ import annotations |
| 15 | + |
14 | 16 | import datetime
|
15 | 17 | import operator
|
| 18 | +from typing import overload |
16 | 19 |
|
17 | 20 | from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getVOForGroup
|
18 | 21 | from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSiteTier
|
19 | 22 | from DIRAC.Core.Base.DB import DB
|
20 | 23 | from DIRAC.Core.Utilities.ClassAd.ClassAdLight import ClassAd
|
21 | 24 | from DIRAC.Core.Utilities.Decorators import deprecated
|
22 | 25 | from DIRAC.Core.Utilities.DErrno import EWMSJMAN, EWMSSUBM, cmpError
|
23 |
| -from DIRAC.Core.Utilities.ReturnValues import S_ERROR, S_OK, convertToReturnValue, returnValueOrRaise, SErrorException |
| 26 | +from DIRAC.Core.Utilities.ReturnValues import ( |
| 27 | + S_ERROR, |
| 28 | + S_OK, |
| 29 | + convertToReturnValue, |
| 30 | + returnValueOrRaise, |
| 31 | + SErrorException, |
| 32 | + DReturnType, |
| 33 | +) |
24 | 34 | from DIRAC.FrameworkSystem.Client.Logger import contextLogger
|
25 | 35 | from DIRAC.ResourceStatusSystem.Client.SiteStatus import SiteStatus
|
26 | 36 | from DIRAC.WorkloadManagementSystem.Client import JobMinorStatus, JobStatus
|
@@ -320,23 +330,42 @@ def getJobOptParameters(self, jobID, paramList=None):
|
320 | 330 |
|
321 | 331 | #############################################################################
|
322 | 332 |
|
323 |
| - def getInputData(self, jobID): |
| 333 | + @overload |
| 334 | + def getInputData(self, jobID: int | str) -> DReturnType[list[str]]: |
| 335 | + ... |
| 336 | + |
| 337 | + @overload |
| 338 | + def getInputData(self, jobID: list[int | str]) -> DReturnType[dict[int, list[str]]]: |
| 339 | + ... |
| 340 | + |
| 341 | + def getInputData(self, jobID: int | str | list[int | str]) -> DReturnType[list[str] | dict[int, list[str]]]: |
324 | 342 | """Get input data for the given job"""
|
325 |
| - ret = self._escapeString(jobID) |
326 |
| - if not ret["OK"]: |
327 |
| - return ret |
328 |
| - jobID = ret["Value"] |
329 |
| - cmd = f"SELECT LFN FROM InputData WHERE JobID={jobID}" |
| 343 | + if isinstance(jobID, (int, str)): |
| 344 | + ret = self._escapeString(jobID) |
| 345 | + if not ret["OK"]: |
| 346 | + return ret |
| 347 | + jobID = ret["Value"] |
| 348 | + query = f"JobID={jobID}" |
| 349 | + result = [] |
| 350 | + else: |
| 351 | + job_ids = {int(i) for i in jobID} |
| 352 | + query = f"JobID IN ({','.join(map(str, job_ids))})" |
| 353 | + result = {i: [] for i in job_ids} |
| 354 | + cmd = f"SELECT JobID, LFN FROM InputData WHERE {query}" |
330 | 355 | res = self._query(cmd)
|
331 | 356 | if not res["OK"]:
|
332 | 357 | return res
|
333 | 358 |
|
334 |
| - inputData = [i[0] for i in res["Value"] if i[0].strip()] |
335 |
| - for index, lfn in enumerate(inputData): |
| 359 | + for jid, lfn in res["Value"]: |
| 360 | + lfn = lfn.strip() |
336 | 361 | if lfn.lower().startswith("lfn:"):
|
337 |
| - inputData[index] = lfn[4:] |
| 362 | + lfn = lfn[4:] |
| 363 | + if isinstance(result, list): |
| 364 | + result.append(lfn) |
| 365 | + else: |
| 366 | + result[jid].append(lfn) |
338 | 367 |
|
339 |
| - return S_OK(inputData) |
| 368 | + return S_OK(result) |
340 | 369 |
|
341 | 370 | #############################################################################
|
342 | 371 | def setInputData(self, jobID, inputData):
|
|
0 commit comments