Skip to content
Snippets Groups Projects
Commit d8525492 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

optional hawc2_path in HAWC2PBSFile,

parent 2ffea0f4
No related branches found
No related tags found
No related merge requests found
Pipeline #6343 passed
......@@ -5,15 +5,7 @@ from wetb.utils.cluster_tools.os_path import pjoin, relpath, abspath,\
template = Template("""
#===============================================================================
echo copy hawc2 to scratch
#===============================================================================
(flock -x 200
unzip -u -o -q [hawc2_path]/*.zip -d /scratch/$USER/$PBS_JOBID/hawc2/
find [hawc2_path]/* ! -name *.zip -exec cp -u -t /scratch/$USER/$PBS_JOBID/hawc2/ {} +
) 200>/scratch/$USER/$PBS_JOBID/lock_file_hawc2
mkdir -p /scratch/$USER/$PBS_JOBID/[model_name]/run_[jobname]/[rel_exe_dir]
cp /scratch/$USER/$PBS_JOBID/hawc2/* /scratch/$USER/$PBS_JOBID/[model_name]/run_[jobname]/[rel_exe_dir]
[copy_hawc2]
#===============================================================================
echo copy input
......@@ -91,7 +83,7 @@ class HAWC2PBSFile(PBSFile):
def commands(self):
rel_exe_dir = relpath(self.exe_dir, self.model_path)
copy_input_to_scratch, copy_input_to_exe_dir = self.copy_input()
return template(hawc2_path=os.path.dirname(cluster_path(self.hawc2_path)),
return template(copy_hawc2=self.copy_hawc2(),
exe_dir=cluster_path(self.exe_dir),
copy_input_to_scratch=copy_input_to_scratch,
copy_input_to_exe_dir=copy_input_to_exe_dir,
......@@ -103,6 +95,21 @@ class HAWC2PBSFile(PBSFile):
model_path=cluster_path(self.model_path),
model_name=self.model_name)
def copy_hawc2(self):
copy_hawc2 = Template("""#===============================================================================
echo copy hawc2 to scratch
#===============================================================================
(flock -x 200
unzip -u -o -q [hawc2_path]/*.zip -d /scratch/$USER/$PBS_JOBID/hawc2/
find [hawc2_path]/* ! -name *.zip -exec cp -u -t /scratch/$USER/$PBS_JOBID/hawc2/ {} +
) 200>/scratch/$USER/$PBS_JOBID/lock_file_hawc2
mkdir -p /scratch/$USER/$PBS_JOBID/[model_name]/run_[jobname]/[rel_exe_dir]
cp /scratch/$USER/$PBS_JOBID/hawc2/* /scratch/$USER/$PBS_JOBID/[model_name]/run_[jobname]/[rel_exe_dir]""")
if self.hawc2_path is None:
return ""
else:
return copy_hawc2(hawc2_path=os.path.dirname(cluster_path(self.hawc2_path)))
def copy_input(self):
rel_input_files = [relpath(f, self.model_path) for f in self.input_files]
......
......@@ -23,17 +23,17 @@ class HTCFileSet():
for filename in glob.iglob(htc_path, recursive=True):
self.htc_files.append(filename)
def pbs_files(self, hawc2_path, hawc2_cmd, htc_lst="**/*.htc", queue='workq',
def pbs_files(self, hawc2_path, hawc2_cmd, queue='workq', walltime=None,
input_files=None, output_files=None, copy_turb=(True, True)):
return [HTCFile(htc).pbs_file(hawc2_path, hawc2_cmd, queue=queue,
return (HTCFile(htc).pbs_file(hawc2_path, hawc2_cmd, queue=queue, walltime=walltime,
input_files=copy.copy(input_files),
output_files=copy.copy(output_files),
copy_turb=copy_turb) for htc in self.htc_files]
copy_turb=copy_turb) for htc in self.htc_files)
def save_pbs_files(self, hawc2_path, hawc2_cmd, htc_lst="**/*.htc", queue='workq',
def save_pbs_files(self, hawc2_path=None, hawc2_cmd=JESS_WINE32_HAWC2MB, queue='workq', walltime=None,
input_files=None, output_files=None, copy_turb=(True, True)):
for pbs in self.pbs_files(hawc2_path, hawc2_cmd, htc_lst, queue=queue,
for pbs in self.pbs_files(hawc2_path, hawc2_cmd, queue=queue, walltime=walltime,
input_files=input_files, output_files=output_files,
copy_turb=copy_turb):
pbs.save(self.model_path)
......
......@@ -33,6 +33,7 @@ pbs_template = Template('''### Jobid
#PBS -q [queue]
cd [workdir]
mkdir -p stdout
if [ -z "$PBS_JOBID" ]; then echo "Run using qsub"; exit ; fi
pwd
[commands]
exit
......
......@@ -33,6 +33,7 @@ def test_pbs_file_str():
#PBS -q workq
cd /home/user/tmp
mkdir -p stdout
if [ -z "$PBS_JOBID" ]; then echo "Run using qsub"; exit ; fi
pwd
python -c "print('hello world')"
exit
......@@ -83,6 +84,7 @@ def test_pbs_multirunner():
#PBS -q workq
cd /home/user/tmp
mkdir -p stdout
if [ -z "$PBS_JOBID" ]; then echo "Run using qsub"; exit ; fi
pwd
echo "import os
import glob
......
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