Skip to content

Commit d3a37ac

Browse files
fix: Fixed client to support vector search
1 parent 8ee384c commit d3a37ac

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/DIRAC/WorkloadManagementSystem/FutureClient/PilotManagerClient.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class PilotManagerClient(FutureClient):
66
def get_pilot_stamps_from_refs(self, pilot_references) -> list[str]:
77
with DiracXClient() as api:
88
search = [{"parameter": "PilotJobReference", "operator": "in", "values": pilot_references}]
9-
pilots = api.pilots.search(parameters=["PilotStamp"], search=search, sort=[])[0] # type: ignore
9+
pilots = api.pilots.search(parameters=["PilotStamp"], search=search, sort=[]) # type: ignore
1010

1111
return [pilot["PilotStamp"] for pilot in pilots]
1212

@@ -47,7 +47,10 @@ def setPilotStatus(self, pilot_reference, status, destination=None, reason=None,
4747
def deletePilot(self, pilot_reference):
4848
# Translate ref to stamp (DiracX relies on stamps whereas DIRAC relies on refs)
4949
pilot_stamps = self.get_pilot_stamps_from_refs([pilot_reference])
50-
pilot_stamp = pilot_stamps[0] # We might raise an error. This is so that we spot the error
50+
# We don't want to raise an error.
51+
if not pilot_stamps:
52+
return None
53+
pilot_stamp = pilot_stamps[0]
5154

5255
with DiracXClient() as api:
5356
pilot_stamps = [pilot_stamp]
@@ -155,12 +158,16 @@ def deletePilots(self, pilot_references):
155158
search = []
156159
if pilot_ids:
157160
# If we have defined pilot_ids, then we have to change them to pilot_stamps
158-
search = [{"parameter": "PilotID", "operator": "in", "value": pilot_ids}]
161+
search = [{"parameter": "PilotID", "operator": "in", "values": pilot_ids}]
159162
else:
160163
# If we have defined pilot_ids, then we have to change them to pilot_stamps
161-
search = [{"parameter": "PilotJobReference", "operator": "in", "value": pilot_references}]
164+
search = [{"parameter": "PilotJobReference", "operator": "in", "values": pilot_references}]
162165

163166
pilots = api.pilots.search(parameters=["PilotStamp"], search=search, sort=[]) # type: ignore
164167
pilot_stamps = [pilot["PilotStamp"] for pilot in pilots]
165168

169+
if not pilot_stamps:
170+
# Avoid useless requests
171+
return None
172+
166173
return api.pilots.delete_pilots(pilot_stamps=pilot_stamps) # type: ignore

0 commit comments

Comments
 (0)