def fwdict(fwid): import fireworks lpad = fireworks.LaunchPad(host='suncatls2.slac.stanford.edu', name='krisbrown', username='******', password='******') return lpad.get_fw_dict_by_id(fwid)
def __init__(self, host, username=None, name=None, password=None): """Initialize a fireworks instance.""" if username is None or name is None or password is None: username, name, password = netrc().authenticators(host) if username is None: raise ValueError('username, name, and password required.') launchpad = fireworks.LaunchPad(host=host, name=name, username=username, password=password) self.launchpad = launchpad
def get_lpad(spec=None): """Get a LaunchPad Parameters ---------- spec : dict, optional options for launchpad Returns ------- lpad : fw.LaunchPad """ if spec: lpad_spec = read_lpad_spec(spec) else: lpad_spec = dict() return fw.LaunchPad(**lpad_spec)
def launchpad(): """Returns a function that runs a Firework or Workflow""" lp = fw.LaunchPad( # TODO: Make this work via env variables for portability #host='ds013216.mlab.com', #name='wftests', #port=13216, #username='******', #password='******', ) #lp.reset('', require_password=False) def do_launch(thingy): """wf - firework or Workflow""" id_map = lp.add_wf(thingy) # id_map is dict of {old: new ids} fw_ids = list(id_map.values()) num_ran = 0 # run all fireworks from the Workflow we just added while True: result = lp.fireworks.find_one( { 'fw_id': { '$in': fw_ids }, 'state': 'READY' }, projection={'fw_id': True}) if result is not None: launch_rocket(lp, fw_id=result['fw_id']) num_ran += 1 else: break if num_ran < len(fw_ids): raise ValueError("Added workflow didn't complete") return return do_launch
#External Modules import subprocess,re,sys,os,json,pickle,sys,datetime,ase,ase.db,glob,sqlite3,ast,fireworks,prettytable,pymatgen,copy import numpy as np import ase.thermochemistry as asethermo import pymatgen.symmetry.analyzer as psa import pymatgen.io.ase as pmgase import ase.visualize as viz # Internal Modules import data_solids_wPBE,constraint,jobs,misc,readJobs import dbase as db from printParse import * # Constant Terms nELEM = len(ase.data.chemical_symbols) toAtomicNum = {symb:num for symb,num in zip(ase.data.chemical_symbols,range(nELEM))} lpad = fireworks.LaunchPad(host='suncatls2.slac.stanford.edu',name='krisbrown',username='******',password='******') # class Detail(object): def __init__(self,colname,datatype,rank,none,inputcols,func,axislabel=None,derivConv=None): if axislabel is None: axislabel = colname # Default axis label self.colname = colname # column name in database self.datatype = datatype # SQLITE datatype self.rank = rank # order in which columns should be calculated self.none = none # Boolean: skip calculation if any arguments are none self.inputcols = inputcols # Dependencies on other columns self.func = func # Function applied to input columns to get result self.axislabel = axislabel # For plotting self.derivConv = derivConv # Dictionary with convergence criteria (only for plotting) def __str__(self): return self.colname
NGENS = 10 def generate_initial(ncandidates, boundaries): pop = [] for _ in range(ncandidates): dude = [] for lo, hi in boundaries: dude.append(random.uniform(lo, hi)) pop.append(tuple(dude)) return pop if __name__ == '__main__': lp = fw.LaunchPad() wf = gcwf.make_genetics.make_genetic_workflow( ngens=NGENS, ncandidates=POPSIZE, template='input', initial_pop=generate_initial(POPSIZE, BOUNDS), conditions=CONDITIONS, ff_updater=updater, bounds=BOUNDS, wf_name='GAargon', ) lp.add_wf(wf)