def is_ready_to_run(self): """Check if single VASP NEB ingredient is ready to run. """ dirname = self.keywords['name'] notready=0 if not(os.path.isfile(dirname + "/KPOINTS")): notready = notready + 1 if not(os.path.isfile(dirname + "/POTCAR")): notready = notready + 1 if not(os.path.isfile(dirname + "/INCAR")): notready = notready + 1 else: #INCAR exists. Now check POSCARs. subdirs = dirutil.walkdirs(dirname) if not (len(subdirs) == self.keywords['program_keys']['mast_neb_settings']['images'] + 2): notready = notready + 1 #bad number of subdirs subdirs.sort() if len(subdirs) == 0: #This is an NEB without folders yet notready = notready + 1 else: for subdir in subdirs: if not (os.path.isfile(subdir + "/POSCAR")): notready = notready + 1 if not os.path.isfile(subdirs[0] + "/OSZICAR"): notready = notready + 1 if not os.path.isfile(subdirs[-1] + "/OSZICAR"): notready = notready + 1 if not(os.path.isfile(dirname + "/submit.sh")): notready = notready + 1 if notready > 0: return False else: return True
def is_ready_to_run(self): """Check if single VASP NEB ingredient is ready to run. """ dirname = self.keywords['name'] notready = 0 if not (os.path.isfile(dirname + "/KPOINTS")): notready = notready + 1 if not (os.path.isfile(dirname + "/POTCAR")): notready = notready + 1 if not (os.path.isfile(dirname + "/INCAR")): notready = notready + 1 else: #INCAR exists. Now check POSCARs. subdirs = dirutil.walkdirs(dirname) if not (len(subdirs) == self.keywords['program_keys'] ['mast_neb_settings']['images'] + 2): notready = notready + 1 #bad number of subdirs subdirs.sort() if len(subdirs) == 0: #This is an NEB without folders yet notready = notready + 1 else: for subdir in subdirs: if not (os.path.isfile(subdir + "/POSCAR")): notready = notready + 1 if not os.path.isfile(subdirs[0] + "/OSZICAR"): notready = notready + 1 if not os.path.isfile(subdirs[-1] + "/OSZICAR"): notready = notready + 1 if not (os.path.isfile(dirname + "/submit.sh")): notready = notready + 1 if notready > 0: return False else: return True
def run(self, verbose=0, single_recipe=0, single_ingred=0): """Run the MAST monitor. """ if (single_ingred == 0) and ("dagman" in dirutil.get_mast_platform()): return None #Do not auto-run from __init__ method for CHTC/DAGMan curdir = os.getcwd() try: os.chdir(self.scratch) except: os.chdir(curdir) errorstr = "Could not change directories to MAST_SCRATCH at %s" % self.scratch raise MASTError(self.__class__.__name__, errorstr) #dirutil.lock_directory(self.scratch, 1) # Wait 5 seconds #Directory is now locked by mast initially, but gets #unlocked at the end of the mastmon run. if single_ingred == 0: recipe_dirs = dirutil.walkdirs(self.scratch,1,1) else: recipe_dirs = list() recipe_dirs.append(single_recipe) if verbose == 1: self.logger.info("================================") self.logger.info("Recipe directories:") for recipe_dir in recipe_dirs: self.logger.info(recipe_dir) self.logger.info("================================") for recipe_dir in recipe_dirs: self.check_recipe_dir(recipe_dir, verbose, single_ingred) dirutil.unlock_directory(self.scratch) #unlock directory os.chdir(curdir)
def run(self, verbose=0, single_recipe=0, single_ingred=0): """Run the MAST monitor. """ if (single_ingred == 0) and ("dagman" in dirutil.get_mast_platform()): return None #Do not auto-run from __init__ method for CHTC/DAGMan curdir = os.getcwd() try: os.chdir(self.scratch) except: os.chdir(curdir) errorstr = "Could not change directories to MAST_SCRATCH at %s" % self.scratch raise MASTError(self.__class__.__name__, errorstr) #dirutil.lock_directory(self.scratch, 1) # Wait 5 seconds #Directory is now locked by mast initially, but gets #unlocked at the end of the mastmon run. if single_ingred == 0: recipe_dirs = dirutil.walkdirs(self.scratch, 1, 1) else: recipe_dirs = list() recipe_dirs.append(single_recipe) if verbose == 1: self.logger.info("================================") self.logger.info("Recipe directories:") for recipe_dir in recipe_dirs: self.logger.info(recipe_dir) self.logger.info("================================") for recipe_dir in recipe_dirs: self.check_recipe_dir(recipe_dir, verbose, single_ingred) dirutil.unlock_directory(self.scratch) #unlock directory os.chdir(curdir)
def run(self, verbose=0): """Run the MAST monitor. """ curdir = os.getcwd() try: os.chdir(self.scratch) except: os.chdir(curdir) errorstr = "Could not change directories to MAST_SCRATCH at %s" % self.scratch raise MASTError(self.__class__.__name__, errorstr) #dirutil.lock_directory(self.scratch, 1) # Wait 5 seconds #Directory is now locked by mast initially, but gets #unlocked at the end of the mastmon run. recipe_dirs = dirutil.walkdirs(self.scratch,1,1) if verbose == 1: self.logger.info("================================") self.logger.info("Recipe directories:") for recipe_dir in recipe_dirs: self.logger.info(recipe_dir) self.logger.info("================================") for recipe_dir in recipe_dirs: self.check_recipe_dir(recipe_dir, verbose) dirutil.unlock_directory(self.scratch) #unlock directory os.chdir(curdir)
def tearDown(self): #return dnames = dirutil.walkdirs("childdir",1,1) for dname in dnames: shutil.rmtree(dname) fnames = dirutil.walkfiles("childdir",1,1) for fname in fnames: os.remove(fname)