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 7457488 commit 9a1e68c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 57 deletions.
55 changes: 13 additions & 42 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,9 +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(self.pp.localConfigFile) # this file is as input
self.cfg.extend(["--cfg", self.pp.localConfigFile]) # this file is as input

checkCmd = "dirac-admin-add-pilot %s %s %s %s --status=Running %s -d" % (
self.pp.pilotReference,
Expand Down Expand Up @@ -674,9 +671,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(self.pp.localConfigFile) # this file is as input
self.cfg.extend(["--cfg", self.pp.localConfigFile]) # this file is as input

# Get the resource description as defined in its configuration
checkCmd = "dirac-resource-get-parameters -S %s -N %s -Q %s %s -d" % (
Expand Down Expand Up @@ -751,9 +746,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(self.pp.localConfigFile) # this file is as input
self.cfg.extend(["--cfg", 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" % (
self.pp.site,
Expand Down Expand Up @@ -827,9 +820,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(self.pp.localConfigFile) # this file is as input
self.cfg.extend(["--cfg", self.pp.localConfigFile]) # this file is as input

if self.debugFlag:
self.cfg.append("-ddd")
Expand Down Expand Up @@ -885,9 +876,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(self.pp.localConfigFile)
self.cfg.extend(["--cfg", self.pp.localConfigFile])

if self.debugFlag:
self.cfg.append("-ddd")
Expand Down Expand Up @@ -918,9 +907,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(self.pp.localConfigFile) # this file is as input
cfg.extend(["--cfg", self.pp.localConfigFile]) # this file is as input

architectureCmd = "%s %s -d" % (self.pp.architectureScript, " ".join(cfg))

Expand All @@ -936,9 +923,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(self.pp.localConfigFile) # this file is also an input
cfg.extend(["--cfg", self.pp.localConfigFile]) # this file is also an input
if self.pp.debugFlag:
cfg.append("-ddd")

Expand Down Expand Up @@ -971,10 +956,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 +978,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,9 +1009,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(self.pp.localConfigFile) # this file is also input
cfg.extend(["--cfg", self.pp.localConfigFile]) # this file is also input
cfg.append("-o /LocalSite/CPUTimeLeft=%s" % str(int(self.pp.jobCPUReq))) # the only real option

configureCmd = "%s %s" % (self.pp.configureScript, " ".join(cfg))
Expand Down Expand Up @@ -1103,9 +1080,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(self.pp.localConfigFile)
self.innerCEOpts.extend(["--cfg", self.pp.localConfigFile])

def __startJobAgent(self):
"""Starting of the JobAgent (or of a user-defined command)"""
Expand All @@ -1118,9 +1093,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.extend(["--cfg", cfg])

if self.pp.executeCmd:
# Execute user command
Expand Down Expand Up @@ -1210,9 +1183,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(self.pp.localConfigFile)
self.inProcessOpts.extend(["--cfg", self.pp.localConfigFile])

def __startJobAgent(self):
"""Starting of the JobAgent"""
Expand Down
15 changes: 0 additions & 15 deletions Pilot/pilotTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,21 +629,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 9a1e68c

Please sign in to comment.