Skip to content

Commit eb1d1c7

Browse files
Robin-Van-de-MerghelRobin VAN DE MERGHEL
authored andcommitted
fix: Small fixes
1 parent 356211a commit eb1d1c7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/DIRAC/WorkloadManagementSystem/FutureClient/PilotManagerClient.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ def clearPilots(self, interval=30, aborted_interval=7):
4747
@convertToReturnValue
4848
def deletePilots(self, pilot_stamps):
4949
with DiracXClient() as api:
50+
pilot_ids = None
51+
if isinstance(pilot_stamps, list[int]):
52+
# Multiple elements (int)
53+
pilot_ids = pilot_stamps # Semantic
54+
elif isinstance(pilot_stamps, int):
55+
# Only one element (int)
56+
pilot_ids = [pilot_stamps]
57+
elif isinstance(pilot_stamps, str):
58+
# Only one element (str)
59+
pilot_stamps = [pilot_stamps]
60+
# Else: pilot_stamps should be list[str] (or the input is random)
61+
62+
if pilot_ids:
63+
# If we have defined pilot_ids, then we have to change them to pilot_stamps
64+
query = [{"parameter": "PilotID", "operator": "in", "value": pilot_ids}]
65+
66+
pilots = api.pilots.search(parameters=["PilotStamp"], search=query, sort=[])
67+
pilot_stamps = [pilot["PilotStamp"] for pilot in pilots]
68+
5069
api.pilots.delete_pilots(pilot_stamps=pilot_stamps)
5170

5271
@convertToReturnValue

0 commit comments

Comments
 (0)