本文整理汇总了Python中custodian.custodian.Custodian.from_spec方法的典型用法代码示例。如果您正苦于以下问题:Python Custodian.from_spec方法的具体用法?Python Custodian.from_spec怎么用?Python Custodian.from_spec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类custodian.custodian.Custodian
的用法示例。
在下文中一共展示了Custodian.from_spec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import from_spec [as 别名]
def run(args):
FORMAT = '%(asctime)s %(message)s'
logging.basicConfig(format=FORMAT, level=logging.INFO, filename="run.log")
logging.info("Spec file is %s" % args.spec_file)
d = loadfn(args.spec_file[0])
c = Custodian.from_spec(d)
c.run()
示例2: test_from_spec
# 需要导入模块: from custodian.custodian import Custodian [as 别名]
# 或者: from custodian.custodian.Custodian import from_spec [as 别名]
def test_from_spec(self):
spec = """jobs:
- jb: custodian.vasp.jobs.VaspJob
params:
final: False
suffix: .relax1
- jb: custodian.vasp.jobs.VaspJob
params:
final: True
suffix: .relax2
settings_override: {"file": "CONTCAR", "action": {"_file_copy": {"dest": "POSCAR"}}}
jobs_common_params:
$vasp_cmd: ["mpirun", "-machinefile", "$PBS_NODEFILE", "-np", "24", "/opt/vasp/5.4.1/bin/vasp"]
handlers:
- hdlr: custodian.vasp.handlers.VaspErrorHandler
- hdlr: custodian.vasp.handlers.AliasingErrorHandler
- hdlr: custodian.vasp.handlers.MeshSymmetryErrorHandler
validators:
- vldr: custodian.vasp.validators.VasprunXMLValidator
custodian_params:
$scratch_dir: $TMPDIR"""
import yaml
os.environ["TMPDIR"] = "/tmp/random"
os.environ["PBS_NODEFILE"] = "whatever"
d = yaml.load(spec)
c = Custodian.from_spec(d)
self.assertEqual(c.jobs[0].vasp_cmd[2], "whatever")
self.assertEqual(c.scratch_dir, "/tmp/random")
self.assertEqual(len(c.jobs), 2)
self.assertEqual(len(c.handlers), 3)
self.assertEqual(len(c.validators), 1)