Skip to content

Commit

Permalink
Merge branch 'develop' into update-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mesmith75 authored May 22, 2024
2 parents 90a9e35 + 1a13d49 commit 57664aa
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
1 change: 1 addition & 0 deletions ganga/GangaCore/Lib/Condor/Condor.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def prepareSubjob(self, job, jobconfig, master_input_sandbox):
"",
"workdir = os.getcwd()",
"execmd = %s" % repr(exeCmd),
"runenv = os.environ.copy()",
"",
"###VIRTUALIZATION###",
"",
Expand Down
15 changes: 12 additions & 3 deletions ganga/GangaCore/Lib/Localhost/LocalHostExec.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,18 @@ gangadir = ###GANGADIR###
sys.path.insert(0, gangadir)
sys.path.insert(0,os.path.join(os.getcwd(),PYTHON_DIR))

runenv = os.environ.copy()
for key,value in environment.items():
runenv[key] = value
runenv = dict()
result = subprocess.run(["env -i HOME=\"$HOME\" bash -lc '(set -o posix; set)'"],
capture_output=True, encoding='utf-8',
shell=True)
for line in result.stdout.split('\\n'):
varval = line.strip().split('=')
if len(varval) < 2:
pass
else:
content = ''.join(varval[1:])
if not str(content).startswith('() {'):
runenv[varval[0]] = content

outfile=open('stdout','w')
errorfile=open('stderr','w')
Expand Down
21 changes: 21 additions & 0 deletions ganga/GangaCore/test/GPI/TestLocalCleanenv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from GangaCore.testlib.GangaUnitTest import GangaUnitTest


class TestLocalCleanenv(GangaUnitTest):
def testLocalCleanenv(self):
from GangaCore.GPI import Job
from GangaTest.Framework.utils import sleep_until_completed, file_contains

envname = 'LocalCleanenv_sjt5p'
os.environ[envname] = 'Test'
os.environ['PATH'] = os.environ['PATH'] + ':' + envname

j = Job()

j.submit()

self.assertTrue(sleep_until_completed(j, 60), 'Timeout on completing job')

self.assertEqual(j.status, 'completed')
self.assertFalse(file_contains(j.outputdir + '/stdout', envname))
6 changes: 2 additions & 4 deletions ganga/GangaLHCb/Utility/LHCbDIRACenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ def store_dirac_environment():
# except KeyError:
# logger.error("Environment variable %s is missing. Can't cache LHCbDIRAC environment.", platform_env_var)
# raise PluginError
# While LHCbDirac is only available for gcc49 we shall unfortunately hard-code the platform.
platform = 'x86_64-slc6-gcc49-opt'

requestedVersion = GangaCore.Utility.Config.getConfig('LHCb')['LHCbDiracVersion']

if not requestedVersion == 'prod':
logger.warn(
f"Specific DIRAC version ({requestedVersion}) is set in the [LHCb]LHCbDiracVersion configuration parameter. Unless you really know what you are doing, this should not be done.")

fdir = join(expanduser("~/.cache/Ganga/GangaLHCb"), platform)
fdir = expanduser("~/.cache/Ganga/GangaLHCb")
fname = join(fdir, requestedVersion)

cmd = (
Expand All @@ -50,7 +48,7 @@ def store_dirac_environment():
raise OptionValueError(f"LHCbDirac version {requestedVersion} does not exist")
try:
write_env_cache(env, fname)
logger.debug(f"Storing new LHCbDirac environment ({requestedVersion}:{platform})")
logger.debug(f"Storing new LHCbDirac environment ({requestedVersion})")
except (OSError, IOError, TypeError):
logger.error("Unable to store LHCbDirac environment")
raise PluginError
Expand Down

0 comments on commit 57664aa

Please sign in to comment.