How to use the fireworks.core.launchpad.LaunchPad 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 / fireworks / fireworks / scripts / rlaunch_run.py View on Github external
if not args.launchpad_file and os.path.exists(os.path.join(args.config_dir, 'my_launchpad.yaml')):
        args.launchpad_file = os.path.join(args.config_dir, 'my_launchpad.yaml')
    elif not args.launchpad_file:
        args.launchpad_file = LAUNCHPAD_LOC

    if not args.fworker_file and os.path.exists(os.path.join(args.config_dir, 'my_fworker.yaml')):
        args.fworker_file = os.path.join(args.config_dir, 'my_fworker.yaml')
    elif not args.fworker_file:
        args.fworker_file = FWORKER_LOC

    args.loglvl = 'CRITICAL' if args.silencer else args.loglvl

    if args.command == 'singleshot' and args.offline:
        launchpad = None
    else:
        launchpad = LaunchPad.from_file(args.launchpad_file) if args.launchpad_file else LaunchPad(
            strm_lvl=args.loglvl)

    if args.fworker_file:
        fworker = FWorker.from_file(args.fworker_file)
    else:
        fworker = FWorker()

    # prime addr lookups
    _log = get_fw_logger("rlaunch", stream_level="INFO")
    _log.info("Hostname/IP lookup (this will take a few seconds)")
    get_my_host()
    get_my_ip()

    if args.command == 'rapidfire':
        rapidfire(launchpad, fworker=fworker, m_dir=None, nlaunches=args.nlaunches,
                  max_loops=args.max_loops, sleep_time=args.sleep, strm_lvl=args.loglvl,
github materialsproject / MPWorks / mpworks / fix_scripts / reparse_tasks.py View on Github external
def process_task(self, data):

        try:
            dir_name = data[0]
            parse_dos = data[1]
            prev_info = self.tasks.find_one({'dir_name_full': dir_name}, {'task_type': 1, 'snl_final': 1, 'snlgroup_id_final': 1, 'snlgroup_changed': 1})
            drone = MPVaspDrone(
                host=self.host, port=self.port,
                database=self.database, user=self.admin_user,
                password=self.admin_password,
                collection=self.collection, parse_dos=parse_dos,
                additional_fields={},
                update_duplicates=True)
            t_id, d = drone.assimilate(dir_name, launches_coll=LaunchPad.auto_load().launches)


            self.tasks.update({"task_id": t_id}, {"$set": {"snl_final": prev_info['snl_final'], "snlgroup_id_final": prev_info['snlgroup_id_final'], "snlgroup_changed": prev_info['snlgroup_changed']}})
            print 'FINISHED', t_id
        except:
            print '-----'
            print 'ENCOUNTERED AN EXCEPTION!!!', data[0]
            traceback.print_exc()
            print '-----'
github abinit / abipy / abipy / gw / GWworks.py View on Github external
def add_to_db(self):
        from fireworks.core.launchpad import LaunchPad
        launchpad_file = os.path.join(os.environ['FW_CONFIG_DIR'], 'my_launchpad.yaml')
        lp = LaunchPad.from_file(launchpad_file)
        lp.add_wf(self.wf)
github materialsproject / fireworks / fireworks / scripts / qlaunch_run.py View on Github external
args.launchpad_file = LAUNCHPAD_LOC

    if not args.fworker_file and os.path.exists(
            os.path.join(args.config_dir, 'my_fworker.yaml')):
        args.fworker_file = os.path.join(args.config_dir, 'my_fworker.yaml')
    elif not args.fworker_file:
        args.fworker_file = FWORKER_LOC

    if not args.queueadapter_file and os.path.exists(
            os.path.join(args.config_dir, 'my_qadapter.yaml')):
        args.queueadapter_file = os.path.join(args.config_dir, 'my_qadapter.yaml')
    elif not args.queueadapter_file:
        args.queueadapter_file = QUEUEADAPTER_LOC

    launchpad = LaunchPad.from_file(
        args.launchpad_file) if args.launchpad_file else LaunchPad(
        strm_lvl=args.loglvl)
    fworker = FWorker.from_file(
        args.fworker_file) if args.fworker_file else FWorker()
    queueadapter = load_object_from_file(args.queueadapter_file)
    args.loglvl = 'CRITICAL' if args.silencer else args.loglvl

    if args.command == 'rapidfire':
        rapidfire(launchpad, fworker=fworker, qadapter=queueadapter, launch_dir=args.launch_dir,
                  nlaunches=args.nlaunches, njobs_queue=args.maxjobs_queue,
                  njobs_block=args.maxjobs_block, sleep_time=args.sleep,
                  reserve=args.reserve, strm_lvl=args.loglvl, timeout=args.timeout, fill_mode=args.fill_mode)
    else:
        launch_rocket_to_queue(launchpad, fworker, queueadapter,
                               args.launch_dir, args.reserve, args.loglvl, False, args.fill_mode, args.fw_id)
github materialsproject / MPWorks / mpworks / firetasks / vasp_io_tasks.py View on Github external
logging.basicConfig(level=logging.INFO)
        logger = logging.getLogger('MPVaspDrone')
        logger.setLevel(logging.INFO)
        sh = logging.StreamHandler(stream=sys.stdout)
        sh.setLevel(getattr(logging, 'INFO'))
        logger.addHandler(sh)
        with open(db_path) as f:
            db_creds = json.load(f)
            drone = MPVaspDrone(host=db_creds['host'], port=db_creds['port'],
                                database=db_creds['database'], user=db_creds['admin_user'],
                                password=db_creds['admin_password'],
                                collection=db_creds['collection'], parse_dos=parse_dos,
                                additional_fields=self.additional_fields,
                                update_duplicates=self.update_duplicates)
            t_id, d = drone.assimilate(prev_dir, launches_coll=LaunchPad.auto_load().launches)

        mpsnl = d['snl_final'] if 'snl_final' in d else d['snl']
        snlgroup_id = d['snlgroup_id_final'] if 'snlgroup_id_final' in d else d['snlgroup_id']
        update_spec.update({'mpsnl': mpsnl, 'snlgroup_id': snlgroup_id})

        print 'ENTERED task id:', t_id
        stored_data = {'task_id': t_id}
        if d['state'] == 'successful':
            update_spec['analysis'] = d['analysis']
            update_spec['output'] = d['output']
            update_spec['vasp']={'incar':d['calculations'][-1]['input']['incar'],
                                 'kpoints':d['calculations'][-1]['input']['kpoints']}
            update_spec["task_id"]=t_id
            return FWAction(stored_data=stored_data, update_spec=update_spec)

        # not successful - first test to see if UnconvergedHandler is needed
github materialsproject / fireworks / fireworks / core / rocket.py View on Github external
'_all_stored_data': all_stored_data,
                              '_all_update_spec': all_update_spec,
                              '_all_mod_spec': all_mod_spec}
                Rocket.update_checkpoint(lp, launch_dir, fw_id, checkpoint)
 
                if lp:
                    l_logger.log(logging.INFO, "Task started: %s." % t.fw_name)

                # TODO
                # Should remove this functionality
                # OR serialize LaunchPad and FWorker and add them to spec
                if my_spec.get("_add_launchpad_and_fw_id"):
                    t.fw_id = m_fw.fw_id
                    if FWData().MULTIPROCESSING:
                        # hack because AutoProxy manager can't access attributes
                        t.launchpad = LaunchPad.from_dict(self.launchpad.to_dict())
                    else:
                        t.launchpad = self.launchpad

                if my_spec.get("_add_fworker"):
                    t.fworker = self.launchpad.fworker
                # END TODO

                try:
                    m_action = t.run_task(my_spec)
                except BaseException as e:
                    traceback.print_exc()
                    tb = traceback.format_exc()
                    stop_backgrounds(ping_stop, btask_stops)
                    do_ping(lp, fw_id)  # one last ping, esp if there is a monitor
                    # If the exception is serializable, save its details
                    if pdb_on_exception:
github materialsproject / fireworks / fw_tutorials / python / python_examples.py View on Github external
def setup():
    launchpad = LaunchPad(name='fireworks_test', strm_lvl='ERROR')
    launchpad.reset('', require_password=False)
    return launchpad
github materialsproject / MPWorks / mpworks / fix_scripts / classify_fizzled.py View on Github external
x = tdb.tasks.find_one({"fw_id": fw_id}, {"analysis": 1})
    warnings = x['analysis'].get('warnings', [])
    warnings.extend(x['analysis']['errors_MP']['signals'])
    errors = x['analysis'].get('errors', [])
    errors.extend(x['analysis']['errors_MP']['critical_signals'])

    warnings = set(warnings)
    errors = set(errors)
    warnings = warnings.difference(errors)
    return set(warnings), set(errors)


if __name__ == '__main__':
    module_dir = os.path.dirname(os.path.abspath(__file__))
    lp_f = os.path.join(module_dir, 'my_launchpad.yaml')
    lpdb = LaunchPad.from_file(lp_f)

    tasks_f = os.path.join(module_dir, 'tasks_read.yaml')
    creds = {}
    with open(tasks_f) as f:
        creds = yaml.load(f)

    connection = MongoClient(creds['host'], creds['port'])
    tdb = connection[creds['db']]
    tdb.authenticate(creds['username'], creds['password'])


    except_dict = defaultdict(int)
    fizzled_fws = []
github materialsproject / MPWorks / mpworks / fix_scripts / clear_FWs.py View on Github external
    @classmethod
    def setup(cls):
        module_dir = os.path.dirname(__file__)
        cls.lp = LaunchPad.from_file(os.path.join(module_dir, 'my_launchpad.yaml'))