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

DM-41194: add user scratch as a configurable item in condor-info #21

Merged
merged 2 commits into from
Oct 16, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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