예제 #1
0
 def check_postproc(self):
     """check for input completeness"""
     # additionally check for the postprogram
     postprogram = self._tp_postprogram()
     # check if the program is executable
     if not which(postprogram):
         # check all additional paths specified
         if all([
                 which(postprogram, path=str(path)) is None
                 for path in self.environment.values()
         ]):
             raise Warning(
                 'Cannot find <postprogram> by invoking `which()`. If you did not do fancy bash aliasing, your job will crash!'
             )
예제 #2
0
    def check_consistency(self):
        """check for input completeness"""
        if self.params['aims_outfile'] is None:
            self.params['aims_outfile'] = self.params['job_name'] + '.out'

        # make sure that we copy back the outfile
        if not self.params['aims_outfile'] in self.params['copyback']:
            self.params['copyback'] += [self.params['aims_outfile']]

        program = self._tp_program()
        walltime_sec = get_sec(self._tp_walltime())

        # check if the program is executable
        if not which(program):
            # check all additional paths specified
            if all([
                    which(program, path=str(path)) is None
                    for path in self.environment.values()
            ]):
                raise Warning(
                    'Cannot find <program> by invoking `which()`. If you did not do fancy bash aliasing, your job will crash!'
                )

        control_path = os.path.join(self.params['job_dir'], "control.in")
        geometry_path = os.path.join(self.params['job_dir'], "geometry.in")

        if not os.path.exists(geometry_path):
            raise Warning('No geometry.in in <job_dir>. Your job will crash!')

        if not os.path.exists(control_path):
            raise Warning('No control.in in <job_dir>. Your job will crash!')
        else:
            # check for runtime flag
            with open(control_path, 'r') as controlfile:
                found = False
                for line in controlfile:
                    if 'walltime' in line.lower():
                        found = True
            if not found:
                with open(control_path, 'a') as controlfile:
                    # down-scale walltime limit to make sure that
                    # the job + ensuing IO can finish.
                    if walltime_sec < 24 * 60 * 60:
                        scale = .9
                    else:
                        scale = .95
                    controlfile.write(
                        '\nwalltime {} # added by submit script'.format(
                            int(walltime_sec * scale)))
예제 #3
0
    def check_consistency(self):
        """check for input completeness"""
        program = self._tp_program()
        # check if the program is executable
        if not which(program):
            # check all additional paths specified
            if all([
                    which(program, path=str(path)) is None
                    for path in self.environment.values()
            ]):
                raise Warning(
                    'Cannot find <program> by invoking `which()`. If you did not do fancy bash aliasing, your job will crash!'
                )

        walltime_sec = get_sec(self._tp_walltime())
        seed = self.params['seed']
        cellfile_path = os.path.join(self.params['job_dir'], seed + '.cell')
        if not os.path.exists(cellfile_path):
            raise Warning('No cellfile in <job_dir>. Your job will crash!')

        paramfile_path = os.path.join(self.params['job_dir'], seed + '.param')
        if not os.path.exists(paramfile_path):
            raise Warning('No paramfile in <job_dir>. Your job will crash!')
        else:
            # check for runtime flag
            with open(paramfile_path, 'r') as paramfile:
                found = False
                for line in paramfile:
                    if 'run_time' in line.lower():
                        found = True
            if not found:
                with open(paramfile_path, 'a') as paramfile:
                    # down-scale walltime limit to make sure that
                    # the job + ensuing IO can finish.
                    if walltime_sec < 24 * 60 * 60:
                        scale = .9
                    else:
                        scale = .95
                    paramfile.write(
                        '\nRUN_TIME : {} # added by submit script'.format(
                            int(walltime_sec * scale)))
예제 #4
0
    def check_consistency(self):
        """check for input completeness"""
        program = self._tp_program()
        # check if the program is executable
        if not which(program):
            # check all additional paths specified
            if all([
                    which(program, path=str(path)) is None
                    for path in self.environment.values()
            ]):
                raise Warning(
                    'Cannot find <program> by invoking `which()`. If you did not do fancy bash aliasing, your job will crash!'
                )

        seed = self.params['seed']
        cellfile_path = os.path.join(self.params['job_dir'], seed + '.cell')
        if not os.path.exists(cellfile_path):
            raise Warning('No cellfile in <job_dir>. Your job will crash!')

        paramfile_path = os.path.join(self.params['job_dir'], seed + '.param')
        if not os.path.exists(paramfile_path):
            raise Warning('No paramfile in <job_dir>. Your job will crash!')
예제 #5
0
import os
import unittest
import shutil
import tempfile
from rtools.submitagents.workstation import castep, WorkstationAgent

try:
    from rtools.filesys import which
    castep_installed = True
    program = 'castep'
    if not which(program):
        castep_installed = False
    else:
        castep_installed = True
except ImportError:
    castep_installed = False

class TestBaseArthurAgent(unittest.TestCase):
    """
    Test some functionality of the base agent class.
    """
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp()
        self.foldername = os.path.basename(self.tmpdir)

    def test_check_arg_works_for_nonexisting_arg(self):
        with self.assertRaises(RuntimeError):
            WorkstationAgent(job_dir=self.tmpdir, pbsnamee='myjob')

class TestCastepAgent(unittest.TestCase):
    """