How to use FireWorks - 10 common examples

To help you get started, we’ve selected a few FireWorks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github abinit / abipy / abipy / fw_integration_tests / itest_check_abiflow.py View on Github external
def itest_scf(self, lp, fworker, fwp, tmpdir, benchmark_input_scf):
        wf = InputFWWorkflow(benchmark_input_scf, task_type=ScfFWTask)

        scf_fw_id = wf.fw.fw_id
        old_new = wf.add_to_db(lpad=lp)
        scf_fw_id = old_new[scf_fw_id]

        rapidfire(lp, fworker, m_dir=str(tmpdir))

        fw = lp.get_fw_by_id(scf_fw_id)

        assert fw.state == "COMPLETED"

        # Build the flow
        flow = abilab.Flow(fwp.workdir, manager=fwp.manager)
        work = flow.register_task(benchmark_input_scf, task_class=abilab.ScfTask)

        flow.allocate()
        flow.build_and_pickle_dump()

        # Run t0, and check status
        t0 = work[0]
        t0.start_and_wait()
        t0.check_status()
github hackingmaterials / rocketsled / rocketsled / tests.py View on Github external
spec = {'_x_opt': x}
    dims = [(1, 10), (10.0, 20.0), ['blue', 'green', 'red', 'orange']]
    fw0 = Firework(AdditionTask(), spec={"input_array": [1, 2]}, name='Parent')
    fw1 = Firework(AdditionTask(), spec={"input_array": [2, 3]}, name='Child A')
    fw2 = Firework(AdditionTask(), spec={"input_array": [3, 4]}, name='Child B')

    bt = BasicTestTask()
    ot = OptTask(wf_creator='rocketsled.tests.wf_creator_complex',
                 dimensions=dims,
                 lpad=launchpad,
                 wf_creator_args=[launchpad],
                 opt_label='test_complex')
    fw3 = Firework([bt, ot], spec=spec, name="Optimization")

    fw4 = Firework(AdditionTask(), spec={"input_array": [5, 6]}, name='After 1')
    fw5 = Firework(ScriptTask.from_str('echo "ScriptTask: Finished complex workflow w/ optimization."'), name='After 2')

    return Workflow([fw0, fw1, fw2, fw3, fw4, fw5],
                    {fw0: [fw1, fw2], fw1: [fw3], fw2: [fw3], fw3: [fw4], fw4: [fw5], fw5: []})
github hackingmaterials / rocketsled / old / examples / ABC_task / test_code.py View on Github external
from ABC_workflow_creator import workflow_creator
from fireworks.core.rocket_launcher import rapidfire
from fireworks import FWorker, LaunchPad
from turboworks.optdb import OptDB
from fireworks.core.rocket_launcher import launch_rocket
import matplotlib.pyplot as plt

"""
This is the top level script for this turboworks example, and is used primarily for debugging/tuning.
"""

launchpad = LaunchPad()
manageDB = OptDB()

# Sample data
A = 50
B = 50
C = 50
input1 = {"A":A, "B":B, "C":C}
dimensions = {"A_range":(1,100),"B_range":(1,100), "C_range":(1,100)}

# Define the initial input
input_dict = {'input':input1, 'dimensions':dimensions}

# How many times to run the workflow + optimization loop
run_num = 30

# Or dynamically call till within a max_val
github hackingmaterials / rocketsled / turboworks / testing_vector.py View on Github external
dimensions = [(1,100), (1,100), (1,100)]
    spec = {'A':inputs[0], 'B':inputs[1], 'C':inputs[2], 'dimensions':dimensions}

    ft1 = CalculateTask()
    ft2 = OptimizeTaskFromVector(workflow_creator)
    firework = Firework([ft1, ft2], spec=spec)


if __name__ == "__main__":
    # mdb = ManageDB()
    # mdb.nuke()

    # set up the LaunchPad and reset it
    launchpad = LaunchPad()
    launchpad.reset('', require_password=False)

    # create the Firework consisting of a single task
    print type(OptimizeTaskFromVector)
    ft1 = OptimizeTaskFromVector(input = [1,2,3,4])
    fw1 = Firework(ft1)
    launchpad.add(fw1)
    launch_rocket(launchpad)
github hackingmaterials / rocketsled / rs_examples / test_perovskites.py View on Github external
def run_task(self, fw_spec):

        # mendeleev params
        a_mr = fw_spec['A']
        b_mr = fw_spec['B']
        c_mr = fw_spec['C']

        # convert from mendeleev and score compound
        a, b, c = mend_to_name(a_mr, b_mr, c_mr)

        data = perovskites.loc[(perovskites['A'] == a) & (perovskites['B'] == b) & (perovskites['anion'] == c)]
        score = float(data['complex_score'])
        output = {'_y_opt': score}
        return FWAction(update_spec=output)
github hackingmaterials / rocketsled / rocketsled / tests.py View on Github external
def test_get_z(self):
        self.lp.reset(password=None, require_password=False)
        self.lp.add_wf(wf_creator_get_z([5, 11, 'blue'], self.lp))
        for _ in range(2):
            launch_rocket(self.lp)

        col = self.db.test_get_z
        loop1 = col.find_one({'index': 1})
        loop2 = col.find_one({'index': 2})

        self.assertEqual(col.find({}).count(), 4)
        self.assertEqual(loop1['x'], [5, 11, 'blue'])
        self.assertEqual(loop1['z'], [25.0, 121.0])
        self.assertEqual(loop2['x'], [3, 12.0, 'green'])
        self.assertEqual(loop2['z'], [9, 144.0])
github hackingmaterials / rocketsled / rocketsled / tests.py View on Github external
def test_complex(self):
        self.lp.reset(password=None, require_password=False)
        self.lp.add_wf(wf_creator_complex([5, 11, 'blue'], self.lp))
        for _ in range(10):
            launch_rocket(self.lp)

        col = self.db.test_complex
        loop1 = col.find({'index': 1})   # should return one doc, for the first WF
        loop2 = col.find({'index': 2})   # should return one doc, for the second WF
        reserved = col.find({'y': 'reserved'})
        self.assertEqual(col.find({}).count(), 4)
        self.assertEqual(reserved.count(), 1)
        self.assertEqual(loop1.count(), 1)
        self.assertEqual(loop2.count(), 1)
github hackingmaterials / rocketsled / old / examples / ABC_task / test_code.py View on Github external
# Run run_num iterations using Skopt Gaussian Processes
    gp_best = []
    wf = workflow_creator(input_dict, 'skopt_gp')
    launchpad.add_wf(wf)
    for i in range(run_num):
        launch_rocket(launchpad)
        gp_best.append(manageDB.get_optima('D', min_or_max='max')[0])
    manageDB.clean()
    launchpad.defuse_wf(launchpad.get_fw_ids()[-1])

    # Run run_num iterations using a dummy optimizer (returns random)
    dummy_best = []
    wf = workflow_creator(input_dict, 'dummy')
    launchpad.add_wf(wf)
    for i in range(run_num):
        launch_rocket(launchpad)
        dummy_best.append(manageDB.get_optima('D', min_or_max='max')[0])
    manageDB.clean()

    iterations = list(range(run_num))
    print("GP best:", gp_best[-1])
    print("Dummy best: ", dummy_best[-1])
    plt.plot(iterations,gp_best,'g', iterations, dummy_best,'r')
    plt.show()
github hackingmaterials / rocketsled / examples / Folder / testing_fw.py View on Github external
if __name__ == "__main__":
    # set up the LaunchPad and reset it
    launchpad = LaunchPad()
    launchpad.reset('', require_password=False)

    fw_spec = {'input':{'A':1, 'B':2, 'C':3}}
    param_list = {'data':['X', 'y'], 'hyperparameters':[]}

    # create the Firework consisting of a single task
    firetask1 = CalculateTask()
    firetask2 = OptimizeTask()
    firework = Firework([firetask1, firetask2])

    # store workflow and launch it locally
    launchpad.add_wf(firework)
    launch_rocket(launchpad)
github hackingmaterials / rocketsled / old / examples / Categorical_task / test_code.py View on Github external
# Run run_num iterations using Skopt Gaussian Processes
    gp_best = []
    wf = workflow_creator(input_dict, 'skopt_gp')
    launchpad.add_wf(wf)
    for i in range(run_num):
        launch_rocket(launchpad)
        gp_best.append(manageDB.get_optima('f', min_or_max='max')[0])
    manageDB.clean()
    launchpad.defuse_wf(launchpad.get_fw_ids()[-1])

    # Run run_num iterations using a dummy optimizer (returns random)
    dummy_best = []
    wf = workflow_creator(input_dict, 'dummy')
    launchpad.add_wf(wf)
    for i in range(run_num):
        launch_rocket(launchpad)
        dummy_best.append(manageDB.get_optima('f', min_or_max='max')[0])
    manageDB.clean()

    iterations = list(range(run_num))
    print("GP best:", gp_best[-1])
    print("Dummy best: ", dummy_best[-1])
    plt.plot(iterations,gp_best,'g', iterations, dummy_best,'r')
    plt.show()