Skip to content

Commit

Permalink
Merge pull request #21 from lsst/tickets/DM-41194
Browse files Browse the repository at this point in the history
DM-41194: add user scratch as a configurable item in condor-info
  • Loading branch information
daues authored Oct 16, 2023
2 parents 44f6225 + 3251f3d commit 8a65b98
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
28 changes: 18 additions & 10 deletions python/lsst/ctrl/execute/allocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,18 @@ def __init__(self, platform, opts, configuration, condorInfoFileName):

self.platform = platform

# Look up the user's name and home directory in the
# Look up the user's name and home and scratch directory in the
# $HOME/.lsst/condor-info.py file
# If the platform is lsst, and the user_name or user_home
# is not in there, then default to user running this
# command and the value of $HOME, respectively.
user_name = None
user_home = None
user_scratch = None
for name in condorInfoConfig.platform:
if name == self.platform:
user_name = condorInfoConfig.platform[name].user.name
user_home = condorInfoConfig.platform[name].user.home
if self.platform == "lsst":
if user_name is None:
user_name = pwd.getpwuid(os.geteuid()).pw_name
if user_home is None:
user_home = os.getenv("HOME")
user_scratch = condorInfoConfig.platform[name].user.scratch
if user_scratch is None and "SCRATCH" in os.environ:
user_scratch = os.environ["SCRATCH"]
if user_name is None:
raise RuntimeError(
"error: %s does not specify user name for platform == %s"
Expand All @@ -90,8 +86,14 @@ def __init__(self, platform, opts, configuration, condorInfoFileName):
"error: %s does not specify user home for platform == %s"
% (condorInfoFileName, self.platform)
)
if user_scratch is None:
raise RuntimeError(
"error: %s does not specify user scratch for platform == %s"
% (condorInfoFileName, self.platform)
)
self.defaults["USER_NAME"] = user_name
self.defaults["USER_HOME"] = user_home
self.defaults["USER_SCRATCH"] = user_scratch
self.commandLineDefaults = {}
self.commandLineDefaults["NODE_COUNT"] = self.opts.nodeCount
self.commandLineDefaults["CPUS"] = self.opts.cpus
Expand Down Expand Up @@ -135,7 +137,7 @@ def load(self):
"""
tempLocalScratch = Template(self.configuration.platform.localScratch)
self.defaults["LOCAL_SCRATCH"] = tempLocalScratch.substitute(
USER_NAME=self.defaults["USER_NAME"]
USER_SCRATCH=self.defaults["USER_SCRATCH"]
)
# print("localScratch-> %s" % self.defaults["LOCAL_SCRATCH"])
self.defaults["SCHEDULER"] = self.configuration.platform.scheduler
Expand Down Expand Up @@ -270,6 +272,12 @@ def getUserHome(self):
"""
return self.getParameter("USER_HOME")

def getUserScratch(self):
"""Accessor for USER_SCRATCH
@return the value of USER_SCRATCH
"""
return self.getParameter("USER_SCRATCH")

def getHostName(self):
"""Accessor for HOST_NAME
@return the value of HOST_NAME
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ctrl/execute/condorInfoConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class UserInfoConfig(pexConfig.Config):

name = pexConfig.Field(doc="user login name", dtype=str, default=None)
home = pexConfig.Field(doc="user home directory", dtype=str, default=None)
scratch = pexConfig.Field(doc="user scratch directory", dtype=str, default=None)


class UserConfig(pexConfig.Config):
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/ctrl/execute/slurmPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def submit(self, platform, platformPkgDir):

# run the sbatch command
template = Template(self.getLocalScratchDirectory())
localScratchDir = template.substitute(USER_NAME=self.getUserName())
localScratchDir = template.substitute(USER_SCRATCH=self.getUserScratch())
if not os.path.exists(localScratchDir):
os.mkdir(localScratchDir)
os.chdir(localScratchDir)
Expand Down Expand Up @@ -116,7 +116,7 @@ def loadSlurm(self, name, platformPkgDir):
allocationConfig = self.loadAllocationConfig(name, "slurm")

template = Template(allocationConfig.platform.scratchDirectory)
scratchDir = template.substitute(USER_NAME=self.getUserName())
scratchDir = template.substitute(USER_SCRATCH=self.getUserScratch())
self.defaults["SCRATCH_DIR"] = scratchDir

self.allocationFileName = os.path.join(
Expand Down

0 comments on commit 8a65b98

Please sign in to comment.