Skip to content

Commit 0835dd8

Browse files
committed
fix: more setup removals
1 parent f48deae commit 0835dd8

File tree

12 files changed

+41
-76
lines changed

12 files changed

+41
-76
lines changed

src/DIRAC/Core/Base/AgentModule.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
"""
22
Base class for all agent modules
33
"""
4+
import datetime
5+
import importlib.metadata
6+
import inspect
47
import os
8+
import signal
59
import threading
610
import time
7-
import signal
8-
import importlib.metadata
9-
import inspect
10-
import datetime
11+
1112
import psutil
1213

1314
import DIRAC
14-
from DIRAC import S_OK, S_ERROR, gConfig, gLogger, rootPath
15-
from DIRAC.Core.Utilities.File import mkDir
15+
from DIRAC import S_ERROR, S_OK, gConfig, gLogger, rootPath
16+
from DIRAC.ConfigurationSystem.Client import PathFinder
17+
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1618
from DIRAC.Core.Utilities import Network, TimeUtilities
17-
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
19+
from DIRAC.Core.Utilities.File import mkDir
1820
from DIRAC.Core.Utilities.ReturnValues import isReturnStructure
19-
from DIRAC.ConfigurationSystem.Client import PathFinder
21+
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
2022
from DIRAC.Core.Utilities.ThreadScheduler import gThreadScheduler
21-
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
2223

2324

2425
class AgentModule:
@@ -68,7 +69,6 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
6869
They are used to populate __codeProperties
6970
7071
The following Options are used from the Configuration:
71-
- /DIRAC/Setup
7272
- Status
7373
- Enabled
7474
- PollingTime default = 120
@@ -113,7 +113,6 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
113113
"loadSection": PathFinder.getAgentSection(loadName),
114114
"cyclesDone": 0,
115115
"totalElapsedTime": 0,
116-
"setup": gConfig.getValue("/DIRAC/Setup", "Unknown"),
117116
"alive": True,
118117
}
119118
self.__moduleProperties["system"], self.__moduleProperties["agentName"] = agentName.split("/")
@@ -201,7 +200,6 @@ def am_initialize(self, *initArgs):
201200
self.log.notice("=" * 40)
202201
self.log.notice(f"Loaded agent module {self.__moduleProperties['fullName']}")
203202
self.log.notice(f" Site: {DIRAC.siteName()}")
204-
self.log.notice(f" Setup: {gConfig.getValue('/DIRAC/Setup')}")
205203
self.log.notice(f" Agent version: {self.__codeProperties['version']}")
206204
self.log.notice(f" DIRAC version: {DIRAC.version}")
207205
self.log.notice(f" DIRAC platform: {DIRAC.getPlatform()}")

src/DIRAC/Core/Base/ExecutorModule.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Just provides a number of functions used by all executors
44
"""
55
import os
6-
from DIRAC import S_OK, S_ERROR, gConfig, gLogger, rootPath
6+
7+
from DIRAC import S_ERROR, S_OK, gConfig, gLogger, rootPath
78
from DIRAC.ConfigurationSystem.Client import PathFinder
8-
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
99
from DIRAC.Core.Utilities.ReturnValues import isReturnStructure
10+
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
1011

1112

1213
class ExecutorModule:
@@ -21,7 +22,6 @@ def _ex_initialize(cls, exeName, loadName):
2122
"loadSection": PathFinder.getExecutorSection(loadName),
2223
"messagesProcessed": 0,
2324
"reconnects": 0,
24-
"setup": gConfig.getValue("/DIRAC/Setup", "Unknown"),
2525
}
2626
cls.__defaults = {}
2727
cls.__defaults["MonitoringEnabled"] = True

src/DIRAC/DataManagementSystem/scripts/dirac_admin_allow_se.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main():
5050
site = switch[1]
5151

5252
# imports
53-
from DIRAC import gConfig, gLogger
53+
from DIRAC import gLogger
5454
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
5555
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites
5656
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
@@ -68,11 +68,6 @@ def main():
6868

6969
ses = resolveSEGroup(ses)
7070
diracAdmin = DiracAdmin()
71-
errorList = []
72-
setup = gConfig.getValue("/DIRAC/Setup", "")
73-
if not setup:
74-
print("ERROR: Could not contact Configuration Service")
75-
DIRAC.exit(2)
7671

7772
res = getProxyInfo()
7873
if not res["OK"]:

src/DIRAC/DataManagementSystem/scripts/dirac_admin_ban_se.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,15 @@ def main():
5858
sites = switch[1].split(",")
5959

6060
# from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI
61-
from DIRAC import gConfig, gLogger
61+
from DIRAC import gLogger
6262
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
6363
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
64+
from DIRAC.DataManagementSystem.Utilities.DMSHelpers import DMSHelpers, resolveSEGroup
6465
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
6566
from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus
66-
from DIRAC.DataManagementSystem.Utilities.DMSHelpers import resolveSEGroup, DMSHelpers
6767

6868
ses = resolveSEGroup(ses)
6969
diracAdmin = DiracAdmin()
70-
setup = gConfig.getValue("/DIRAC/Setup", "")
71-
if not setup:
72-
print("ERROR: Could not contact Configuration Service")
73-
DIRAC.exit(2)
7470

7571
res = getProxyInfo()
7672
if not res["OK"]:

src/DIRAC/Interfaces/scripts/dirac_admin_allow_site.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ def main():
2222
Script.registerArgument("Comment: Reason of the action")
2323
Script.parseCommandLine(ignoreErrors=True)
2424

25-
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
25+
from DIRAC import exit as DIRACExit
26+
from DIRAC import gLogger
2627
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
27-
from DIRAC import exit as DIRACExit, gConfig, gLogger
28+
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
2829

2930
def getBoolean(value):
3031
if value.lower() == "true":
@@ -42,11 +43,6 @@ def getBoolean(value):
4243
diracAdmin = DiracAdmin()
4344
exitCode = 0
4445
errorList = []
45-
setup = gConfig.getValue("/DIRAC/Setup", "")
46-
if not setup:
47-
print("ERROR: Could not contact Configuration Service")
48-
exitCode = 2
49-
DIRACExit(exitCode)
5046

5147
# result = promptUser(
5248
# 'All the elements that are associated with this site will be active, '
@@ -70,10 +66,9 @@ def getBoolean(value):
7066
exitCode = 2
7167
DIRACExit(exitCode)
7268
userName = userName["Value"]
73-
subject = f"{site} is added in site mask for {setup} setup"
74-
body = "Site {} is added to the site mask for {} setup by {} on {}.\n\n".format(
69+
subject = f"{site} is added in site mask"
70+
body = "Site {} is added to the site mask by {} on {}.\n\n".format(
7571
site,
76-
setup,
7772
userName,
7873
time.asctime(),
7974
)

src/DIRAC/Interfaces/scripts/dirac_admin_ban_site.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def main():
2222
Script.registerArgument("Comment: Reason of the action")
2323
Script.parseCommandLine(ignoreErrors=True)
2424

25-
from DIRAC import exit as DIRACExit, gConfig, gLogger
26-
from DIRAC.Core.Utilities.PromptUser import promptUser
27-
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
25+
from DIRAC import exit as DIRACExit
26+
from DIRAC import gLogger
2827
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
28+
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
2929

3030
def getBoolean(value):
3131
if value.lower() == "true":
@@ -43,11 +43,6 @@ def getBoolean(value):
4343
diracAdmin = DiracAdmin()
4444
exitCode = 0
4545
errorList = []
46-
setup = gConfig.getValue("/DIRAC/Setup", "")
47-
if not setup:
48-
print("ERROR: Could not contact Configuration Service")
49-
exitCode = 2
50-
DIRACExit(exitCode)
5146

5247
# result = promptUser(
5348
# 'All the elements that are associated with this site will be banned,'
@@ -71,10 +66,9 @@ def getBoolean(value):
7166
exitCode = 2
7267
DIRACExit(exitCode)
7368
userName = userName["Value"]
74-
subject = f"{site} is banned for {setup} setup"
75-
body = "Site {} is removed from site mask for {} setup by {} on {}.\n\n".format(
69+
subject = f"{site} is banned"
70+
body = "Site {} is removed from site mask by {} on {}.\n\n".format(
7671
site,
77-
setup,
7872
userName,
7973
time.asctime(),
8074
)

src/DIRAC/Resources/Computing/SingularityComputingElement.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ def __getInstallFlags(self, infoDict=None):
175175
setup = infoDict.get("DefaultSetup")
176176
if not setup:
177177
setup = list(infoDict.get("Setups"))[0]
178-
if not setup:
179-
setup = gConfig.getValue("/DIRAC/Setup", "unknown")
180178
setup = str(setup)
181179

182180
diracProject = "DIRAC"
@@ -205,8 +203,6 @@ def __getConfigFlags(infoDict=None):
205203
cfgOpts = []
206204

207205
setup = infoDict.get("DefaultSetup")
208-
if not setup:
209-
setup = gConfig.getValue("/DIRAC/Setup", "unknown")
210206
cfgOpts.append(f"-S '{setup}'")
211207

212208
csServers = infoDict.get("ConfigurationServers")

src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,7 @@ def _getPilotOptions(self, queue: str) -> list[str]:
610610
queueDict = self.queueDict[queue]["ParametersDict"]
611611
pilotOptions = []
612612

613-
setup = gConfig.getValue("/DIRAC/Setup", "unknown")
614-
if setup == "unknown":
615-
self.log.error("Setup is not defined in the configuration")
616-
return []
617-
pilotOptions.append(f"-S {setup}")
618-
opsHelper = Operations(vo=self.vo, setup=setup)
613+
opsHelper = Operations(vo=self.vo)
619614

620615
# Installation defined?
621616
installationName = opsHelper.getValue("Pilot/Installation", "")

src/DIRAC/WorkloadManagementSystem/JobWrapper/test/Test_JobWrapper.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
""" Test class for JobWrapper
22
"""
33
import os
4-
from pathlib import Path
54
import shutil
65
import tempfile
76
import time
7+
from pathlib import Path
88
from unittest.mock import MagicMock
99

1010
import pytest
1111

1212
import DIRAC
13-
from DIRAC import gLogger, S_OK
13+
from DIRAC import S_OK, gLogger
1414
from DIRAC.Core.Utilities import DErrno
1515
from DIRAC.Core.Utilities.ReturnValues import S_ERROR
1616
from DIRAC.DataManagementSystem.Client.test.mock_DM import dm_mock
@@ -19,7 +19,6 @@
1919
from DIRAC.WorkloadManagementSystem.JobWrapper.JobExecutionCoordinator import JobExecutionCoordinator
2020
from DIRAC.WorkloadManagementSystem.JobWrapper.JobWrapper import JobWrapper
2121

22-
2322
gLogger.setLevel("DEBUG")
2423

2524
# -------------------------------------------------------------------------------------------------
@@ -229,7 +228,7 @@ def test_processSuccessfulDiracJobExec(mocker):
229228
jw.outputFile = std_out.name
230229
jw.errorFile = std_err.name
231230
result = jw.process(
232-
command=f"{executable} {os.path.dirname(os.path.abspath(__file__))}/jobDescription.xml --o /DIRAC/Setup=Test",
231+
command=f"{executable} {os.path.dirname(os.path.abspath(__file__))}/jobDescription.xml",
233232
env={},
234233
)
235234

@@ -573,7 +572,7 @@ def test_postProcess_subprocess_not_complete(setup_job_wrapper, mocker, mock_rep
573572
("script-RESC.sh", None, "src/DIRAC/WorkloadManagementSystem/JobWrapper/test/", "Going to reschedule job"),
574573
(
575574
"src/DIRAC/WorkloadManagementSystem/scripts/dirac_jobexec.py",
576-
"src/DIRAC/WorkloadManagementSystem/JobWrapper/test/jobDescription.xml -o /DIRAC/Setup=Test",
575+
"src/DIRAC/WorkloadManagementSystem/JobWrapper/test/jobDescription.xml",
577576
None,
578577
"Application Finished Successfully",
579578
),

src/DIRAC/WorkloadManagementSystem/Utilities/PilotCStoJSONSynchronizer.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
these are incorporated to the file.
55
The module uploads to a web server the latest version of the pilot scripts.
66
"""
7-
import os
7+
import datetime
88
import glob
9+
import os
910
import shutil
1011
import tarfile
11-
import datetime
1212
from typing import Any
1313

1414
from git import Repo
1515

16-
from DIRAC import gLogger, gConfig, S_OK
16+
from DIRAC import S_OK, gConfig, gLogger
1717
from DIRAC.ConfigurationSystem.Client.ConfigurationData import gConfigurationData
1818
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1919
from DIRAC.ConfigurationSystem.Client.Helpers.Path import cfgPath
20-
from DIRAC.Core.Utilities.ReturnValues import DReturnType, DOKReturnType
20+
from DIRAC.Core.Utilities.ReturnValues import DOKReturnType, DReturnType
2121

2222

2323
class PilotCStoJSONSynchronizer:
@@ -40,7 +40,6 @@ def __init__(self):
4040
# pilot sync default parameters
4141
self.pilotRepo = "https://github.com/DIRACGrid/Pilot.git" # repository of the pilot
4242
self.pilotVORepo = "" # repository of the VO that can contain a pilot extension
43-
self.pilotSetup = gConfig.getValue("/DIRAC/Setup", "")
4443
self.projectDir = ""
4544
# where the find the pilot scripts in the VO pilot repository
4645
self.pilotScriptPath = "Pilot" # where the find the pilot scripts in the pilot repository
@@ -87,7 +86,7 @@ def getCSDict(self, includeMasterCS: bool = True) -> DReturnType[Any]:
8786
pilotDict.update(opRes["Value"])
8887

8988
# we still need a pilotVOVersion
90-
self.opsHelper = Operations(setup=self.pilotSetup)
89+
self.opsHelper = Operations()
9190
self.pilotVOVersion = self.opsHelper.getValue("/Pilot/Version")
9291
# if self.pilotVORepo is defined and self.pilotVOVersion is not, syncScripts is likely to fail.
9392
if self.pilotVOVersion is None and self.pilotVORepo:

0 commit comments

Comments
 (0)