Skip to content

Commit

Permalink
import cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Aug 30, 2023
1 parent 07bd1ca commit 2861ba1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/DIRAC/FrameworkSystem/Service/ProxyManagerHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def export_getVOMSProxyWithToken(self, userDN, userGroup, requestPem, requiredLi

def export_exchangeProxyForToken(self):
try:
from diracx.routers.auth import (
from diracx.routers.auth import ( # pylint: disable=import-error
AuthSettings,
create_access_token,
TokenResponse,
Expand Down
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)

0 comments on commit 2861ba1

Please sign in to comment.