forked from DIRACGrid/DIRAC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
28 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 27 additions & 25 deletions
52
src/DIRAC/WorkloadManagementSystem/FutureClient/JobMonitoringClient.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
# pylint: disable=import-error | ||
from diracx.client import Dirac | ||
from diracx.client.models import JobSearchParams | ||
import os | ||
|
||
from diracx.cli.utils import get_auth_headers | ||
from diracx.core.preferences import DiracxPreferences | ||
if os.getenv("DIRAC_ENABLE_DIRACX_JOB_MONITORING", "No").lower() in ("yes", "true"): | ||
from diracx.client import Dirac | ||
from diracx.client.models import JobSearchParams | ||
|
||
from DIRAC.Core.Utilities.ReturnValues import convertToReturnValue | ||
from diracx.cli.utils import get_auth_headers | ||
from diracx.core.preferences import DiracxPreferences | ||
|
||
from DIRAC.Core.Utilities.ReturnValues import convertToReturnValue | ||
|
||
class JobMonitoringClient: | ||
def __init__(self, *args, **kwargs): | ||
self.endpoint = DiracxPreferences().url | ||
class JobMonitoringClient: | ||
def __init__(self, *args, **kwargs): | ||
self.endpoint = DiracxPreferences().url | ||
|
||
def fetch(self, parameters, jobIDs): | ||
with Dirac(endpoint=self.endpoint) as api: | ||
jobs = api.jobs.search( | ||
parameters=["JobID"] + parameters, | ||
search=[{"parameter": "JobID", "operator": "in", "values": jobIDs}], | ||
headers=get_auth_headers(), | ||
) | ||
return {j["JobID"]: {param: j[param] for param in parameters} for j in jobs} | ||
def fetch(self, parameters, jobIDs): | ||
with Dirac(endpoint=self.endpoint) as api: | ||
jobs = api.jobs.search( | ||
parameters=["JobID"] + parameters, | ||
search=[{"parameter": "JobID", "operator": "in", "values": jobIDs}], | ||
headers=get_auth_headers(), | ||
) | ||
return {j["JobID"]: {param: j[param] for param in parameters} for j in jobs} | ||
|
||
@convertToReturnValue | ||
def getJobsMinorStatus(self, jobIDs): | ||
return self.fetch(["MinorStatus"], jobIDs) | ||
@convertToReturnValue | ||
def getJobsMinorStatus(self, jobIDs): | ||
return self.fetch(["MinorStatus"], jobIDs) | ||
|
||
@convertToReturnValue | ||
def getJobsStates(self, jobIDs): | ||
return self.fetch(["Status", "MinorStatus", "ApplicationStatus"], jobIDs) | ||
@convertToReturnValue | ||
def getJobsStates(self, jobIDs): | ||
return self.fetch(["Status", "MinorStatus", "ApplicationStatus"], jobIDs) | ||
|
||
@convertToReturnValue | ||
def getJobsSites(self, jobIDs): | ||
return self.fetch(["Site"], jobIDs) | ||
@convertToReturnValue | ||
def getJobsSites(self, jobIDs): | ||
return self.fetch(["Site"], jobIDs) |