<commit_before>"""
Created:         3 March 2018
Last Updated:    3 March 2018

<NAME>
<EMAIL>
Texas A&M University
-----

Templates for scripts to submit batch jobs
"""


def condor_bash_template():
    """Bash script that will run CyMiniAna -- designed for condor"""
    bash_template = """#!/bin/tcsh
echo " > Starting CONDOR job at `date` on `hostname`"


## Copy CMSSW tarball from eos, untar it, and remove the tarball
xrdcp -s root://cmseos.fnal.gov/%(eos_path_to_tarball)s/%(cmsRelease)s.tgz .
tar -xf %(cmsRelease)s.tgz
rm %(cmsRelease)s.tgz


## Setup CMSSW environment
setenv SCRAM_ARCH slc6_amd64_gcc530
cd %(cmsRelease)s/src/
scramv1 b ProjectRename
eval `scramv1 runtime -csh` # cmsenv is an alias not on the workers
scram b -j8


## Execute CyMiniAna
echo " > Run the program "
cd Analysis/CyMiniAna
%(executable)s %(cfg_filename)s


## Move output file to EOS (make new directory if necessary)
echo " > Finishing executing "
echo " > Move output file to EOS"

# -- Only copy files if they exist
set outfiles = `ls %(local_output_path)s/`
if ( "$outfiles" != "" ) then
    echo " Output file exists, copy to EOS "
    xrdcp %(local_output_path)s/*.root %(outputDir)s/%(local_output_path)s
endif


## Cleanup
rm %(local_output_path)s/*.root   # delete output files
cd ${_CONDOR_SCRATCH_DIR}         # delete working directory
rm -rf %(cmsRelease)s

echo " > Ended at `date` on `hostname`"
exit 0
"""

    return bash_template




def condor_script_template():
    """Condor script for submitting batch job"""
    condor_template = """
Universe   = vanilla
Executable = %(condorExec)s

Should_Transfer_Files = YES
WhenToTransferOutput  = ON_EXIT
Transfer_Input_Files  = %(unique_id_batch_path)s/cmaConfig.txt,%(unique_id_batch_path)s/listOfFiles.txt,%(unique_id_batch_path)s/run_condor.sh
notify_user   = <EMAIL>
x509userproxy = $ENV(X509_USER_PROXY)

Log        = %(unique_id_batch_path)s/condor_$(Cluster)_$(Process).log
Error	   = %(unique_id_batch_path)s/condor_$(Cluster)_$(Process).error
Output     = %(unique_id_batch_path)s/condor_$(Cluster)_$(Process).out

Queue 1
"""<commit_msg>Copy whole directory rather than individual scripts to batch job<commit_after>"""
Created:         3 March 2018
Last Updated:    3 March 2018

<NAME>
<EMAIL>
Texas A&M University
-----

Templates for scripts to submit batch jobs
"""


def condor_bash_template():
    """Bash script that will run CyMiniAna -- designed for condor"""
    bash_template = """#!/bin/tcsh
echo " > Starting CONDOR job at `date` on `hostname`"


## Copy CMSSW tarball from eos, untar it, and remove the tarball
xrdcp -s root://cmseos.fnal.gov/%(eos_path_to_tarball)s/%(cmsRelease)s.tgz .
tar -xf %(cmsRelease)s.tgz
rm %(cmsRelease)s.tgz


## Setup CMSSW environment
setenv SCRAM_ARCH slc6_amd64_gcc530
cd %(cmsRelease)s/src/
scramv1 b ProjectRename
eval `scramv1 runtime -csh` # cmsenv is an alias not on the workers
scram b -j8


## Execute CyMiniAna
echo " > Run the program "
cd Analysis/CyMiniAna
%(executable)s %(cfg_filename)s


## Move output file to EOS (make new directory if necessary)
echo " > Finishing executing "
echo " > Move output file to EOS"

# -- Only copy files if they exist
set outfiles = `ls %(local_output_path)s/`
if ( "$outfiles" != "" ) then
    echo " Output file exists, copy to EOS "
    xrdcp %(local_output_path)s/*.root %(outputDir)s/%(local_output_path)s
endif


## Cleanup
rm %(local_output_path)s/*.root   # delete output files
cd ${_CONDOR_SCRATCH_DIR}         # delete working directory
rm -rf %(cmsRelease)s

echo " > Ended at `date` on `hostname`"
exit 0
"""

    return bash_template




def condor_script_template():
    """Condor script for submitting batch job"""
    condor_template = """
Universe   = vanilla
Executable = %(condorExec)s

Should_Transfer_Files = YES
WhenToTransferOutput  = ON_EXIT
Transfer_Input_Files  = %(unique_id_batch_path)s
notify_user   = <EMAIL>}@FN<EMAIL>
x509userproxy = $ENV(X509_USER_PROXY)

Log        = %(unique_id_batch_path)s/condor_$(Cluster)_$(Process).log
Error	   = %(unique_id_batch_path)s/condor_$(Cluster)_$(Process).error
Output     = %(unique_id_batch_path)s/condor_$(Cluster)_$(Process).out

Queue 1
"""
{'fraction_non_alphanumeric': 0.12032598274209012, 'fraction_numerical': 0.012943432406519654, 'mean_word_length': 4.419480519480519, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3369167', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1475, 'n_words': 401}