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


Python Workflow.from_FireWork方法代码示例

本文整理汇总了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
开发者ID:dannybrowne86,项目名称:fireworks,代码行数:28,代码来源:launchpad.py

示例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
开发者ID:aykol,项目名称:MPWorks,代码行数:47,代码来源:task_to_fw.py

示例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
开发者ID:ctoher,项目名称:MPWorks,代码行数:72,代码来源:task_to_fw.py


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