Skip to content

Commit

Permalink
feat: removed check for --cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Oct 2, 2023
1 parent e055be2 commit ca3d722
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 46 deletions.
44 changes: 13 additions & 31 deletions Pilot/pilotCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def __init__(self, pilotParams):
import sys
import time
from collections import Counter
from distutils.version import LooseVersion

############################
# python 2 -> 3 "hacks"
Expand Down Expand Up @@ -640,8 +639,7 @@ def execute(self):
pilotOwnerGroup = self.pp.userGroup

if self.pp.localConfigFile:
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
self.cfg.append("--cfg")
self.cfg.append("--cfg")
self.cfg.append(self.pp.localConfigFile) # this file is as input

checkCmd = "dirac-admin-add-pilot %s %s %s %s --status=Running %s -d" % (
Expand Down Expand Up @@ -674,8 +672,7 @@ def execute(self):
if self.pp.useServerCertificate:
self.cfg.append("-o /DIRAC/Security/UseServerCertificate=yes")
if self.pp.localConfigFile:
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
self.cfg.append("--cfg")
self.cfg.append("--cfg")
self.cfg.append(self.pp.localConfigFile) # this file is as input

# Get the resource description as defined in its configuration
Expand Down Expand Up @@ -751,8 +748,7 @@ def execute(self):
if self.pp.useServerCertificate:
self.cfg.append("-o /DIRAC/Security/UseServerCertificate=yes")
if self.pp.localConfigFile:
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
self.cfg.append("--cfg")
self.cfg.append("--cfg")
self.cfg.append(self.pp.localConfigFile) # this file is as input
# Get the worker node parameters
checkCmd = "dirac-wms-get-wn-parameters -S %s -N %s -Q %s %s -d" % (
Expand Down Expand Up @@ -827,8 +823,7 @@ def execute(self):

if self.pp.localConfigFile:
self.cfg.append("-O %s" % self.pp.localConfigFile) # this file is as output
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
self.cfg.append("--cfg")
self.cfg.append("--cfg")
self.cfg.append(self.pp.localConfigFile) # this file is as input

if self.debugFlag:
Expand Down Expand Up @@ -885,8 +880,7 @@ def execute(self):
self.cfg.append("-FDMH")
if self.pp.localConfigFile:
self.cfg.append("-O %s" % self.pp.localConfigFile)
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
self.cfg.append("--cfg")
self.cfg.append("--cfg")
self.cfg.append(self.pp.localConfigFile)

if self.debugFlag:
Expand Down Expand Up @@ -918,8 +912,7 @@ def execute(self):
if self.pp.useServerCertificate:
cfg.append("-o /DIRAC/Security/UseServerCertificate=yes")
if self.pp.localConfigFile:
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
cfg.append("--cfg")
cfg.append("--cfg")
cfg.append(self.pp.localConfigFile) # this file is as input

architectureCmd = "%s %s -d" % (self.pp.architectureScript, " ".join(cfg))
Expand All @@ -936,8 +929,7 @@ def execute(self):
cfg.append("--UseServerCertificate")
if self.pp.localConfigFile:
cfg.append("-O %s" % self.pp.localConfigFile) # our target file for pilots
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
cfg.append("--cfg")
cfg.append("--cfg")
cfg.append(self.pp.localConfigFile) # this file is also an input
if self.pp.debugFlag:
cfg.append("-ddd")
Expand Down Expand Up @@ -971,10 +963,7 @@ def execute(self):
if self.pp.useServerCertificate:
configFileArg = "-o /DIRAC/Security/UseServerCertificate=yes"
if self.pp.localConfigFile:
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
configFileArg = "%s -R %s --cfg %s" % (configFileArg, self.pp.localConfigFile, self.pp.localConfigFile)
else:
configFileArg = "%s -R %s %s" % (configFileArg, self.pp.localConfigFile, self.pp.localConfigFile)
configFileArg = "%s -R %s --cfg %s" % (configFileArg, self.pp.localConfigFile, self.pp.localConfigFile)
retCode, cpuNormalizationFactorOutput = self.executeAndGetOutput(
"dirac-wms-cpu-normalization -U %s -d" % configFileArg, self.pp.installEnv
)
Expand All @@ -996,10 +985,7 @@ def execute(self):
configFileArg = ""
if self.pp.useServerCertificate:
configFileArg = "-o /DIRAC/Security/UseServerCertificate=yes"
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
cfgFile = "--cfg %s" % self.pp.localConfigFile
else:
cfgFile = self.pp.localConfigFile
cfgFile = "--cfg %s" % self.pp.localConfigFile
retCode, cpuTimeOutput = self.executeAndGetOutput(
"dirac-wms-get-queue-cpu-time --CPUNormalizationFactor=%f %s %s -d"
% (cpuNormalizationFactor, configFileArg, cfgFile),
Expand Down Expand Up @@ -1030,8 +1016,7 @@ def execute(self):
cfg.append("-o /DIRAC/Security/UseServerCertificate=yes")
if self.pp.localConfigFile:
cfg.append("-O %s" % self.pp.localConfigFile) # our target file for pilots
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
cfg.append("--cfg")
cfg.append("--cfg")
cfg.append(self.pp.localConfigFile) # this file is also input
cfg.append("-o /LocalSite/CPUTimeLeft=%s" % str(int(self.pp.jobCPUReq))) # the only real option

Expand Down Expand Up @@ -1103,8 +1088,7 @@ def __setInnerCEOpts(self):
# The file pilot.cfg has to be created previously by ConfigureDIRAC
if self.pp.localConfigFile:
self.innerCEOpts.append(" -o /AgentJobRequirements/ExtraOptions=%s" % self.pp.localConfigFile)
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
self.innerCEOpts.append("--cfg")
self.innerCEOpts.append("--cfg")
self.innerCEOpts.append(self.pp.localConfigFile)

def __startJobAgent(self):
Expand All @@ -1118,8 +1102,7 @@ def __startJobAgent(self):
for i in os.listdir(self.pp.rootPath):
cfg = os.path.join(self.pp.rootPath, i)
if os.path.isfile(cfg) and cfg.endswith(".cfg") and not filecmp.cmp(self.pp.localConfigFile, cfg):
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
extraCFG.append("--cfg")
extraCFG.append("--cfg")
extraCFG.append(cfg)

if self.pp.executeCmd:
Expand Down Expand Up @@ -1210,8 +1193,7 @@ def __setInProcessOpts(self):
# The file pilot.cfg has to be created previously by ConfigureDIRAC
if self.pp.localConfigFile:
self.inProcessOpts.append(" -o /AgentJobRequirements/ExtraOptions=%s" % self.pp.localConfigFile)
if LooseVersion(self.releaseVersion) >= self.cfgOptionDIRACVersion:
self.inProcessOpts.append("--cfg")
self.inProcessOpts.append("--cfg")
self.inProcessOpts.append(self.pp.localConfigFile)

def __startJobAgent(self):
Expand Down
15 changes: 0 additions & 15 deletions Pilot/pilotTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,21 +628,6 @@ def __init__(self, pilotParams, dummy=""):

self.log.debug("Initialized command %s" % self.__class__.__name__)
self.log.debug("pilotParams option list: %s" % self.pp.optList)
self.cfgOptionDIRACVersion = self._getCFGOptionDIRACVersion()

def _getCFGOptionDIRACVersion(self):
"""Convenience method.
Reference vanilla DIRAC version from when we ask to use --cfg for cfg files
For extensions: the only way to know the vanilla DIRAC version
is to check releases.cfg. Not impossible, but cumbersome to do here.
Extensions could replace this function.
"""
if not self.pp.releaseProject:
return LooseVersion(parseVersion("v7r0p29", self.pp.pythonVersion == "27"))
# just a trick to always evaluate comparisons in pilotCommands to False
return LooseVersion("z") if self.pp.pythonVersion == "27" else LooseVersion("1000")

def executeAndGetOutput(self, cmd, environDict=None):
"""Execute a command on the worker node and get the output"""
Expand Down

0 comments on commit ca3d722

Please sign in to comment.