Skip to content
Snippets Groups Projects
Commit 8b256264 authored by Izzard, Robert Dr (Maths & Physics)'s avatar Izzard, Robert Dr (Maths & Physics)
Browse files

add option HPC_rebuild_joinlist to build the joinlist automatically

parent d80dd772
No related branches found
No related tags found
No related merge requests found
...@@ -24,13 +24,26 @@ class HPC(condor,slurm): ...@@ -24,13 +24,26 @@ class HPC(condor,slurm):
def HPC_joinfiles(self,joinlist=None): def HPC_joinfiles(self,joinlist=None):
""" """
Function to load in the joinlist to a list and return it. Function to load in the joinlist to a list and return it.
If grid_options['HPC_rebuild_joinlist'] is True, we rebuild it.
""" """
prefix = os.path.join(self.HPC_dir(),
'results')
if self.grid_options['HPC_rebuild_joinlist'] == 1:
# we should rebuild the joinlist from the
# files we find at the prefix directory
list = glob.glob(str(prefix) + '/*.gz')
return list
if joinlist is None: if joinlist is None:
joinlist = self.grid_options['joinlist'] joinlist = self.grid_options['joinlist']
try: try:
f = open(joinlist,'r',encoding='utf-8') f = open(joinlist,'r',encoding='utf-8')
list = f.read().splitlines() list = f.read().splitlines()
f.close() f.close()
if self.grid_options['HPC_prepend_dir_to_joinlist'] = True:
list = [os.path.join(prefix,file) for file in list]
except: except:
print("Failed to open joinlist at {list}".format(list=joinlist)) print("Failed to open joinlist at {list}".format(list=joinlist))
self.exit(code=1) self.exit(code=1)
...@@ -92,7 +105,8 @@ class HPC(condor,slurm): ...@@ -92,7 +105,8 @@ class HPC(condor,slurm):
""" """
Function to return True if we're running an HPC (Slurm or Condor) job, False otherwise. Function to return True if we're running an HPC (Slurm or Condor) job, False otherwise.
""" """
if self.grid_options['slurm'] > 0 or self.grid_options['condor'] > 0: if self.grid_options['slurm'] > 0 or \
self.grid_options['condor'] > 0:
x = True x = True
else: else:
x = False x = False
...@@ -354,14 +368,22 @@ class HPC(condor,slurm): ...@@ -354,14 +368,22 @@ class HPC(condor,slurm):
""" """
Function to return an HPC job's snapshot filename. Function to return an HPC job's snapshot filename.
""" """
if self.grid_options['slurm'] > 0: if self.HPCjob():
file = os.path.join(self.grid_options['slurm_dir'], file = os.path.join(self.HPC_dir,
'snapshots',
self.HPCjobID() + '.gz')
elif self.grid_options['condor'] > 0:
file = os.path.join(self.grid_options['condor_dir'],
'snapshots', 'snapshots',
self.HPCjobID() + '.gz') self.HPCjobID() + '.gz')
else: else:
file = None file = None
return file return file
def HPC_dir(self):
"""
Function to return an HPC job's directory.
"""
if self.grid_options['slurm'] > 0:
d = self.grid_options['slurm_dir']
elif self.grid_options['condor'] > 0:
d = self.grid_options['condor_dir']
else:
d = None
return d
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment