Skip to content

Commit

Permalink
better separation of WM/CMSSW python. Fix #8805 (#8844)
Browse files Browse the repository at this point in the history
  • Loading branch information
belforte authored Nov 27, 2024
1 parent 8d59c1b commit 30bf6e4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/CMSRunAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ def executeUserApplication(cmd=None, scramTool=None, cleanEnv=True):
exception can only be raised by unexpected failures of the Scram wrapper itself
Scram() never raises and returns the exit code from executing 'command'
"""
# possibly needed environment overrides for CMSSW call go here
envOverride = {}
# Do not pass WM PYTHONPATH to CMSSW environment
pythonPath = os.environ.get('PYTHONPATH', '')
envOverride['PYTHONPATH'] = ""
os.environ.update(envOverride)
with tempSetLogLevel(logger=logging.getLogger(), level=logging.DEBUG):
retCode = scramTool(cmd, runtimeDir=os.getcwd(), cleanEnv=cleanEnv)
dest = shutil.move('cmsRun-stdout.log.tmp', 'cmsRun-stdout.log')
Expand All @@ -415,6 +421,10 @@ def executeUserApplication(cmd=None, scramTool=None, cleanEnv=True):
with open('cmsRun-stdout.log', 'a', encoding='utf-8') as fh:
fh.write(scramTool.diagnostic())
print("Error executing application in CMSSW environment.\n\tSee stdout log")
# restore WM PYTHONPATH
envOverride['PYTHONPATH'] = pythonPath
os.environ.update(envOverride)

return retCode


Expand Down Expand Up @@ -682,7 +692,7 @@ def compareBrachListWithReference(branchList, tier):
jobExitCode = None
applicationName = 'CMSSW JOB' if not options.scriptExe else 'ScriptEXE'
print(f"==== {applicationName} Execution started at {UTCNow()} ====")
command = "unset PYTHONPATH; stdbuf -oL -eL " # make sure COMP python does not leak to CMSSW #8805
command = "stdbuf -oL -eL " # make sure COMP python does not leak to CMSSW #8805
if not options.scriptExe:
command += 'cmsRun -j FrameworkJobReport.xml PSet.py'
else:
Expand Down

0 comments on commit 30bf6e4

Please sign in to comment.