本文整理汇总了Python中fireworks.LaunchPad.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python LaunchPad.from_file方法的具体用法?Python LaunchPad.from_file怎么用?Python LaunchPad.from_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fireworks.LaunchPad
的用法示例。
在下文中一共展示了LaunchPad.from_file方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from fireworks import LaunchPad [as 别名]
# 或者: from fireworks.LaunchPad import from_file [as 别名]
def __init__(self, *args, **kwargs):
'''
:param args: (VaspFirework objects) objects to create Workflow from. No limit
on the amount of VaspInputInterface objects to be given. Entered as just
comma separated objects passed to class.
:param deps_dict: (dict) specifies the dependency of the VaspInputInterface objects given.
If no dependency is given, Firworks are assumed to be
sequentially dependent.
:param name (str) Name given to Workflow
'''
self.fws = []
self.name = kwargs.get('name', 'Sequential WF')
self.deps_dict = kwargs.get('deps_dict', {})
self.dependency = {}
if self.deps_dict:
for i in self.deps_dict.keys():
fw_deps = []
for j in self.deps_dict[i]:
fw_deps.append(j.Firework)
self.dependency[i.Firework]=fw_deps
self.deps = True if self.dependency else False
for id, fw_task in enumerate(args):
self.fws.append(fw_task.Firework)
if not self.deps and id != 0:
self.dependency[self.fws[id-1]]=[fw_task.Firework]
self.wf = Workflow(self.fws, self.dependency, name=self.name)
# Try to establish connection with Launchpad
try:
self.LaunchPad=LaunchPad.from_file(os.path.join(os.environ["HOME"], ".fireworks", "my_launchpad.yaml"))
except:
self.LaunchPad = None
示例2: launch
# 需要导入模块: from fireworks import LaunchPad [as 别名]
# 或者: from fireworks.LaunchPad import from_file [as 别名]
def launch():
descr = "Smart rocket launcher."\
"Uses the execution termination emails send by the batch system to "\
"launch fireworks that depend on other fireworks i.e fireworks that "\
"have 'cal_objs' in their spec."\
"Takes in fw_ids of fireworks to be launched. "\
"Range specification of fw_ids is also supported."\
"All the jobs are launched to hipergator remotely using fabric."\
"Note: Ensure that the submit scripts have the appropriate email settings and "\
"that the mail daemon is fetching emails to the folder polled by this script."\
"Note: All rocket launches take place in the home directory. If "\
"_launch_dir spec is set for the firework the job files will be written to "\
"that folder and jobs to the batch system will be done from there."
parser = ArgumentParser(description=descr)
parser.add_argument('-f', '--fw_ids', help='one or more of fw_ids to run',
default=None, type=int, nargs='+')
parser.add_argument('-r', '--r_fw_ids',
help='start and end fw_ids of the range of fw_ids to run',
default=None, type=int, nargs=2)
args = parser.parse_args()
fw_ids = args.fw_ids
if args.r_fw_ids is not None:
fw_ids += range(args.r_fw_ids[0], args.r_fw_ids[1])
job_ids = None
lp = LaunchPad.from_file(LAUNCHPAD_LOC)
print('Firework ids: ',fw_ids)
if fw_ids is None:
print('No fw ids given')
return
for fid in fw_ids:
m_fw = lp._get_a_fw_to_run(fw_id=fid, checkout=False)
if m_fw is None:
print('No firework with that id')
return
fw_spec = dict(m_fw.spec)
done = []
if fw_spec.get('cal_objs',None) is not None:
for calparams in fw_spec['cal_objs']:
if calparams.get('job_ids', None) is not None:
job_ids = calparams.get('job_ids', None)
print(fid,' depends on jobs with ids : ',job_ids)
if job_ids is not None:
for jid in job_ids:
done.append(check_done(jid))
else:
print('job_ids not set')
else:
print('This firework doesnt depend on any other fireworks.')
done.append(True)
if done and all(done):
print('Launching ', fid, ' ...')
with settings(host_string='[email protected]'):
run("ssh dev1 rlaunch singleshot -f "+str(fid))
else:
print("Haven't recieved execution termination confirmation for the jobs in the firework from hipergator resource manager")
time.sleep(3)
return
示例3: setUp
# 需要导入模块: from fireworks import LaunchPad [as 别名]
# 或者: from fireworks.LaunchPad import from_file [as 别名]
def setUp(self):
if os.path.exists(self.scratch_dir):
shutil.rmtree(self.scratch_dir)
os.makedirs(self.scratch_dir)
os.chdir(self.scratch_dir)
try:
self.lp = LaunchPad.from_file(os.path.join(db_dir, "my_launchpad.yaml"))
self.lp.reset("", require_password=False)
except:
raise unittest.SkipTest(
'Cannot connect to MongoDB! Is the database server running? '
'Are the credentials correct?')
示例4: setUp
# 需要导入模块: from fireworks import LaunchPad [as 别名]
# 或者: from fireworks.LaunchPad import from_file [as 别名]
def setUp(self, lpad=True):
"""
Create scratch directory(removes the old one if there is one) and change to it.
Also initialize launchpad.
"""
if not SETTINGS.get("PMG_VASP_PSP_DIR"):
SETTINGS["PMG_VASP_PSP_DIR"] = os.path.abspath(os.path.join(MODULE_DIR, "..", "vasp", "test_files"))
print('This system is not set up to run VASP jobs. '
'Please set PMG_VASP_PSP_DIR variable in your ~/.pmgrc.yaml file.')
self.scratch_dir = os.path.join(MODULE_DIR, "scratch")
if os.path.exists(self.scratch_dir):
shutil.rmtree(self.scratch_dir)
os.makedirs(self.scratch_dir)
os.chdir(self.scratch_dir)
if lpad:
try:
self.lp = LaunchPad.from_file(os.path.join(DB_DIR, "my_launchpad.yaml"))
self.lp.reset("", require_password=False)
except:
raise unittest.SkipTest('Cannot connect to MongoDB! Is the database server running? '
'Are the credentials correct?')
示例5: range
# 需要导入模块: from fireworks import LaunchPad [as 别名]
# 或者: from fireworks.LaunchPad import from_file [as 别名]
'KPOINTS': [k for k in range(20, 30, 10)]
}
job_dir = 'calBulk'
job_cmd = ['mpirun', '/home/km468/Software/VASP/vasp.5.3.5/vasp']
qparams= dict(nnodes='1', ppnode='16',
job_name='vasp_job', pmem='1000mb',
walltime='24:00:00',
rocket_launch=''.join(job_cmd))
# set qadapter to None to launch via qlaunch
# reserve and launch offline
# qlaunch -r singleshot
# lpad recover_offline
qadapter = None #CommonAdapter(q_type="PBS",**qparams)
cal = Calibrate(incar, poscar, potcar, kpoints,
turn_knobs = turn_knobs,
qadapter = qadapter,
job_dir = job_dir, job_cmd=job_cmd)
caltask = MPINTCalibrateTask(cal.as_dict())
#firework with launch directory set to $FW_JOB_DIR, an environment variable
#spec={'_launch_dir':'$FW_JOB_DIR'},
fw_calibrate = Firework([caltask],
name="fw_test")
wf = Workflow([fw_calibrate], name="mpint_wf_test")
lp = LaunchPad.from_file(LAUNCHPAD_LOC)
print('fireworks in the database before adding the workflow: \n',
lp.get_fw_ids())
lp.add_wf(wf)
print('fireworks in the database: \n', lp.get_fw_ids())
示例6: test_dict_from_file
# 需要导入模块: from fireworks import LaunchPad [as 别名]
# 或者: from fireworks.LaunchPad import from_file [as 别名]
def test_dict_from_file(self):
lp = LaunchPad.from_file(self.LP_LOC)
lp_dict = lp.to_dict()
new_lp = LaunchPad.from_dict(lp_dict)
self.assertIsInstance(new_lp, LaunchPad)
示例7: structure
# 需要导入模块: from fireworks import LaunchPad [as 别名]
# 或者: from fireworks.LaunchPad import from_file [as 别名]
structure (Structure): input structure to be optimized and run
vasp_cmd (str): command to run
db_file (str): path to file containing the database credentials.
Returns:
Workflow
"""
fws = []
fws.append(StaticFW(structure=structure, vasp_cmd=vasp_cmd, db_file=db_file))
fws.append(NonSCFFW(structure=structure, vasp_cmd=vasp_cmd, db_file=db_file, parents=fws[0]))
fws.append(BandGapCheckFW(structure=structure, parents=fws[1]))
fws.append(InterpolateFW(structure=structure, parents=fws[2]))
wfname = "{}:{}".format(structure.composition.reduced_formula, "dipole_moment")
return Workflow(fws, name=wfname)
if __name__ == "__main__":
from pymatgen.util.testing import PymatgenTest
from matmethods.vasp.workflows.presets.core import wf_ferroelectric
structure = PymatgenTest.get_structure("Si")
# wf = get_wf_ferroelectric(structure)
my_wf = wf_ferroelectric(structure)
# lp = LaunchPad()
lp = LaunchPad.from_file(os.path.join("/global/homes/s/sbajaj/mm_installdir/config", "my_launchpad.yaml"))
lp.reset('', require_password=False)
lp.add_wf(my_wf)