def execute(self, name): try: self.state.saveState('READY') lp = LaunchPad(**self.db) lp.reset('', require_password=False) tasks = [] for idx, command in enumerate(self.commands): if idx > 0: tasks.append( Firework(ScriptTask.from_str(command), name=f'task_{idx}', fw_id=idx, parents=[tasks[idx - 1]])) else: tasks.append( Firework(ScriptTask.from_str(command), name=f'task_{idx}', fw_id=idx)) self.state.saveState('RUNNING') wf = Workflow(tasks, name=name) lp.add_wf(wf) rapidfire(lp) self.state.saveState('FINISHED') except Exception as e: print(e) self.state.saveState('ERROR')
def run_workflows(): TESTDB_NAME = 'rsled' launchpad = LaunchPad(name=TESTDB_NAME) # clean up tw database if necessary launchpad.reset(password=None, require_password=False) launchpad.add_wf(wf_creator([1, 1, 2, "red"])) rapidfire(launchpad, nlaunches=23, sleep_time=0)
def lp(request): lp = LaunchPad(name=TESTDB_NAME, strm_lvl='ERROR') lp.reset(password=None, require_password=False) def fin(): lp.connection.drop_database(TESTDB_NAME) request.addfinalizer(fin) return lp
def lp(request): lp = LaunchPad(name=TESTDB_NAME, strm_lvl='ERROR') lp.reset(password=None, require_password=False) def fin(): lp.connection.drop_database(TESTDB_NAME) # request.addfinalizer(fin) return lp
def main(algorithms, supports, datasets, working_directory, reset, launchpad_args): launchpad = LaunchPad(**launchpad_args) if reset: launchpad.reset("", require_password=False) working_directory = os.path.expandvars( os.path.expanduser(working_directory)) for dataset in datasets: for algorithm in algorithms: tasks = [] links = {} spec = {} spec["directory"] = os.path.join(working_directory, algorithm) spec["local_files"] = [os.path.abspath(dataset)] spec["_priority"] = 1000 try: short_working_directory = spec["directory"].replace( os.path.expanduser('~'), '~', 1) except ValueError: short_working_directory = spec["directory"] setup_firework_name = "setup {0}".format(short_working_directory) setup_firework = Firework(SetupWorkingDirectory(), spec=spec, name=setup_firework_name) tasks.append(setup_firework) for support in supports: spec = {} spec["database_filename"] = os.path.basename(dataset) spec["algorithm"] = algorithm spec["support"] = support spec["timings_filename"] = "{0}.{1}.{2}.timing".format( os.path.basename(dataset), algorithm, str(support).zfill(3)) spec["patterns_filename"] = "{0}.{1}.{2}.patterns.gz".format( os.path.basename(dataset), algorithm, str(support).zfill(3)) spec["_priority"] = support support_firework_name = "{0} {1}".format(algorithm, support) support_firework = Firework(SPMFTask(), spec=spec, name=support_firework_name) tasks.append(support_firework) links.setdefault(setup_firework, []).append(support_firework) workflow_name = "{0} {1}".format(os.path.basename(dataset), algorithm) workflow = Workflow(tasks, links, name=workflow_name) launchpad.add_wf(workflow)
def lpad(database, debug_mode): from fireworks import LaunchPad lpad = LaunchPad(name=database) lpad.reset("", require_password=False) yield lpad if not debug_mode: lpad.reset("", require_password=False) for coll in lpad.db.list_collection_names(): lpad.db[coll].drop()
def run_workflows(): TESTDB_NAME = 'rsled' launchpad = LaunchPad(name=TESTDB_NAME) # clean up tw database if necessary launchpad.reset(password=None, require_password=False) # load 10 batch workflows onto the launchpad for _ in range(10): launchpad.add_wf(wf_creator(random_guess(X_dim))) rapidfire(launchpad, nlaunches=10, sleep_time=0)
def run_workflows(): TESTDB_NAME = 'rsled' # clean up tw database if necessary launchpad = LaunchPad(name=TESTDB_NAME) launchpad.reset(password=None, require_password=False) launchpad.add_wf(wf_creator([1, 1, 2, "red"], launchpad, 3, my_kwarg=1)) # if n_launches > 24 for this particular example, the search space will be # exhausted and OptTask will throw an exception rapidfire(launchpad, nlaunches=24, sleep_time=0)
def main(reset, launchpad_args, rocket_args): if rocket_args["m_dir"]: try: os.makedirs(rocket_args["m_dir"]) except OSError: pass launchpad = LaunchPad(**launchpad_args) if reset: launchpad.reset("", require_password=False) rapidfire(launchpad=launchpad, **rocket_args)
def setUp(self): lpad = LaunchPad(name="test_emmet") lpad.reset('', require_password=False) self.lpad = lpad self.nofilter = PropertyWorkflowBuilder( self.elasticity, self.materials, wf_elastic_constant, material_filter=None, lpad=self.lpad) self.nofilter.connect() self.filter = PropertyWorkflowBuilder( self.elasticity, self.materials, wf_elastic_constant, material_filter={"task_id": {"$lt": 3}}, lpad=self.lpad) self.filter.connect()
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
n_cands = 20 n_runs = 20 filename = 'perovskites_{}_{}_{}cands_{}runs.p'.format( predictor, TESTDB_NAME, n_cands, n_runs) Y = [] for i in range(n_runs): rundb = TESTDB_NAME + "_{}".format(i) conn = MongoClient('localhost', 27017) db = getattr(conn, rundb) collection = db.test_perovskites filedir = os.path.dirname(os.path.realpath(__file__)) launchpad = LaunchPad(name=rundb) launchpad.reset(password=None, require_password=False) launchpad.add_wf( wf_creator(random.choice(space_noex), predictor, get_z, launchpad, filedir + '/space_gs_cat_included.p', chemical_rules=True)) y = [] cands = 0 while cands != n_cands: launch_rocket(launchpad) cands = collection.find({'yi': 30.0}).count() y.append(cands)
"EDIFF": 1E-7, "EDIFFG": -1E-3, "PREC": "Accurate", "NPAR": 2} custom_settings_dfpt = {"SYSTEM": "Si", "ENCUT": 600, "ISTART": 0, "ICHARG": 2, "ISMEAR": -5, "SIGMA": 0.02, "IBRION": 8, "IALGO": 38, "EDIFF": 1E-7, "EDIFFG": 1E-6, "PREC": "Accurate", "LCHARG": ".FALSE.", "LWAVE": ".FALSE.", "LREAL": ".FALSE.", "ADDGRID": ".TRUE."} KPOINT = Generate_kpoints(struct, 0.03) # set up the LaunchPad and reset it launchpad = LaunchPad(host=<your database url>, name="test") launchpad.reset('', require_password=False) workflow = wf_phonon_conductivity(struct, vasp_input_set_relax=custom_settings_relax, vasp_input_set_fixvol_relax=custom_settings_fixvol_relax, vasp_input_set_dfpt=custom_settings_dfpt, vasp_kpoint_set=KPOINT, vasp_cmd=">>vasp_cmd<<", db_file=">>db_file<<", Temp=[300], ifscale=True, supercell=[2,2,2]) # store workflow and launch it locally launchpad.add_wf(workflow)
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)
class automatic: def __init__(self, wfname, fxyz, fprot, reset=False): self.launchpad = LaunchPad() if reset: self.launchpad.reset('', require_password=False) self.wfname = wfname self.fxyz = fxyz self.fprot = fprot self.ftxyz = wfname + '.txyz' self.fkey = wfname + '.key' self.fref = wfname + '.hdf5' return def copy2cmcc(self): # copy to CMCC copy1 = FileTransferTask({ 'files': ['../' + self.fxyz, '../' + self.fprot], 'dest': 'ffgen/fireworks', 'mode': 'rtransfer', 'server': 'cmcc' }) copy = Firework([copy1], name='copy to cmcc', spec={ "pass_job_info": True, }) return copy def TMsetup(self, parent): # setup TM setup0 = FileTransferTask({ 'files': ['../' + self.fxyz, '../' + self.fprot], 'dest': '.', 'mode': 'copy' }) setup1 = ScriptTask.from_str(x2t(self.fxyz)) # x2t setup2 = ScriptTask.from_str(define(self.fprot)) # define setup3 = ScriptTask.from_str(info(self.wfname, 'TM_setup')) setup = Firework([setup0, setup1, setup2, setup3], name='TM_setup', spec={ "_pass_job_info": True, '_fworker': 'cmcc_front' }, parents=[parent]) return setup def opt(self, parent): #optimization opt1 = JobexTask(wf_name=self.wfname) opt = Firework([opt1], name='opt', parents=[parent], spec={ "_pass_job_info": True, '_fworker': 'cmcc_queue' }) return opt def hessian(self, parent): # aoforce force1 = AoforceTask(wf_name=self.wfname) force = Firework([force1], name='hessian', parents=[parent], spec={ "_pass_job_info": True, '_fworker': 'cmcc_queue' }) return force def extract(self, parent): # extract infos extract1 = ExtractTask(fxyz=self.fxyz, fref=self.wfname) extract2 = ScriptTask.from_str(info(self.wfname, 'extract')) extract = Firework([extract1, extract2], name='extract', parents=[parent], spec={ "_pass_job_info": True, '_fworker': 'cmcc_front' }) return extract def FFsetup(self, parent): # setup FF FF1 = CopyTask() FF2 = ScriptTask.from_str(info(self.wfname, 'FF_setup')) FF3 = ScriptTask.from_str( 'xyz2txyz -i final.xyz -o %s > /dev/null 2> xyz2txyz.err' % self.ftxyz) FF4 = ScriptTask.from_str( 'atomtyper -c %s -o %s > /dev/null 2> atomtyper.err' % (self.ftxyz, self.ftxyz)) FF5 = ScriptTask.from_str( 'create_key -i %s -o %s -r %s > key.out 2> key.err' % (self.ftxyz, self.fkey, self.wfname)) FF = Firework([FF1, FF2, FF3, FF4, FF5], name='FF_setup', parents=[parent], spec={ "_pass_job_info": True, '_fworker': 'cmcc_front' }) return FF def FFfit(self, parent): # fit FF fit0 = ScriptTask.from_str(info(self.wfname, 'FF_fit')) fit1 = RemoteCopyTask(server='cmcc', files=[self.fkey, self.ftxyz, self.fref]) fit2 = ScriptTask.from_str('fit-cma -c %s -k %s -r %s > fit.out \ 2> fit.err' % (self.ftxyz, self.fkey, self.wfname)) fit3 = ScriptTask.from_str('compare-freqs -c %s -k %s/opt.key -r %s > \ /dev/null 2> compare-freqs.err' % (self.ftxyz, self.wfname, self.wfname)) fit = Firework([fit0, fit1, fit2, fit3], name='FF_fit', parents=[parent], spec={ "_pass_job_info": True, '_fworker': 'merry' }) return fit def __call__(self): copy = self.copy2cmcc() setup = self.TMsetup(copy) opt = self.opt(setup) force = self.hessian(opt) extract = self.extract(force) FF = self.FFsetup(extract) fit = self.FFfit(FF) workflow = Workflow([copy, setup, opt, force, extract, FF, fit], name=self.wfname) # store workflow and launch it locally #launchpad.add_wf(setup) self.launchpad.add_wf(workflow) rapidfire(self.launchpad, FWorker()) return
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)
def run_workflows(): TESTDB_NAME = 'rsled' launchpad = LaunchPad(name=TESTDB_NAME) launchpad.reset(password=None, require_password=False) launchpad.add_wf(wf_creator([60, 45.0, "industry standard"])) rapidfire(launchpad, nlaunches=500, sleep_time=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()