How to use the fireworks.utilities.fw_utilities.get_slug function in FireWorks

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 materialsproject / MPWorks / mpworks / workflows / snl_to_wf_dielectrics.py View on Github external
incar = mpvis.get_incar(snl.structure)
    incar.update({"EDIFF":"1.0E-6", "ENCUT":"600", "NPAR":"2", "NWRITE":"3"})
    # incar.update({"ALGO":"Normal"})
    spec['vasp']['incar'] = incar.as_dict()
    kpoints_density = 3000
    k=Kpoints.automatic_density(snl.structure, kpoints_density, force_gamma=True)
    spec['vasp']['kpoints'] = k.as_dict()
    del spec['_dupefinder']
    # spec['run_tags'].append("origin")
    spec['_priority'] = priority
    spec["_pass_job_info"] = True
    spec['_allow_fizzled_parents'] = False
    spec['_queueadapter'] = QA_VASP
    spec['task_type'] = "Static Dielectrics"
    tasks = [VaspWriterTask(), get_custodian_task(spec)]
    fws.append(Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=1))
    connections[0] = [1] # define fw_id=1 is dependent on completion of fw_id=0

    # insert into DB - Static Dielectrics run
    spec = {'task_type': 'VASP db insertion', '_priority': priority, "_pass_job_info": True, '_allow_fizzled_parents': True, '_queueadapter': QA_DB}
    fws.append(Firework([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=2))
    connections[1] = [2,3] # define fw_id=2 is dependent on completion of fw_id=1

    # Setup Raman Calculation:
    spec= {'task_type': 'Setup Raman Task', '_priority': priority, "_pass_job_info": True, '_allow_fizzled_parents': False, '_queueadapter': QA_CONTROL}
    spec['passed_vars'] = []
    fws.append(Firework([SetupRamanTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=3))


    wf_meta = get_meta_from_structure(snl.structure)
    wf_meta['run_version'] = 'May 2013 (1)'
github materialsproject / MPWorks / mpworks / firetasks / elastic_tasks.py View on Github external
get_custodian_task(spec)], 
                                spec, 
                                name=get_slug(f + '--' + spec['task_type']), 
                                fw_id=-999+i*10))
            
            priority = fw_spec['_priority']*3
            spec = {'task_type': 'VASP db insertion', 
                    '_priority': priority,
                    '_allow_fizzled_parents': True, 
                    '_queueadapter': QA_DB, 
                    'elastic_constant':"deformed_structure", 
                    'clean_task_doc':True,
                    'deformation_matrix':d_struct_set.deformations[i].tolist(), 
                    'original_task_id':fw_spec["task_id"]}
            fws.append(Firework([VaspToDBTask(), AddElasticDataToDBTask()], spec,
                                name=get_slug(f + '--' + spec['task_type']),
                                fw_id=-998+i*10))
            connections[-999+i*10] = [-998+i*10]
            wf.append(Workflow(fws, connections))
        return FWAction(additions=wf)
github materialsproject / MPWorks / mpworks / fix_scripts / fix_bs_controller_tasks.py View on Github external
print 'AddEStructureTask v2', child_fw_id , 'reignited for', fw_id
                elif child_fw['state'] == 'FIZZLED':
                    lpdb.rerun_fw(child_fw_id)
                    print 'AddEStructureTask v2', child_fw_id , 'marked for rerun for', fw_id
                elif child_fw['state'] == 'COMPLETED':
                    print 'AddEStructureTask v2 already successfully run for', fw_id
                    sec_child_fw_id = wf['links'][str(child_fw_id)][0]
		    sec_child_fw = lpdb.fireworks.find_one({'fw_id': sec_child_fw_id}, {'spec.task_type':1, 'state':1})
		    if sec_child_fw['state'] == 'FIZZLED':
                        lpdb.rerun_fw(sec_child_fw_id)
		        print 'FIZZLED -> marked for rerun:', sec_child_fw_id, sec_child_fw['spec']['task_type']
                else:
                    print 'AddEStructureTask v2 added but neither DEFUSED, FIZZLED, or COMPLETED for', fw_id
                return
        f = lpdb.get_wf_summary_dict(fw_id)['name'].replace(' ', '_')
        name = get_slug(f + '--' + spec['task_type'])
        fw = Firework([AddEStructureTask()], spec, name=name)
        lpdb.append_wf(Workflow([fw]), [parent_fw_id])
        print name, 'added for', fw_id
    except ValueError:
        raise ValueError('could not append controller task to wf', wf['name'])
github hackingmaterials / atomate / atomate / vasp / powerups.py View on Github external
"""
    Every FireWork begins by writing an empty file with the name
    "FW--". This makes it easy to figure out what jobs are in what
    launcher directories, e.g. "ls -l launch*/FW--*" from within a "block" dir.

    Args:
        original_wf (Workflow)
        use_slug (bool): whether to replace whitespace-type chars with a slug

    Returns:
       Workflow
    """
    for idx, fw in enumerate(original_wf.fws):
        fname = "FW--{}".format(fw.name)
        if use_slug:
            fname = get_slug(fname)

        t = FileWriteTask(files_to_write=[{"filename": fname, "contents": ""}])
        original_wf.fws[idx].tasks.insert(0, t)
    return original_wf
github hackingmaterials / atomate / atomate / vasp / powerups.py View on Github external
def add_namefile(original_wf, use_slug=True):
    """
    Every FireWork begins by writing an empty file with the name
    "FW--". This makes it easy to figure out what jobs are in what
    launcher directories, e.g. "ls -l launch*/FW--*" from within a "block" dir.

    Args:
        original_wf (Workflow)
        use_slug (bool): whether to replace whitespace-type chars with a slug
    """
    wf_dict = original_wf.to_dict()
    for idx, fw in enumerate(wf_dict["fws"]):
        fname = "FW--{}".format(fw["name"])
        if use_slug:
            fname = get_slug(fname)
        wf_dict["fws"][idx]["spec"]["_tasks"].insert(0, FileWriteTask(
            files_to_write=[{"filename": fname, "contents": ""}]).to_dict())
    return Workflow.from_dict(wf_dict)
github materialsproject / MPWorks / mpworks / firetasks / custodian_task.py View on Github external
def _write_formula_file(self, fw_spec):
        filename = get_slug(
            'JOB--' + fw_spec['mpsnl']['reduced_cell_formula_abc'] + '--'
            + fw_spec['task_type'])
        with open(filename, 'w+') as f:
            f.write('')
github materialsproject / MPWorks / mpworks / firetasks / dielectrics_tasks.py View on Github external
#for i, strain in enumerate(deformed_structs.keys()):
        fws=[]
        connections={}
        #d_struct = deformed_structs[strain]
        f = Composition(relaxed_struct.formula).alphabetical_formula
        snl = StructureNL(relaxed_struct, 'Ioannis Petousis ',projects=["Static Dielectrics", "force_convergence"])

        tasks = [AddSNLTask()]
        snl_priority = fw_spec.get('priority', 1)
        spec = {'task_type': 'Add F-relaxed Struct to SNL database', 'snl': snl.as_dict(), '_queueadapter': QA_DB, '_priority': snl_priority}
        if 'snlgroup_id' in fw_spec and isinstance(snl, MPStructureNL):
            spec['static_dielectrics_mpsnl'] = snl.as_dict()
            spec['static_dielectrics_snlgroup_id'] = fw_spec['snlgroup_id']
            del spec['snl']
        fws.append(Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=10))
        connections[10] = [11]

        #incar = Incar.from_file(zpath("INCAR"))
        #ediff = incar['EDIFF']
        #encut = incar['ENCUT']
        #ediff = fw_spec['vasp']['incar']['EDIFF']
        #encut = fw_spec['vasp']['incar']['ENCUT']
        spec = snl_to_wf._snl_to_spec(snl, parameters={'exact_structure':True})
        mpvis = MPStaticDielectricDFPTVaspInputSet()
        incar = mpvis.get_incar(snl.structure)
        incar.update({"EDIFF":"1.0E-6", "ENCUT":"600", "NWRITE":"3"})
        kpoints_density = 3000
        k=Kpoints.automatic_density(snl.structure, kpoints_density, force_gamma=True)
        spec['vasp']['incar'] = incar.as_dict()
        spec['vasp']['kpoints'] = k.as_dict()
        #kpoints=fw_spec['vasp']['kpoints']
github materialsproject / MPWorks / mpworks / examples / wf_ex.py View on Github external
# SetupStaticRunTask - override old parameters for static run
    # CustodianTaskEx - run VASP within a custodian
    spec = {'task_type': 'GGA static example'}
    copytask = VaspCopyTask({'use_CONTCAR': True, 'skip_CHGCAR': True})
    setuptask = SetupStaticRunTask()
    custodiantask = VaspCustodianTaskEx({'jobs': [VaspJob('', auto_npar=False).as_dict()], 'handlers': [h.as_dict() for h in handlers], 'max_errors': 5})
    fws.append(Firework([copytask, setuptask, custodiantask], spec, name=get_name(structure, spec['task_type']), fw_id=3))
    connections[2] = [3]

    # 4th Firework - insert previous run into DB
    spec = {'task_type': 'VASP db insertion example'}
    fws.append(
        Firework([VaspToDBTaskEx()], spec, name=get_name(structure, spec['task_type']), fw_id=4))
    connections[3] = [4]

    return Workflow(fws, connections, name=get_slug(structure.formula))
github materialsproject / MPWorks / mpworks / examples / wf_ex.py View on Github external
def get_name(structure, task_type):
    return get_slug(structure.formula + '--' + task_type)