当前位置: 首页>>代码示例>>Python>>正文


Python Custodian.run方法代码示例

本文整理汇总了Python中custodian.custodian.Custodian.run方法的典型用法代码示例。如果您正苦于以下问题:Python Custodian.run方法的具体用法?Python Custodian.run怎么用?Python Custodian.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在custodian.custodian.Custodian的用法示例。


在下文中一共展示了Custodian.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_vasp

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
def run_vasp(override=[], suffix=''):
    '''
    execute vasp with given override and suffix

    :param override:
    :param suffix:
    :return:
    '''
    from Classes_Pymatgen import Incar
    from Classes_Custodian import StandardJob
    from custodian.custodian import Custodian
    import os

    # Determine wheter to use Gamma optimized vasp
    incar = Incar.from_file('INCAR')
    if 'AUTO_GAMMA' in incar and incar['AUTO_GAMMA']:
        vasp = os.environ['VASP_GAMMA']
    else:
        vasp = os.environ['VASP_KPTS']

    handlers = []
    vaspjob = [StandardJob(['mpirun', '-np', os.environ['VASP_PROCS'], vasp], 'vasp.log', auto_npar=False, backup=False,
                           settings_override=override, suffix=suffix, final=False)]
    c = Custodian(handlers, vaspjob, max_errors=10)
    c.run()
开发者ID:rtrottie,项目名称:VASP-Templates,代码行数:27,代码来源:VASP_gsm.py

示例2: run

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
 def run(self, job_cmd=None):
     """
     run the vasp jobs through custodian
     if the job list is empty,
     run a single job with the initial input set
     """
     for j in self.jobs:
         if job_cmd is not None:            
             j.job_cmd = job_cmd
         else:
             j.job_cmd = self.job_cmd
     c_params = {'jobs': [j.as_dict() for j in self.jobs],
             'handlers': [h.as_dict() for h in self.handlers],
             'max_errors': 5}
     c = Custodian(self.handlers, self.jobs, max_errors=5)
     c.run()
     for j in self.jobs:
         self.cal_log.append({"job": j.as_dict(), 
                              'job_id': j.job_id, 
                              "corrections": [], 
                              'final_energy': None})
         self.job_ids.append(j.job_id)
     if self.checkpoint_file:
         dumpfn(self.cal_log, self.checkpoint_file,
                cls=MontyEncoder, indent=4)
     else:
         dumpfn(self.cal_log, Calibrate.LOG_FILE, cls=MontyEncoder,
                indent=4)
开发者ID:zhuyizhou,项目名称:MPInterfaces,代码行数:30,代码来源:calibrate.py

示例3: run

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
 def run(self, fw_spec):
     # class VaspJob(Job):
     #     """
     #     A basic vasp job. Just runs whatever is in the directory. But conceivably
     #     can be a complex processing of inputs etc. with initialization.
     #     """
     #
     #     def __init__(self, vasp_cmd, output_file="vasp.out", stderr_file="std_err.txt",
     #                  suffix="", final=True, backup=True, auto_npar=True,
     #                  auto_gamma=True, settings_override=None,
     #                  gamma_vasp_cmd=None, copy_magmom=False, auto_continue=False):
     try:
         vasp_cmd = os.environ['VASP_CMD'].split()
     except:
         raise ValueError('Unable to find vasp command')
     if 'custodian_jobs' in fw_spec:
         jobs = fw_spec['custodian_jobs']
     else:
         jobs = [VaspJob(vasp_cmd=vasp_cmd, auto_npar=False,
                         output_file=os.path.join(self.run_dir, 'vasp.out'),
                         stderr_file=os.path.join(self.run_dir, 'std_err.txt'),
                         backup=False,
                         auto_gamma=False)]
     custodian = Custodian(handlers=self.custodian_handlers, jobs=jobs,
                           validators=None, max_errors=10,
                           polling_time_step=10, monitor_freq=30)
     custodian.run()
开发者ID:gmatteo,项目名称:abiflows,代码行数:29,代码来源:vasp_tasks_src.py

示例4: do_run

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
def do_run(args):
    handlers = [VaspErrorHandler(), MeshSymmetryErrorHandler(),
                UnconvergedErrorHandler(), NonConvergingErrorHandler(),
                PotimErrorHandler()]
    c = Custodian(handlers, get_runs(args), max_errors=10, gzipped_output=args.gzip)
    c.run()
    logging.info("Geometry optimization complete")
开发者ID:czhengsci,项目名称:custodian,代码行数:9,代码来源:converge_geometry.py

示例5: do_run

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
def do_run(args):
    handlers = [VaspErrorHandler(), UnconvergedErrorHandler()]
    c = Custodian(handlers, get_runs(vasp_command=args.command.split(),
                                     target=args.target, mode=args.mode,
                                     max_steps=args.max_steps),
                  max_errors=10)
    c.run()
开发者ID:czhengsci,项目名称:custodian,代码行数:9,代码来源:converge_kpoints.py

示例6: _test_simplejob

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
 def _test_simplejob(self):
     os.chdir(self.path)
     njobs = 100
     params = {"initial": 0, "total": 0}
     c = Custodian([ExampleHandler(params), ExampleHandler2(params)],
                   [ExampleJob(i, params) for i in range(njobs)],
                   max_errors=njobs*2)
     c.run()
开发者ID:hackberie,项目名称:00_workSpace,代码行数:10,代码来源:test_custodian.py

示例7: test_max_errors_per_handler_warning

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
 def test_max_errors_per_handler_warning(self):
     njobs = 100
     params = {"initial": 0, "total": 0}
     c = Custodian([ExampleHandler1c(params)],
                   [ExampleJob(i, params) for i in range(njobs)],
                   max_errors=njobs*10, max_errors_per_job=1000)
     c.run()
     self.assertTrue(all(len(r["corrections"]) <= 2 for r in c.run_log))
开发者ID:materialsproject,项目名称:custodian,代码行数:10,代码来源:test_custodian.py

示例8: test_exitcode_error

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
 def test_exitcode_error(self):
     c = Custodian([], [ExitCodeJob(0)])
     c.run()
     c = Custodian([], [ExitCodeJob(1)])
     self.assertRaises(RuntimeError, c.run)
     c = Custodian([], [ExitCodeJob(1)],
                   terminate_on_nonzero_returncode=False)
     c.run()
开发者ID:xhqu1981,项目名称:custodian,代码行数:10,代码来源:test_custodian.py

示例9: test_exitcode_error

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
 def test_exitcode_error(self):
     c = Custodian([], [ExitCodeJob(0)])
     c.run()
     c = Custodian([], [ExitCodeJob(1)])
     self.assertRaises(ReturnCodeError, c.run)
     self.assertTrue(c.run_log[-1]["nonzero_return_code"])
     c = Custodian([], [ExitCodeJob(1)],
                   terminate_on_nonzero_returncode=False)
     c.run()
开发者ID:materialsproject,项目名称:custodian,代码行数:11,代码来源:test_custodian.py

示例10: do_run

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
def do_run(args):
    logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO,
                        filename="run.log")
    job = NwchemJob(nwchem_cmd=args.command.split(),
                    input_file=args.infile,
                    output_file=args.outfile)
    c = Custodian([NwchemErrorHandler(output_filename=args.outfile)], [job],
                  max_errors=5, scratch_dir=args.scratch,
                  gzipped_output=args.gzipped, checkpoint=True)
    c.run()
开发者ID:czhengsci,项目名称:custodian,代码行数:12,代码来源:run_nwchem.py

示例11: do_run

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
def do_run(args):
    FORMAT = '%(asctime)s %(message)s'
    logging.basicConfig(format=FORMAT, level=logging.INFO, filename="run.log")
    logging.info("Handlers used are %s" % args.handlers)
    handlers = [load_class("custodian.vasp.handlers", n) for n in
                args.handlers]
    validators = [load_class("custodian.vasp.validators", n) for n in
                  args.validators]

    c = Custodian(handlers, get_jobs(args), validators,
                  max_errors=args.max_errors, scratch_dir=args.scratch,
                  gzipped_output=args.gzip,
                  checkpoint=True)
    c.run()
开发者ID:czhengsci,项目名称:custodian,代码行数:16,代码来源:run_vasp.py

示例12: test_unrecoverable

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
 def test_unrecoverable(self):
     njobs = 100
     params = {"initial": 0, "total": 0}
     h = ExampleHandler2(params)
     c = Custodian([h],
                   [ExampleJob(i, params) for i in range(njobs)],
                   max_errors=njobs)
     self.assertRaises(RuntimeError, c.run)
     self.assertTrue(h.has_error)
     h = ExampleHandler2b(params)
     c = Custodian([h],
                   [ExampleJob(i, params) for i in range(njobs)],
                   max_errors=njobs)
     c.run()
     self.assertTrue(h.has_error)
开发者ID:pombredanne,项目名称:custodian,代码行数:17,代码来源:test_custodian.py

示例13: run_task

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
    def run_task(self, fw_spec):
        # write a file containing the formula and task_type for somewhat easier file system browsing
        self._write_formula_file(fw_spec)

        # TODO: make this better - is there a way to load an environment variable as the VASP_EXE?
        if 'nid' in socket.gethostname():  # hopper compute nodes
            v_exe = shlex.split('aprun -n 48 vasp')  # TODO: make ncores dynamic!
        elif 'c' in socket.gethostname():  # carver / mendel compute nodes
            v_exe = shlex.split('mpirun -n 32 vasp')  # TODO: make ncores dynamic!
        else:
            raise ValueError('Unrecognized host!')

        for job in self.jobs:
            job.vasp_command = v_exe

        c = Custodian(self.handlers, self.jobs, self.max_errors)
        custodian_out = c.run()

        all_errors = set()
        for run in custodian_out:
            for correction in run['corrections']:
                all_errors.update(correction['errors'])

        stored_data = {'error_list': list(all_errors)}
        update_spec = {'prev_vasp_dir': os.getcwd(), 'prev_task_type': fw_spec['task_type']}

        update_spec.update({'mpsnl': fw_spec['mpsnl'], 'snlgroup_id': fw_spec['snlgroup_id']})

        return FWAction(stored_data=stored_data, update_spec=update_spec)
开发者ID:cmgtam,项目名称:MPWorks,代码行数:31,代码来源:custodian_task.py

示例14: test_run

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
 def test_run(self):
     njobs = 100
     params = {"initial": 0, "total": 0}
     c = Custodian([ExampleHandler(params)],
                   [ExampleJob(i, params) for i in xrange(njobs)],
                   max_errors=njobs, log_file=None)
     output = c.run()
     self.assertEqual(len(output), njobs)
开发者ID:navnidhirajput,项目名称:custodian,代码行数:10,代码来源:test_custodian.py

示例15: run_task

# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import run [as 别名]
    def run_task(self, fw_spec):

        # write a file containing the formula and task_type for somewhat
        # easier file system browsing
        self._write_formula_file(fw_spec)

        fw_env = fw_spec.get("_fw_env", {})

        if "mpi_cmd" in fw_env:
            mpi_cmd = fw_spec["_fw_env"]["mpi_cmd"]
        elif which("mpirun"):
            mpi_cmd = "mpirun"
        elif which("aprun"):
            mpi_cmd = "aprun"
        else:
            raise ValueError("No MPI command found!")

        nproc = os.environ['PBS_NP']

        v_exe = shlex.split('{} -n {} {}'.format(mpi_cmd, nproc, fw_env.get("vasp_cmd", "vasp")))
        gv_exe = shlex.split('{} -n {} {}'.format(mpi_cmd, nproc, fw_env.get("gvasp_cmd", "gvasp")))

        print 'host:', os.environ['HOSTNAME']

        for job in self.jobs:
            job.vasp_cmd = v_exe
            job.gamma_vasp_cmd = gv_exe

        incar_errors = check_incar(fw_spec['task_type'])
        if incar_errors:
            raise ValueError("Critical error: INCAR does not pass checks: {}".format(incar_errors))

        logging.basicConfig(level=logging.DEBUG)
        c = Custodian(self.handlers, self.jobs, max_errors=self.max_errors, gzipped_output=False, validators=[VasprunXMLValidator()])  # manual gzip
        custodian_out = c.run()

        if self.gzip_output:
            for f in os.listdir(os.getcwd()):
                if not f.lower().endswith("gz") and not f.endswith(".OU") and not f.endswith(".ER"):
                    with open(f, 'rb') as f_in, \
                            GzipFile('{}.gz'.format(f), 'wb') as f_out:
                        f_out.writelines(f_in)
                    os.remove(f)

        all_errors = set()
        for run in custodian_out:
            for correction in run['corrections']:
                all_errors.update(correction['errors'])

        stored_data = {'error_list': list(all_errors)}
        update_spec = {'prev_vasp_dir': os.getcwd(),
                       'prev_task_type': fw_spec['task_type'],
                       'mpsnl': fw_spec['mpsnl'],
                       'snlgroup_id': fw_spec['snlgroup_id'],
                       'run_tags': fw_spec['run_tags'],
                       'parameters': fw_spec.get('parameters')}

        return FWAction(stored_data=stored_data, update_spec=update_spec)
开发者ID:ctoher,项目名称:MPWorks,代码行数:60,代码来源:custodian_task.py


注:本文中的custodian.custodian.Custodian.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。