Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor TFC override for multi-step jobs; adopt SITECONF_PATH during runtime - wmagent branch #11483

Merged
merged 2 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/python/WMCore/Storage/SiteLocalConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def loadSiteLocalConfig():

Runtime Accessor for the site local config.

Requires that CMS_PATH is defined as an environment variable
Requires that SITECONFIG_PATH is defined as an environment variable

"""
overVarName = "WMAGENT_SITE_CONFIG_OVERRIDE"
Expand All @@ -39,11 +39,11 @@ def loadSiteLocalConfig():
msg = "%s env. var. provided but not pointing to an existing file, ignoring." % overVarName
logging.log(logging.ERROR, msg)

defaultPath = "$CMS_PATH/SITECONF/local/JobConfig/site-local-config.xml"
defaultPath = "$SITECONFIG_PATH/JobConfig/site-local-config.xml"
actualPath = os.path.expandvars(defaultPath)
if os.environ.get("CMS_PATH", None) is None:
if os.environ.get("SITECONFIG_PATH", None) is None:
msg = "Unable to find site local config file:\n"
msg += "CMS_PATH variable is not defined."
msg += "SITECONFIG_PATH variable is not defined."
raise SiteConfigError(msg)

if not os.path.exists(actualPath):
Expand Down
29 changes: 7 additions & 22 deletions src/python/WMCore/WMRuntime/Scripts/SetupCMSSWPset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Create a CMSSW PSet suitable for running a WMAgent job.

"""

from builtins import next, object

import json
Expand All @@ -17,7 +16,6 @@
from PSetTweaks.WMTweak import makeJobTweak, makeOutputTweak, makeTaskTweak, resizeResources
from Utils.Utilities import decodeBytesToUnicode, encodeUnicodeToBytes
from WMCore.Storage.SiteLocalConfig import loadSiteLocalConfig
from WMCore.Storage.TrivialFileCatalog import TrivialFileCatalog
from WMCore.WMRuntime.ScriptInterface import ScriptInterface
from WMCore.WMRuntime.Tools.Scram import Scram

Expand Down Expand Up @@ -333,32 +331,19 @@ def handleChainedProcessingTweak(self):
"""
_handleChainedProcessing_

In order to handle chained processing it's necessary to feed
output of one step/task (nomenclature ambiguous) to another.
This method creates particular mapping in a working Trivial
File Catalog (TFC).
When a job has multiple cmsRun steps, we need to tweak the
subsequent PSet configuration such that it reads file in
from the local disk (job sandbox).
"""
self.logger.info("Handling chained processing job")
# first, create an instance of TrivialFileCatalog to override
tfc = TrivialFileCatalog()

# check the jobs input files
inputFile = ("../%s/%s.root" % (self.step.data.input.inputStepName,
self.step.data.input.inputOutputModule))
tfc.addMapping("direct", inputFile, inputFile, mapping_type="lfn-to-pfn")
tfc.addMapping("direct", inputFile, inputFile, mapping_type="pfn-to-lfn")
inputFile = ("file:../%s/%s.root" % (self.step.data.input.inputStepName,
self.step.data.input.inputOutputModule))

self.tweak.addParameter('process.source.fileNames', "customTypeCms.untracked.vstring(%s)" % [inputFile])
self.tweak.addParameter("process.maxEvents", "customTypeCms.untracked.PSet(input=cms.untracked.int32(-1))")

tfcName = "override_catalog.xml"
tfcPath = os.path.join(os.getcwd(), tfcName)
self.logger.info("Creating override TFC and saving into '%s'", tfcPath)
tfcStr = tfc.getXML()
with open(tfcPath, 'w') as tfcFile:
tfcFile.write(tfcStr)

self.step.data.application.overrideCatalog = "trivialcatalog_file:" + tfcPath + "?protocol=direct"

self.logger.info("Chained PSet tweaked with maxEvents: -1, and fileNames: %s", inputFile)
return

def handlePileup(self):
Expand Down
4 changes: 4 additions & 0 deletions src/python/WMCore/WMRuntime/Tools/Scram.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,12 @@ def __call__(self, command, hackLdLibPath=False, runtimeDir=None, cleanEnv=True)
self.procWriter(proc, 'export VO_CMS_SW_DIR=%s\n' % os.environ['VO_CMS_SW_DIR'])
if os.environ.get('OSG_APP', None) is not None:
self.procWriter(proc, 'export VO_CMS_SW_DIR=%s/cmssoft/cms\n' % os.environ['OSG_APP'])
# In general, CMSSW releases <= 12_6_0 will use CMS_PATH, while anything beyond that
# requires the SITECONFIG_PATH variable to properly load storage.xml/json file.
if os.environ.get('CMS_PATH', None) is not None:
self.procWriter(proc, 'export CMS_PATH=%s\n' % os.environ['CMS_PATH'])
if os.environ.get('SITECONFIG_PATH', None) is not None:
self.procWriter(proc, 'export SITECONFIG_PATH=%s\n' % os.environ['SITECONFIG_PATH'])
if os.environ.get('_CONDOR_JOB_AD'):
self.procWriter(proc, 'export _CONDOR_JOB_AD=%s\n' % os.environ['_CONDOR_JOB_AD'])
if os.environ.get('_CONDOR_MACHINE_AD'):
Expand Down
1 change: 1 addition & 0 deletions src/python/WMCore/WMSpec/Steps/Executors/LogCollect.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def execute(self, emulator=None):

# setup Scram needed to run edmCopyUtil
if useEdmCopyUtil:
logging.info("Creating software area for %s under %s", cmsswVersion, scramArch)
scram = Scram(
command=scramCommand,
version=cmsswVersion,
Expand Down