Ejemplo n.º 1
0
def main():
    # set up the LaunchPad and reset it
    launchpad = LaunchPad()
    launchpad.reset('', require_password=False)

    # Build the flow
    nflows = 2
    for i in range(nflows):
        flow = build_flow("flow_" + str(i))
        flow.build_and_pickle_dump()

        # create the Firework consisting of a single task
        firework = Firework(FireTaskWithFlow(flow=flow))

        # store workflow 
        launchpad.add_wf(firework)

    #launch it locally
    #launch_rocket(launchpad)

    return 0
Ejemplo n.º 2
0
"""
This code is described in the Introductory tutorial, https://materialsproject.github.io/fireworks/introduction.html
"""

from fireworks import Firework, LaunchPad, ScriptTask
from fireworks.core.rocket_launcher import launch_rocket

if __name__ == "__main__":
    # set up the LaunchPad and reset it
    launchpad = LaunchPad()
    # launchpad.reset('', require_password=False)

    # create the Firework consisting of a single task
    firetask = ScriptTask.from_str('echo "howdy, your job launched successfully!"')
    firework = Firework(firetask)

    # store workflow and launch it locally
    launchpad.add_wf(firework)
    launch_rocket(launchpad)
Ejemplo n.º 3
0
from fireworks import LaunchPad, Firework, Workflow
from fireworks.core.rocket_launcher import launch_rocket
from fireworks.examples.custom_firetasks.hello_world.hello_world_task import HelloTask

if __name__ == "__main__":
    # initialize the database
    lp = LaunchPad()  # you might need to modify the connection settings here
    # lp.reset()  # uncomment this line and set the appropriate parameters if you want to reset the database

    # create the workflow and store it in the database
    my_fw = Firework([HelloTask()])
    my_wflow = Workflow.from_Firework(my_fw)
    lp.add_wf(my_wflow)

    # run the workflow
    launch_rocket(lp)
Ejemplo n.º 4
0
#==============================================================================
if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser(
            description='Demonstrates Fireworks workflows on OLCF resources.')
    parser.add_argument('--reset', action='store_true',
            help='Reset the database.')
    parser.add_argument('-p', '--push-wf', dest='push_wf', action='store_true',
            help='Push demo workflow to DB.')
    parser.add_argument('-b', '--block', action='store_true',
            help='Create a new output block.')
    parser.add_argument('-u', '--update-only', action='store_true',
            help='Update the DB, but do not process jobs.')
    parser.add_argument('-d', '--daemon-mode', action='store_true',
            help='Update the DB, but do not process jobs.')
    args = parser.parse_args()

    if args.reset:
        launchpad.reset('', require_password=False)

    if args.push_wf:
        launchpad.add_wf(workflow)

    if args.block:
        from fireworks.utilities.fw_utilities import create_datestamp_dir
        create_datestamp_dir(out_dir, launchpad.m_logger)

    if not args.update_only:
        process_offline(launchpad, launcher_args, args.daemon_mode)

Ejemplo n.º 5
0
    Returns:
        (Workflow): A workflow containing one FireWork (two FireTasks) which
            is automatically set up to run the optimization loop.

    """
    spec = {'_x': x}
    # ObjectiveFuncTask writes _y field to the spec internally.
    firework1 = Firework([ObjectiveFuncTask(), OptTask(**db_info)], spec=spec)
    return Workflow([firework1])


if __name__ == "__main__":
    # Make a MissionControl object
    mc = MissionControl(**db_info)

    # Reset the launchpad and optimization db for this example
    launchpad.reset(password=None, require_password=False)
    mc.reset(hard=True)

    # Configure the optimization db with MissionControl
    mc.configure(wf_creator=wf_creator, dimensions=x_dim)

    # Run the optimization loop 10 times.
    launchpad.add_wf(wf_creator([5, 5, 2]))
    rapidfire(launchpad, nlaunches=10, sleep_time=0)

    # Examine results
    plt = mc.plot()
    plt.show()
Ejemplo n.º 6
0
    """
    fin_len = x[0]
    fin_angle = x[1]
    useful_feature1 = fin_len + fin_angle ** 2
    useful_feature2 = fin_angle + fin_len
    return x + [useful_feature1, useful_feature2]


if __name__ == "__main__":
    # Make a MissionControl object
    mc = MissionControl(**db_info)

    # Reset the launchpad and optimization db for this example
    launchpad.reset(password=None, require_password=False)
    mc.reset(hard=True)

    # Configure the optimization db with MissionControl
    mc.configure(wf_creator=wf_creator,
                 dimensions=x_dim,
                 acq="maximin",
                 predictor="GaussianProcessRegressor",
                 get_z=get_z)

    # Run 30 workflows + optimization
    launchpad.add_wf(wf_creator([100, 45.0, "dolphin fin"]))
    rapidfire(launchpad, nlaunches=30)

    # Examine and plot the optimization
    plt = mc.plot(print_pareto=True)
    plt.show()
Ejemplo n.º 7
0
"""
This code is described in the Firetasks tutorial,
https://materialsproject.github.io/fireworks/firetask_tutorial.html
"""

from fireworks import Firework, FWorker, LaunchPad
from fireworks.core.rocket_launcher import launch_rocket
from fw_tutorials.firetask.addition_task import AdditionTask

if __name__ == "__main__":
    # set up the LaunchPad and reset it
    launchpad = LaunchPad()
    # launchpad.reset('', require_password=False)

    # create the Firework consisting of a custom "Addition" task
    firework = Firework(AdditionTask(), spec={"input_array": [1, 2]})

    # store workflow and launch it locally
    launchpad.add_wf(firework)
    launch_rocket(launchpad, FWorker())
Ejemplo n.º 8
0
    firework1 = Firework([
        CalculateTask(),
        OptTask(wf_creator='turboworks_examples.test_categorical.wf_creator',
                dimensions=fw1_dim,
                get_z='turboworks_examples.test_categorical.get_z',
                duplicate_check=True,
                opt_label="opt_categorical")
    ],
                         spec=fw1_spec)
    return Workflow([firework1])


def get_z(x):
    if x[1] == 1:
        cat = "tiger"
    else:
        cat = "lion"
    return [x[0]**2, cat]


if __name__ == "__main__":

    TESTDB_NAME = 'turboworks'
    launchpad = LaunchPad(name=TESTDB_NAME)
    launchpad.reset(password=None, require_password=False)
    launchpad.add_wf(wf_creator([1, 1, 2, "red"]))

    rapidfire(launchpad, nlaunches=23, sleep_time=0)

    # tear down database
    # launchpad.connection.drop_database(TESTDB_NAME)
Ejemplo n.º 9
0
Contributors
'''

import modena
from fireworks import Firework, Workflow, LaunchPad
from fireworks.core.rocket_launcher import rapidfire
from modulefinder import ModuleFinder

from modena.Strategy import BackwardMappingScriptTask
import os

# Source code in src/twoTanksMacroscopicProblem.C
SIMULATION = BackwardMappingScriptTask(
    script='../run.sh'
)


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

# create the individual FireWorks and Workflow
# Source code in src/twoTanksMacroscopicProblem.C
wf = Workflow([Firework(SIMULATION)], {}, name="simulation")

# store workflow and launch it locally
launchpad.add_wf(wf)
rapidfire(launchpad)

Ejemplo n.º 10
0
    def submit(self):
        from fireworks import LaunchPad, Firework, Workflow, PyTask
        from standardScripts import OptimizeLattice, GetBulkModulus, GetXCcontribs, SaveResults

        launchpad = LaunchPad(host='suncatls2.slac.stanford.edu',
                              name='krisbrown',
                              username='******',
                              password='******')

        names = [
            x + '_%d' % self.ID for x in [
                'OptimizeLattice', 'GetBulkModulus', 'GetXCcontribs',
                'SaveResults'
            ]
        ]

        clusters = self.allocate()  #
        timestamp = '_' + datetime.now().strftime('%Y_%m_%d_%H_%M')

        fw1 = Firework(
            [OptimizeLattice()],
            name=names[0],
            spec={
                "jobID":
                self.ID,
                '_fworker':
                clusters[0].fworker,
                "_pass_job_info":
                True,
                "_files_out": {
                    "fw1": "inp.gpw"
                },
                "_queueadapter":
                clusters[0].qfunc(self.guessTime('optimizelattice')),
                "_launch_dir":
                clusters[0].launchdir + names[0] + timestamp
            })

        fw2 = Firework(
            [GetBulkModulus()],
            name=names[1],
            parents=[fw1],
            spec={
                "jobID":
                self.ID,
                '_fworker':
                clusters[1].fworker,
                "_pass_job_info":
                True,
                "_queueadapter":
                clusters[1].qfunc(self.guessTime('getbulkmodulus')),
                "_launch_dir":
                clusters[1].launchdir + names[1] + timestamp
            })

        fw3 = Firework(
            [GetXCcontribs()],
            name=names[2],
            parents=[fw1],
            spec={
                "jobID": self.ID,
                '_fworker': clusters[2].fworker,
                "_pass_job_info": True,
                "_files_in": {
                    "fw1": "inp.gpw"
                },
                "_queueadapter":
                clusters[2].qfunc(self.guessTime('getxccontribs')),
                "_launch_dir": clusters[2].launchdir + names[2] + timestamp
            })

        fw4 = Firework(
            [SaveResults()],
            name=names[3],
            parents=[fw1, fw2, fw3],
            spec={
                "jobID": self.ID,
                '_fworker': clusters[3].fworker  #MUST be sherlock
                ,
                "_queueadapter":
                clusters[3].qfunc(self.guessTime('saveresults')),
                "_launch_dir": clusters[3].launchdir + names[3] + timestamp
            })

        wflow = Workflow([fw1, fw2, fw3, fw4],
                         name='BulkRelaxation_%d' % self.ID)

        print "Submitting job with ID = %d" % self.ID

        updateStatus('bulkjob', self.ID, 'initialized', 'queued')

        launchpad.add_wf(wflow)
Ejemplo n.º 11
0
def run_workflows():
    TESTDB_NAME = 'rsled'
    launchpad = LaunchPad(name=TESTDB_NAME)
    launchpad.reset(password=None, require_password=False)
    launchpad.add_wf(wf_creator([5, 5, 2]))
    rapidfire(launchpad, nlaunches=10, sleep_time=0)
Ejemplo n.º 12
0
    fin_angle = x[1]
    useful_feature1 = fin_len + fin_angle**2
    useful_feature2 = fin_angle + fin_len
    return x + [useful_feature1, useful_feature2]


if __name__ == "__main__":
    # Make a MissionControl object
    mc = MissionControl(**db_info)

    # Reset the launchpad and optimization db for this example
    launchpad.reset(password=None, require_password=False)
    mc.reset(hard=True)

    # Configure the optimization db with MissionControl
    mc.configure(
        wf_creator=wf_creator,
        dimensions=x_dim,
        acq="maximin",
        predictor="GaussianProcessRegressor",
        get_z=get_z,
    )

    # Run 30 workflows + optimization
    launchpad.add_wf(wf_creator([100, 45.0, "dolphin fin"]))
    rapidfire(launchpad, nlaunches=30)

    # Examine and plot the optimization
    plt = mc.plot(print_pareto=True)
    plt.show()
Ejemplo n.º 13
0
    Returns:
        (Workflow): A workflow containing one FireWork (two FireTasks) which
            is automatically set up to run the optimization loop.

    """
    spec = {"_x": x}
    # ObjectiveFuncTask writes _y field to the spec internally.
    firework1 = Firework([ObjectiveFuncTask(), OptTask(**db_info)], spec=spec)
    return Workflow([firework1])


if __name__ == "__main__":
    # Make a MissionControl object
    mc = MissionControl(**db_info)

    # Reset the launchpad and optimization db for this example
    launchpad.reset(password=None, require_password=False)
    mc.reset(hard=True)

    # Configure the optimization db with MissionControl
    mc.configure(wf_creator=wf_creator, dimensions=x_dim)

    # Run the optimization loop 10 times.
    launchpad.add_wf(wf_creator([5, 5, 2]))
    rapidfire(launchpad, nlaunches=10, sleep_time=0)

    # Examine results
    plt = mc.plot()
    plt.show()
Ejemplo n.º 14
0
from fireworks import LaunchPad, Firework, Workflow
from fireworks.core.rocket_launcher import launch_rocket
from fireworks.examples.custom_firetasks.hello_world.hello_world_task import HelloTask

if __name__ == "__main__":
    # initialize the database
    lp = LaunchPad()  # you might need to modify the connection settings here
    # lp.reset()  # uncomment this line and set the appropriate parameters if you want to reset the database

    # create the workflow and store it in the database
    my_fw = Firework([HelloTask()])
    my_wflow = Workflow.from_Firework(my_fw)
    lp.add_wf(my_wflow)

    # run the workflow
    launch_rocket(lp)
Ejemplo n.º 15
0
from fireworks import Firework, Workflow, LaunchPad, ScriptTask
from fireworks.core.rocket_launcher import rapidfire

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

# create the individual FireWorks and Workflow
fw1 = Firework(ScriptTask.from_str('echo "hello"'), name="hello")
fw2 = Firework(ScriptTask.from_str('echo "goodbye"'), name="goodbye", parents=[fw1,])
wf = Workflow([fw1, fw2], name="test workflow")

# store workflow and launch it locally
launchpad.add_wf(wf)
rapidfire(launchpad)
Ejemplo n.º 16
0
db = connect('A_ads_slab.db')

for i, d in enumerate(db.select()):

    #if i != 0:
    #    continue
    slab = d.toatoms()
    kvp = d.key_value_pairs
    kvp['metal'] = slab.get_chemical_symbols()[0]
    param = d.data
    slab.info = param

    # Encode the atoms
    encoding = atoms_to_encode(slab)

    # Define some searching keys
    omit_key = ['facet', 'layer', 'vacuum']
    kvp_sk = {a: b for a, b in kvp.items() if a not in omit_key}
    search_keys = {'calc': kvp_sk}

    # Two steps - write the input structure to an input file, then relax
    t0 = PyTask(func='qescripts.fwio.encode_to_atoms', args=[encoding])
    t1 = PyTask(func='qescripts.fwespresso.get_potential_energy',
                stored_data_varname='trajectory')

    # Package the tasks into a firework, the fireworks into a workflow,
    # and submit the workflow to the launchpad
    firework = Firework([t0, t1], spec={'_priority': 1}, name=search_keys)
    workflow = Workflow([firework])
    launchpad.add_wf(workflow)
Ejemplo n.º 17
0
def processfile(runfile):
    """Function to process testopia run yaml file and create workflows, add them 
    to run in fireworks"""
    with open(runfile, 'r') as f:
        run_details = yaml.load(f)
    testcases = run_details['test_run']['cases']
    print 'testcases:\n'
    print testcases
    testcasetype = type(testcases)
    print testcasetype
    run_id = int(run_details['test_run']['run_id'])
    print run_id
    environment_id = int(run_details['test_run']['environment_id'])
    print environment_id
    tcms = Testopia.from_config('/var/dt/tf/etc/testopia.cfg')
    environment_details = tcms.environment_get(environment_id)
    print environment_details
    rundetailsfromtcms = tcms.testrun_get(run_id)
    product_version = rundetailsfromtcms['product_version']
    build_id = rundetailsfromtcms['build_id']
    buildinfo = tcms.build_get(build_id)
    print buildinfo
    build_name = buildinfo['name']
    print "build name: " + build_name
    print "product_version " + product_version
    environment_name = environment_details['name']
    print environment_name
    environment_file = '/var/dt/tf/etc/environments/' + environment_name + '.py'
    environment_filepyc = environment_file + 'c'
    if os.path.isfile(environment_filepyc):
        print "environment pyc file is present, deleting it"
        os.remove(environment_filepyc)
    else:
        print "No cached environment pyc file found"
    print environment_file
    testsonfire = []
    fwsequence = {}
    fwkey = ''
    fwvalue = ''
    for testcase in testcases.keys():
        case_id = int(testcase)
        testcase_name = run_details['test_run']['cases'][testcase]['summary']
        argsf = [
            run_id, case_id, build_id, environment_id, environment_name,
            environment_file, testcase_name, product_version, build_name
        ]
        fw_test = Firework(PyTask(func='HookFW.runCase', args=argsf))
        print "argsf are:"
        print argsf
        testsonfire.append(fw_test)
        if fwvalue:
            fwsequence[fwvalue] = fw_test
            fwvalue = fw_test
        else:
            fwvalue = fw_test

    #To be run as last firework in the workflow, to compile logs for the entire set of testcases

    rebotcmd = "cd /var/dt/tf/logs/" + str(
        run_id
    ) + '; rebot -N "DTTF" -R */*.xml; ln -s report.html index.html; echo ok '
    fw_test = Firework(ScriptTask.from_str(rebotcmd))
    testsonfire.append(fw_test)
    fwsequence[fwvalue] = fw_test
    print "tests on fire:"
    print testsonfire
    print "test sequence:"
    print fwsequence
    workflow = Workflow(testsonfire, fwsequence)
    launchpad = LaunchPad()
    launchpad.add_wf(workflow)