def reset_from_scratch(self):
        """
        restart from scratch, this is to be used if a job is restarted with more resources after a crash
        """
        # Move output files produced in workdir to _reset otherwise check_status continues
        # to see the task as crashed even if the job did not run
        # Create reset directory if not already done.
        reset_dir = os.path.join(self.workdir, "_reset")
        reset_file = os.path.join(reset_dir, "_counter")
        if not os.path.exists(reset_dir):
            os.mkdir(reset_dir)
            num_reset = 1
        else:
            with open(reset_file, "rt") as fh:
                num_reset = 1 + int(fh.read())

        # Move files to reset and append digit with reset index.
        def move_file(f):
            if not f.exists: return
            try:
                f.move(os.path.join(reset_dir, f.basename + "_" + str(num_reset)))
            except OSError as exc:
                logger.warning("Couldn't move file {}. exc: {}".format(f, str(exc)))

        for fname in ("output_file", "log_file", "stderr_file", "qout_file", "qerr_file", "mpiabort_file"):
            move_file(getattr(self, fname))

        with open(reset_file, "wt") as fh:
            fh.write(str(num_reset))

        self.start_lockfile.remove()

        # Reset datetimes
        self.datetimes.reset()

        return self._restart(submit=False)
def reset_from_scratch ( self ) : reset_dir = os . path . join ( self . workdir , "_reset" ) reset_file = os . path . join ( reset_dir , "_counter" ) if not os . path . exists ( reset_dir ) : os . mkdir ( reset_dir ) num_reset = 1 else : with open ( reset_file , "rt" ) as fh : num_reset = 1 + int ( fh . read ( ) ) def move_file ( f ) : if not f . exists : return try : f . move ( os . path . join ( reset_dir , f . basename + "_" + str ( num_reset ) ) ) except OSError as exc : logger . warning ( "Couldn't move file {}. exc: {}" . format ( f , str ( exc ) ) ) for fname in ( "output_file" , "log_file" , "stderr_file" , "qout_file" , "qerr_file" , "mpiabort_file" ) : move_file ( getattr ( self , fname ) ) with open ( reset_file , "wt" ) as fh : fh . write ( str ( num_reset ) ) self . start_lockfile . remove ( ) self . datetimes . reset ( ) return self . _restart ( submit = False )
restart from scratch, this is to be used if a job is restarted with more resources after a crash