本文整理匯總了Python中fireworks.core.firework.Workflow.from_FireWork方法的典型用法代碼示例。如果您正苦於以下問題:Python Workflow.from_FireWork方法的具體用法?Python Workflow.from_FireWork怎麽用?Python Workflow.from_FireWork使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fireworks.core.firework.Workflow
的用法示例。
在下文中一共展示了Workflow.from_FireWork方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_wf
# 需要導入模塊: from fireworks.core.firework import Workflow [as 別名]
# 或者: from fireworks.core.firework.Workflow import from_FireWork [as 別名]
def add_wf(self, wf, reassign_all=True):
"""
:param wf: a Workflow object.
"""
m_timer.start("add_wf")
if isinstance(wf, FireWork):
wf = Workflow.from_FireWork(wf)
# sets the root FWs as READY
# prefer to wf.refresh() for speed reasons w/many root FWs
for fw_id in wf.root_fw_ids:
wf.id_fw[fw_id].state = 'READY'
# insert the FireWorks and get back mapping of old to new ids
old_new = self._upsert_fws(list(wf.id_fw.values()), reassign_all=reassign_all)
# update the Workflow with the new ids
wf._reassign_ids(old_new)
# insert the WFLinks
self.workflows.insert(wf.to_db_dict())
m_timer.stop("add_wf")
self.m_logger.info('Added a workflow. id_map: {}'.format(old_new))
return old_new
示例2: task_dict_to_wf
# 需要導入模塊: from fireworks.core.firework import Workflow [as 別名]
# 或者: from fireworks.core.firework.Workflow import from_FireWork [as 別名]
def task_dict_to_wf(task_dict, launchpad):
fw_id = launchpad.get_new_fw_id()
l_id = launchpad.get_new_launch_id()
spec = {'task_type': task_dict['task_type'], 'run_tags': task_dict['run_tags'],
'vaspinputset_name': None, 'vasp': None, 'mpsnl': task_dict['snl'],
'snlgroup_id': task_dict['snlgroup_id']}
tasks = [DummyLegacyTask()]
launch_dir = task_dict['dir_name_full']
stored_data = {'error_list': []}
update_spec = {'prev_vasp_dir': task_dict['dir_name'],
'prev_task_type': spec['task_type'],
'mpsnl': spec['mpsnl'], 'snlgroup_id': spec['snlgroup_id'],
'run_tags': spec['run_tags']}
fwaction = FWAction(stored_data=stored_data, update_spec=update_spec)
if task_dict['completed_at']:
complete_date = datetime.datetime.strptime(task_dict['completed_at'], "%Y-%m-%d %H:%M:%S")
state_history = [{"created_on": complete_date, 'state': 'COMPLETED'}]
else:
state_history = []
launches = [Launch('COMPLETED', launch_dir, fworker=None, host=None, ip=None, action=fwaction,
state_history=state_history, launch_id=l_id, fw_id=fw_id)]
f = Composition(task_dict['pretty_formula']).alphabetical_formula
fw = Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), launches=launches, state='COMPLETED', created_on=None,
fw_id=fw_id)
wf_meta = get_meta_from_structure(Structure.from_dict(task_dict['snl']))
wf_meta['run_version'] = 'preproduction (0)'
wf = Workflow.from_FireWork(fw, name=f, metadata=wf_meta)
launchpad.add_wf(wf, reassign_all=False)
launchpad._upsert_launch(launches[0])
print 'ADDED', fw_id
# return fw_id
return fw_id
示例3: task_dict_to_wf
# 需要導入模塊: from fireworks.core.firework import Workflow [as 別名]
# 或者: from fireworks.core.firework.Workflow import from_FireWork [as 別名]
def task_dict_to_wf(task_dict, launchpad):
fw_id = launchpad.get_new_fw_id()
l_id = launchpad.get_new_launch_id()
spec = {
"task_type": task_dict["task_type"],
"run_tags": task_dict["run_tags"],
"vaspinputset_name": None,
"vasp": None,
"mpsnl": task_dict["snl"],
"snlgroup_id": task_dict["snlgroup_id"],
}
tasks = [DummyLegacyTask()]
launch_dir = task_dict["dir_name_full"]
stored_data = {"error_list": []}
update_spec = {
"prev_vasp_dir": task_dict["dir_name"],
"prev_task_type": spec["task_type"],
"mpsnl": spec["mpsnl"],
"snlgroup_id": spec["snlgroup_id"],
"run_tags": spec["run_tags"],
}
fwaction = FWAction(stored_data=stored_data, update_spec=update_spec)
if task_dict["completed_at"]:
complete_date = datetime.datetime.strptime(task_dict["completed_at"], "%Y-%m-%d %H:%M:%S")
state_history = [{"created_on": complete_date, "state": "COMPLETED"}]
else:
state_history = []
launches = [
Launch(
"COMPLETED",
launch_dir,
fworker=None,
host=None,
ip=None,
action=fwaction,
state_history=state_history,
launch_id=l_id,
fw_id=fw_id,
)
]
f = Composition(task_dict["pretty_formula"]).alphabetical_formula
fw = Firework(
tasks,
spec,
name=get_slug(f + "--" + spec["task_type"]),
launches=launches,
state="COMPLETED",
created_on=None,
fw_id=fw_id,
)
wf_meta = get_meta_from_structure(Structure.from_dict(task_dict["snl"]))
wf_meta["run_version"] = "preproduction (0)"
wf = Workflow.from_FireWork(fw, name=f, metadata=wf_meta)
launchpad.add_wf(wf, reassign_all=False)
launchpad._upsert_launch(launches[0])
print "ADDED", fw_id
# return fw_id
return fw_id