def submit(self): """Submit a PBS job for this VASP convergence""" # first, check if the job has already been submitted and is not completed db = pbs.JobDB() print "rundir", self.calcdir id = db.select_regex_id("rundir", self.calcdir) print "id:", id sys.stdout.flush() if id != []: for j in id: job = db.select_job(j) # taskstatus = ["Incomplete","Complete","Continued","Check","Error:.*","Aborted"] # jobstatus = ["C","Q","R","E","W","H","M"] if job["jobstatus"] != "C": print "JobID:", job["jobid"], " Jobstatus:", job["jobstatus"], " Not submitting." sys.stdout.flush() return #elif job["taskstatus"] in ["Complete", "Check"] or re.match( "Error:.*", job["taskstatus"]): # print "JobID:", job["jobid"], " Taskstatus:", job["taskstatus"], " Not submitting." # sys.stdout.flush() # return # second, only submit a job if relaxation status is "incomplete" # construct the Relax object convergence = vasp.Converge(self.calcdir, self.run_settings(), convtype=self.convtype) # check the current status (status, task) = convergence.status() if status == "complete": print "Status:", status, " Not submitting." sys.stdout.flush() return elif status == "not_converging": print "Status:", status, " Not submitting." sys.stdout.flush() return elif status != "incomplete": raise vaspwrapper.VaspWrapperError("unexpected relaxation status: '" + status + "' and task: '" + task + "'") sys.stdout.flush() return print "Preparing to submit a VASP convergence PBS job" sys.stdout.flush() # cd to configdir, submit jobs from configdir, then cd back to currdir currdir = os.getcwd() os.chdir(self.calcdir) # determine the number of atoms in the configuration print " Counting atoms in the POSCAR" sys.stdout.flush() pos = vasp.io.Poscar(os.path.join(self.configdir,"POS")) N = len(pos.basis) print " Constructing a PBS job" sys.stdout.flush() # construct a pbs.Job job = pbs.Job(name=casm.jobname(self.configdir),\ account=self.settings["account"],\ nodes=int(math.ceil(float(N)/float(self.settings["atom_per_proc"])/float(self.settings["ppn"]))),\ ppn=int(self.settings["ppn"]),\ walltime=self.settings["walltime"],\ pmem=self.settings["pmem"],\ queue=self.settings["queue"],\ message=self.settings["message"],\ email=self.settings["email"],\ priority=self.settings["priority"],\ command="python -c \"import casm; casm.vaspwrapper.Converge('" + self.configdir + "', '" + self.convtype + "').run()\"",\ auto=self.auto) print " Submitting" sys.stdout.flush() # submit the job job.submit() # return to current directory os.chdir(currdir) print "CASM VASPWrapper relaxation PBS job submission complete\n" sys.stdout.flush()
def submit(self): #pylint: disable=too-many-statements """Submit a PBS job for this SeqQuest relaxation""" print "Submitting..." print "Configuration:", self.configname # first, check if the job has already been submitted and is not completed db = pbs.JobDB() print "Calculation directory:", self.calcdir id = db.select_regex_id("rundir", self.calcdir) print "JobID:", id sys.stdout.flush() if id != []: for j in id: job = db.select_job(j) if job["jobstatus"] != "C": print "JobID:", job["jobid"], " Jobstatus:", job[ "jobstatus"], " Not submitting." sys.stdout.flush() return # second, only submit a job if relaxation status is "incomplete" # construct the Relax object relaxation = seqquest.Relax(self.calcdir, self.run_settings()) # check the current status (status, task) = relaxation.status() if status == "complete": print "Status:", status, " Not submitting." sys.stdout.flush() # ensure job marked as complete in db if self.auto: for j in id: job = db.select_job(j) if job["taskstatus"] == "Incomplete": try: pbs.complete_job(jobid=j) except (pbs.PBSError, pbs.JobDBError, pbs.EligibilityError) as e: print str(e) sys.stdout.flush() # ensure results report written if not os.path.isfile( os.path.join(self.calcdir, "properties.calc.json")): self.finalize() return elif status == "not_converging": print "Status:", status, " Not submitting." sys.stdout.flush() return elif status != "incomplete": raise questwrapper.QuestWrapperError( "unexpected relaxation status: '" + status + "' and task: '" + task + "'") # This code can never be reached... # sys.stdout.flush() # return print "Preparing to submit a SeqQuest relaxation PBS job" sys.stdout.flush() # cd to configdir, submit jobs from configdir, then cd back to currdir currdir = os.getcwd() os.chdir(self.calcdir) # determine the number of atoms in the configuration print "Counting atoms in the POSCAR" sys.stdout.flush() geom = seqquest.seqquest_io.Geom.POS( os.path.join(self.configdir, "POS")) N = len(geom.basis) # construct command to be run cmd = "" if self.settings["preamble"] is not None: # Append any instructions given in the 'preamble' file, if given preamble = self.casm_directories.settings_path_crawl( self.settings["preamble"], self.configname, self.clex) with open(preamble) as my_preamble: cmd += "".join(my_preamble) + "\n" if self.settings["prerun"] is not None: cmd += self.settings["prerun"] + "\n" cmd += "python -c \"import casm.vaspwrapper; casm.vaspwrapper.Relax('" + self.configdir + "').run()\"\n" if self.settings["postrun"] is not None: cmd += self.settings["postrun"] + "\n" print "Constructing a PBS job" sys.stdout.flush() # construct a pbs.Job job = pbs.Job(name=casm.jobname(self.configdir),\ account=self.settings["account"],\ nodes=int(math.ceil(float(N)/float(self.settings["atom_per_proc"])/float(self.settings["ppn"]))),\ ppn=int(self.settings["ppn"]),\ walltime=self.settings["walltime"],\ pmem=self.settings["pmem"],\ qos=self.settings["qos"],\ queue=self.settings["queue"],\ message=self.settings["message"],\ email=self.settings["email"],\ priority=self.settings["priority"],\ command=cmd,\ auto=self.auto) print "Submitting" sys.stdout.flush() # submit the job job.submit() self.report_status("submitted") # return to current directory os.chdir(currdir) print "CASM QuestWrapper relaxation PBS job submission complete\n" sys.stdout.flush()
def submit(self): """Submit a PBS job for this VASP relaxation""" # first, check if the job has already been submitted and is not completed db = pbs.JobDB() print "rundir", self.calcdir id = db.select_regex_id("rundir", self.calcdir) print "id:", id sys.stdout.flush() if id != []: for j in id: job = db.select_job(j) # taskstatus = ["Incomplete","Complete","Continued","Check","Error:.*","Aborted"] # jobstatus = ["C","Q","R","E","W","H","M"] if job["jobstatus"] != "C": print "JobID:", job["jobid"], " Jobstatus:", job["jobstatus"], " Not submitting." sys.stdout.flush() return #elif job["taskstatus"] in ["Complete", "Check"] or re.match( "Error:.*", job["taskstatus"]): # print "JobID:", job["jobid"], " Taskstatus:", job["taskstatus"], " Not submitting." # sys.stdout.flush() # return # second, only submit a job if relaxation status is "incomplete" # construct the Relax object relaxation = vasp.Relax(self.calcdir, self.run_settings()) # check the current status (status, task) = relaxation.status() if status == "complete": print "Status:", status, " Not submitting." sys.stdout.flush() # ensure job marked as complete in db if self.auto: for j in id: job = db.select_job(j) if job["taskstatus"] == "Incomplete": try: pbs.complete_job(jobid=j) except (pbs.PBSError, pbs.JobDBError, pbs.EligibilityError) as e: print str(e) sys.stdout.flush() # ensure results report written if not os.path.isfile(os.path.join(self.calcdir, "properties.calc.json")): self.report() return elif status == "not_converging": print "Status:", status, " Not submitting." sys.stdout.flush() return elif status != "incomplete": raise vaspwrapper.VaspWrapperError("unexpected relaxation status: '" + status + "' and task: '" + task + "'") sys.stdout.flush() return print "Preparing to submit a VASP relaxation PBS job" sys.stdout.flush() # cd to configdir, submit jobs from configdir, then cd back to currdir currdir = os.getcwd() os.chdir(self.calcdir) # determine the number of atoms in the configuration print " Counting atoms in the POSCAR" sys.stdout.flush() pos = vasp.io.Poscar(os.path.join(self.configdir,"POS")) N = len(pos.basis) print " Constructing a PBS job" sys.stdout.flush() # construct a pbs.Job job = pbs.Job(name=casm.jobname(self.configdir),\ account=self.settings["account"],\ nodes=int(math.ceil(float(N)/float(self.settings["atom_per_proc"])/float(self.settings["ppn"]))),\ ppn=int(self.settings["ppn"]),\ walltime=self.settings["walltime"],\ pmem=self.settings["pmem"],\ qos=self.settings["qos"],\ queue=self.settings["queue"],\ message=self.settings["message"],\ email=self.settings["email"],\ priority=self.settings["priority"],\ command="python -c \"import casm.vaspwrapper; casm.vaspwrapper.Relax('" + self.configdir + "').run()\"",\ auto=self.auto) print " Submitting" sys.stdout.flush() # submit the job job.submit() # return to current directory os.chdir(currdir) print "CASM VASPWrapper relaxation PBS job submission complete\n" sys.stdout.flush()
def submit(self): """Submit a PBS job for this VASP relaxation""" print "Submitting..." print "Configuration:", self.configname # first, check if the job has already been submitted and is not completed db = pbs.JobDB() print "Calculation directory:", self.calcdir id = db.select_regex_id("rundir", self.calcdir) print "JobID:", id sys.stdout.flush() if id != []: for j in id: job = db.select_job(j) # taskstatus = ["Incomplete","Complete","Continued","Check","Error:.*","Aborted"] # jobstatus = ["C","Q","R","E","W","H","M"] if job["jobstatus"] != "C": print "JobID:", job["jobid"], " Jobstatus:", job["jobstatus"], " Not submitting." sys.stdout.flush() return #elif job["taskstatus"] in ["Complete", "Check"] or re.match( "Error:.*", job["taskstatus"]): # print "JobID:", job["jobid"], " Taskstatus:", job["taskstatus"], " Not submitting." # sys.stdout.flush() # return # second, only submit a job if relaxation status is "incomplete" # construct the Relax object relaxation = vasp.Relax(self.calcdir, self.run_settings()) # check the current status (status, task) = relaxation.status() if status == "complete": print "Status:", status, " Not submitting." sys.stdout.flush() # ensure job marked as complete in db if self.auto: for j in id: job = db.select_job(j) if job["taskstatus"] == "Incomplete": try: pbs.complete_job(jobid=j) except (pbs.PBSError, pbs.JobDBError, pbs.EligibilityError) as e: print str(e) sys.stdout.flush() # ensure results report written if not os.path.isfile(os.path.join(self.calcdir, "properties.calc.json")): self.finalize() return elif status == "not_converging": print "Status:", status, " Not submitting." sys.stdout.flush() return elif status != "incomplete": raise vaspwrapper.VaspWrapperError("unexpected relaxation status: '" + status + "' and task: '" + task + "'") sys.stdout.flush() return print "Preparing to submit a VASP relaxation PBS job" sys.stdout.flush() # cd to configdir, submit jobs from configdir, then cd back to currdir currdir = os.getcwd() os.chdir(self.calcdir) # determine the number of atoms in the configuration print "Counting atoms in the POSCAR" sys.stdout.flush() pos = vasp.io.Poscar(os.path.join(self.configdir,"POS")) N = len(pos.basis) # construct command to be run cmd = "" if self.settings["prerun"] is not None: cmd += self.settings["prerun"] + "\n" cmd += "python -c \"import casm.vaspwrapper; casm.vaspwrapper.Relax('" + self.configdir + "').run()\"\n" if self.settings["postrun"] is not None: cmd += self.settings["postrun"] + "\n" print "Constructing a PBS job" sys.stdout.flush() # construct a pbs.Job job = pbs.Job(name=casm.jobname(self.configdir),\ account=self.settings["account"],\ nodes=int(math.ceil(float(N)/float(self.settings["atom_per_proc"])/float(self.settings["ppn"]))),\ ppn=int(self.settings["ppn"]),\ walltime=self.settings["walltime"],\ pmem=self.settings["pmem"],\ qos=self.settings["qos"],\ queue=self.settings["queue"],\ message=self.settings["message"],\ email=self.settings["email"],\ priority=self.settings["priority"],\ command=cmd,\ auto=self.auto) print "Submitting" sys.stdout.flush() # submit the job job.submit() self.report_status("submitted") # return to current directory os.chdir(currdir) print "CASM VASPWrapper relaxation PBS job submission complete\n" sys.stdout.flush()