Skip to content

Commit 806dd7b

Browse files
committed
feat: added PilotManager legacy adaptor
1 parent 8278fc9 commit 806dd7b

2 files changed

Lines changed: 84 additions & 2 deletions

File tree

src/DIRAC/WorkloadManagementSystem/Client/PilotManagerClient.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
""" Module that contains client access to the Pilots handler.
2-
"""
1+
"""Module that contains client access to the Pilots handler."""
32

43
from DIRAC.Core.Base.Client import Client, createClient
4+
from DIRAC.WorkloadManagementSystem.FutureClient.PilotManagerClient import (
5+
PilotManagerClient as futurePilotManagerClient,
6+
)
57

68

79
@createClient("WorkloadManagement/PilotManager")
810
class PilotManagerClient(Client):
911
"""PilotManagerClient sets url for the PilotManagerHandler."""
1012

13+
diracxClient = futurePilotManagerClient
14+
1115
def __init__(self, url=None, **kwargs):
1216
"""
1317
Sets URL for PilotManager handler
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from DIRAC.Core.Security.DiracX import DiracXClient, FutureClient
2+
from DIRAC.Core.Utilities.ReturnValues import convertToReturnValue
3+
4+
5+
class PilotManagerClient(FutureClient):
6+
@convertToReturnValue
7+
def addPilotReferences(
8+
self,
9+
pilot_reference: str,
10+
VO: str,
11+
grid_type: str = "DIRAC",
12+
pilot_stamp_dict: dict = {},
13+
grid_site: str = "Unknown",
14+
destination_site: str = "NotAssigned",
15+
):
16+
"""Add a new pilot to the database.
17+
Uses pilots/management/register_pilot
18+
"""
19+
20+
with DiracXClient() as api:
21+
api.pilots.register_pilot(
22+
pilot_stamp=pilot_stamp_dict[pilot_reference],
23+
vo=VO,
24+
grid_type=grid_type,
25+
grid_site=grid_site,
26+
destination_site=destination_site,
27+
)
28+
29+
@convertToReturnValue
30+
def getPilotInfo(self, pilot_reference: str):
31+
"""Get the info about a given pilot job reference"""
32+
33+
# with DiracXClient() as api:
34+
35+
@convertToReturnValue
36+
def selectPilots(self, conditions_dict: dict):
37+
"""Select pilots given the selection conditions"""
38+
39+
# with DiracXClient() as api:
40+
41+
@convertToReturnValue
42+
def getPilotSummary(self, start_date: str, end_date: str):
43+
"""Get summary of the status of the Pilot Jobs"""
44+
45+
# with DiracXClient() as api:
46+
47+
@convertToReturnValue
48+
def getPilots(self, job_id: str | int):
49+
"""Get pilots executing/having executed a Job"""
50+
51+
# with DiracXClient() as api:
52+
53+
@convertToReturnValue
54+
def setPilotStatus(
55+
self,
56+
pilot_reference: str,
57+
status: str,
58+
destination: str | None = None,
59+
reason: str | None = None,
60+
grid_site: str | None = None,
61+
queue: str | None = None,
62+
pilot_stamp: str | None = None,
63+
):
64+
"""Set the pilot status"""
65+
66+
with DiracXClient() as api:
67+
values_dict = (
68+
{
69+
"PilotStamp": pilot_stamp,
70+
"Status": status,
71+
"DestinationSite": destination,
72+
"StatusReason": reason,
73+
"GridSite": grid_site,
74+
"Queue": queue,
75+
},
76+
)
77+
78+
return api.pilots.update_pilot_metadata(pilot_stamps_to_fields_mapping=[values_dict])

0 commit comments

Comments
 (0)