Ejemplo n.º 1
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)))
Ejemplo n.º 2
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)))
Ejemplo n.º 3
0
    def __init__(self, **kwargs):

        self.defaults = {'copyback' : ['*.py',
                                       '*.dat',
                                       '*.eta',
                                       '*.pot',
                                       '*.cfg',
                                       'output'],
                         'program' : 'SurfDiff',
                         'configfile' : None,
                         'cmd_args' : None,
                         'seed' : 'MDsim'}

        PythonScriptAgent.__init__(self, **kwargs)

        # creating the precommand
        if self.params['configfile'] is not None:
            self.params['configfile'] = 'configfile="-i {}"'.format(self.params['configfile'])
            self.precmd.add(self.params['configfile'])

        cmd_args = self.params['cmd_args']
        if cmd_args is None:
            flags = ''
        else:
            flags = ''
            for arg, val in cmd_args:
                if arg in ['io.seed',
                           'misc.walltime']:
                    continue
                flags +='--{}="{}" '.format(arg, val)

        flags += '--io.seed="{}" '.format(self.params['seed'])
        flags += '--misc.walltime="{}"'.format(walltime_sec = get_sec(self._tp_walltime()))

        self.precmd.add("flags='{}'".format(flags))

        # remove the old command first
        self.cmd.remove(-1)
        self.cmd.add('$python_bin $pyflags $program $configfile $flags')