Commit 095d8e90 authored by Fabrice Allain's avatar Fabrice Allain
Browse files

refactor: use vformat function to generate csh scripts

parent a036e7f5
...@@ -82,42 +82,42 @@ PLAN = 'plan.tbl' ...@@ -82,42 +82,42 @@ PLAN = 'plan.tbl'
CNS_OUTPUT_PATH_NAME = 'cns' CNS_OUTPUT_PATH_NAME = 'cns'
CSH_SCRIPT_REFINE = '''\ CSH_SCRIPT_REFINE = '''\
#! %(sge_job_shell)s #! {sge_job_shell}
# SGE/PBS/SLURM/LFS facility # SGE/PBS/SLURM/LFS facility
#$ -N %(sge_job_name)s #$ -N {sge_job_name}
#$ -S %(sge_job_shell)s #$ -S {sge_job_shell}
#PBS -N %(sge_job_name)s #PBS -N {sge_job_name}
#PBS -S %(sge_job_shell)s #PBS -S {sge_job_shell}
#BSUB -J %(sge_job_name)s #BSUB -J {sge_job_name}
#BSUB -L %(sge_job_shell)s #BSUB -L {sge_job_shell}
#BSUB -oo refine.lsf.out #BSUB -oo refine.lsf.out
#BSUB -eo refine.lsf.err #BSUB -eo refine.lsf.err
#SBATCH -o refine.%j.slurm.out #SBATCH -o refine.%j.slurm.out
#SBATCH -e refine.%j.slurm.err #SBATCH -e refine.%j.slurm.err
#SBATCH -J %(sge_job_name)s #SBATCH -J {sge_job_name}
#SBATCH --ignore-pbs #SBATCH --ignore-pbs
# results will be stored here # results will be stored here
setenv NEWIT %(iteration_path)s setenv NEWIT {iteration_path}
# project path # project path
setenv RUN %(cns_resource_path)s setenv RUN {cns_resource_path}
# individual run.cns is stored here # individual run.cns is stored here
setenv RUN_CNS %(cns_working_dir)s setenv RUN_CNS {cns_working_dir}
# path of ARIA2 cns protocos (for RAMA) # path of ARIA2 cns protocos (for RAMA)
setenv RAMA_DATA %(rama_data_dir)s setenv RAMA_DATA {rama_data_dir}
# CNS working directory # CNS working directory
cd %(cns_working_dir)s cd {cns_working_dir}
# solves some NFS sync problems # solves some NFS sync problems
cat %(cns_input_file)s > /dev/null cat {cns_input_file} > /dev/null
# command line # command line
%(cns_executable)s < %(cns_input_file)s >! %(cns_output_file)s {cns_executable} < {cns_input_file} >! {cns_output_file}
touch done touch done
''' '''
...@@ -167,20 +167,20 @@ Requirements = Arch == "X86_64" && OpSys == "LINUX" && Memory > 200 ...@@ -167,20 +167,20 @@ Requirements = Arch == "X86_64" && OpSys == "LINUX" && Memory > 200
CSH_SCRIPT_REFINE_CONDOR = '''\ CSH_SCRIPT_REFINE_CONDOR = '''\
# results will be stored here # results will be stored here
setenv NEWIT %(iteration_path)s setenv NEWIT {iteration_path}
# project path # project path
setenv RUN %(cns_resource_path)s setenv RUN {cns_resource_path}
# individual run.cns is stored here # individual run.cns is stored here
setenv RUN_CNS %(cns_working_dir)s setenv RUN_CNS {cns_working_dir}
# CNS working directory # CNS working directory
cd %(cns_working_dir)s cd {cns_working_dir}
# solves some NFS sync problems # solves some NFS sync problems
cat %(cns_input_file)s > /dev/null cat {cns_input_file} > /dev/null
# command line # command line
condor_submit condor.job condor_submit condor.job
...@@ -194,19 +194,19 @@ cp /dev/null done ...@@ -194,19 +194,19 @@ cp /dev/null done
CSH_SCRIPT_ANALYSIS = """\ CSH_SCRIPT_ANALYSIS = """\
# results will be stored here # results will be stored here
setenv ANALYSIS %(analysis_output_path)s setenv ANALYSIS {analysis_output_path}
# results from last iteration # results from last iteration
setenv NEWIT %(iteration_path)s setenv NEWIT {iteration_path}
# project path # project path
setenv RUN %(cns_resource_path)s setenv RUN {cns_resource_path}
# individual run.cns and output-files are stored here # individual run.cns and output-files are stored here
setenv RUN_CNS %(cns_working_dir)s setenv RUN_CNS {cns_working_dir}
# working directory # working directory
cd %(cns_working_dir)s cd {cns_working_dir}
# command line # command line
""" """
...@@ -2017,7 +2017,8 @@ class CNS(StructureEngine): ...@@ -2017,7 +2017,8 @@ class CNS(StructureEngine):
condor_queue = "input = %(cns_input_file)s\n" \ condor_queue = "input = %(cns_input_file)s\n" \
"output = %(cns_output_file)s\nqueue\n" "output = %(cns_output_file)s\nqueue\n"
self._write_condor_script(d, condor_append=condor_queue) self._write_condor_script(d, condor_append=condor_queue)
script = CSH_SCRIPT_REFINE_CONDOR % d script = string.Formatter().vformat(
CSH_SCRIPT_REFINE_CONDOR, (), SafeFormatDict(d))
checkscript = string.Formatter().vformat( checkscript = string.Formatter().vformat(
CSH_SCRIPT_CHECKPOINT, (), SafeFormatDict(d)) CSH_SCRIPT_CHECKPOINT, (), SafeFormatDict(d))
...@@ -2030,7 +2031,8 @@ class CNS(StructureEngine): ...@@ -2030,7 +2031,8 @@ class CNS(StructureEngine):
d['sge_job_shell'] = '/bin/csh -f' d['sge_job_shell'] = '/bin/csh -f'
# d['sge_job_hostname'] = '%(sge_job_hostname)s' # d['sge_job_hostname'] = '%(sge_job_hostname)s'
script = CSH_SCRIPT_REFINE % d script = string.Formatter().vformat(
CSH_SCRIPT_REFINE, (), SafeFormatDict(d))
d['sge_checkjob_name'] = sge_job_name + "_checkpoint" d['sge_checkjob_name'] = sge_job_name + "_checkpoint"
checkscript = string.Formatter().vformat( checkscript = string.Formatter().vformat(
CSH_SCRIPT_CHECKPOINT, (), SafeFormatDict(d)) CSH_SCRIPT_CHECKPOINT, (), SafeFormatDict(d))
...@@ -2466,7 +2468,8 @@ Could not create working directory for CNS analysis scripts ("%s").""" % ( ...@@ -2466,7 +2468,8 @@ Could not create working directory for CNS analysis scripts ("%s").""" % (
'cns_working_dir': working_dir, 'cns_working_dir': working_dir,
'cns_executable': cns_executable} 'cns_executable': cns_executable}
csh_script = CSH_SCRIPT_ANALYSIS % csh_dict csh_script = string.Formatter().vformat(
CSH_SCRIPT_ANALYSIS, (), SafeFormatDict(csh_dict))
condor_append = '\n' condor_append = '\n'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment