Esempio n. 1
0
    def from_dict(cls, d):
        """
        Args:
            d (dict): Dict representation

        Returns:
            ConversionVoltagePair
        """
        dec = MontyDecoder()
        working_ion_entry = dec.process_decoded(d["working_ion_entry"])
        balanced_rxn = dec.process_decoded(d["balanced_rxn"])
        entries_charge = dec.process_decoded(d["entries_charge"])
        entries_discharge = dec.process_decoded(d["entries_discharge"])
        return ConversionVoltagePair(
            balanced_rxn,
            d["voltage"],
            d["mAh"],
            d["vol_charge"],
            d["vol_discharge"],
            d["mass_charge"],
            d["mass_discharge"],
            d["frac_charge"],
            d["frac_discharge"],
            entries_charge,
            entries_discharge,
            working_ion_entry,
        )
Esempio n. 2
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(d["composition"], d["energy"], d["correction"],
                dec.process_decoded(d.get("parameters", {})),
                dec.process_decoded(d.get("data", {})),
                entry_id=d.get("entry_id", None),
                attribute=d["attribute"] if "attribute" in d else None)
Esempio n. 3
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(dec.process_decoded(d["structure"]),
                d["energy"], d["correction"],
                dec.process_decoded(d.get("parameters", {})),
                dec.process_decoded(d.get("data", {})),
                entry_id=d.get("entry_id", None))
Esempio n. 4
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(d["composition"], d["energy"], d["correction"],
                dec.process_decoded(d.get("parameters", {})),
                dec.process_decoded(d.get("data", {})),
                entry_id=d.get("entry_id", None),
                attribute=d["attribute"] if "attribute" in d else None)
Esempio n. 5
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(dec.process_decoded(d["structure"]),
                d["energy"], d["correction"],
                dec.process_decoded(d.get("parameters", {})),
                dec.process_decoded(d.get("data", {})),
                entry_id=d.get("entry_id", None))
Esempio n. 6
0
    def from_dict(cls, d):
        """
        Args:
            d (dict): Dict representation

        Returns:
            Class
        """
        a = d["about"]
        dec = MontyDecoder()

        created_at = dec.process_decoded(a.get("created_at"))
        data = {k: v for k, v in d["about"].items() if k.startswith("_")}
        data = dec.process_decoded(data)

        structure = Structure.from_dict(
            d) if "lattice" in d else Molecule.from_dict(d)
        return cls(
            structure,
            a["authors"],
            projects=a.get("projects", None),
            references=a.get("references", ""),
            remarks=a.get("remarks", None),
            data=data,
            history=a.get("history", None),
            created_at=created_at,
        )
Esempio n. 7
0
 def from_dict(cls, d) -> "GibbsComputedStructureEntry":
     """
     :param d: Dict representation.
     :return: GibbsComputedStructureEntry
     """
     dec = MontyDecoder()
     return cls(
         dec.process_decoded(d["structure"]),
         d["formation_enthalpy"],
         d["temp"],
         d["gibbs_model"],
         correction=d["correction"],
         energy_adjustments=[
             dec.process_decoded(e) for e in d.get("energy_adjustments", {})
         ],
         parameters={
             k: dec.process_decoded(v)
             for k, v in d.get("parameters", {}).items()
         },
         data={
             k: dec.process_decoded(v)
             for k, v in d.get("data", {}).items()
         },
         entry_id=d.get("entry_id", None),
     )
Esempio n. 8
0
 def from_dict(cls, d) -> "ComputedEntry":
     """
     :param d: Dict representation.
     :return: ComputedEntry
     """
     dec = MontyDecoder()
     # the first block here is for legacy ComputedEntry that were
     # serialized before we had the energy_adjustments attribute.
     if d["correction"] != 0 and not d.get("energy_adjustments"):
         return cls(
             d["composition"],
             d["energy"],
             d["correction"],
             parameters={k: dec.process_decoded(v) for k, v in d.get("parameters", {}).items()},
             data={k: dec.process_decoded(v) for k, v in d.get("data", {}).items()},
             entry_id=d.get("entry_id", None),
         )
     # this is the preferred / modern way of instantiating ComputedEntry
     # we don't pass correction explicitly because it will be calculated
     # on the fly from energy_adjustments
     return cls(
         d["composition"],
         d["energy"],
         correction=0,
         energy_adjustments=[dec.process_decoded(e) for e in d.get("energy_adjustments", {})],
         parameters={k: dec.process_decoded(v) for k, v in d.get("parameters", {}).items()},
         data={k: dec.process_decoded(v) for k, v in d.get("data", {}).items()},
         entry_id=d.get("entry_id", None),
     )
Esempio n. 9
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(
         dec.process_decoded(d["voltage_pairs"]),
         dec.process_decoded(d["working_ion_entry"]),
         Composition(d["initial_comp"]),
     )
Esempio n. 10
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     sub_d = {"optional_files": {}}
     for k, v in d.items():
         if k in ["INCAR", "POSCAR", "POTCAR", "KPOINTS"]:
             sub_d[k.lower()] = dec.process_decoded(v)
         elif k not in ["@module", "@class"]:
             sub_d["optional_files"][k] = dec.process_decoded(v)
     return cls(**sub_d)
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(dec.process_decoded(d["structure"]),
                d["energy"], d["correction"],
                parameters={k: dec.process_decoded(v)
                            for k, v in d.get("parameters", {}).items()},
                data={k: dec.process_decoded(v)
                      for k, v in d.get("data", {}).items()},
                entry_id=d.get("entry_id", None))
Esempio n. 12
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(dec.process_decoded(d["structure"]),
                d["energy"], d["correction"],
                parameters={k: dec.process_decoded(v)
                            for k, v in d.get("parameters", {}).items()},
                data={k: dec.process_decoded(v)
                      for k, v in d.get("data", {}).items()},
                entry_id=d.get("entry_id", None))
Esempio n. 13
0
    def from_dict(cls, d):
        dec = MontyDecoder()
        scf_strategy = dec.process_decoded(d["scf_strategy"])
        ksampling = dec.process_decoded(d["ksampling"])
        nscf_nband = dec.process_decoded(d["nscf_nband"])
        nscf_algorithm = dec.process_decoded(d["nscf_algorithm"])

        return cls(scf_strategy=scf_strategy, ksampling=ksampling,
                   nscf_nband=nscf_nband, nscf_algorithm=nscf_algorithm, **d['extra_abivars'])
Esempio n. 14
0
 def from_dict(cls, d):
     d = d.copy()
     d.pop("@module", None)
     d.pop("@class", None)
     dec = MontyDecoder()
     d["spin_mode"] = dec.process_decoded(d["spin_mode"])
     d["smearing"] = dec.process_decoded(d["smearing"])
     d["algorithm"] = dec.process_decoded(d["algorithm"]) if d["algorithm"] else None
     return cls(**d)
Esempio n. 15
0
 def from_dict(cls, d):
     d = d.copy()
     d.pop("@module", None)
     d.pop("@class", None)
     dec = MontyDecoder()
     d["spin_mode"] = dec.process_decoded(d["spin_mode"])
     d["smearing"] = dec.process_decoded(d["smearing"])
     d["algorithm"] = dec.process_decoded(d["algorithm"]) if d["algorithm"] else None
     return cls(**d)
Esempio n. 16
0
    def from_dict(cls, d):
        dec = MontyDecoder()
        structure = dec.process_decoded(d["structure"])
        pseudos = dec.process_decoded(d['pseudos'])
        ksampling = dec.process_decoded(d["ksampling"])
        electrons = dec.process_decoded(d["electrons"])

        return cls(structure=structure, pseudos=pseudos, ksampling=ksampling, accuracy=d['accuracy'],
                   spin_mode=electrons.spin_mode, smearing=electrons.smearing, charge=d['charge'],
                   scf_algorithm=electrons.algorithm, use_symmetries=d['use_symmetries'],
                   **d['extra_abivars'])
Esempio n. 17
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     if 'is_valid' in d:
         return cls(controller=dec.process_decoded(d['controller']),
                    state=d['state'], problems=d['problems'],
                    actions=dec.process_decoded(d['actions']),
                    restart=d['restart'], is_valid=d['is_valid'])
     else:
         return cls(controller=dec.process_decoded(d['controller']),
                    state=d['state'], problems=d['problems'],
                    actions=dec.process_decoded(d['actions']),
                    restart=d['restart'])
Esempio n. 18
0
    def from_dict(cls, d):
        dec = MontyDecoder()
        structure = dec.process_decoded(d["structure"])
        pseudos = [Pseudo.from_file(p['filepath']) for p in d['pseudos']]
        ksampling = dec.process_decoded(d["ksampling"])
        spin_mode = dec.process_decoded(d["spin_mode"])
        smearing = dec.process_decoded(d["smearing"])

        return cls(structure=structure, pseudos=pseudos, ksampling=ksampling, accuracy=d['accuracy'],
                   spin_mode=spin_mode, smearing=smearing, charge=d['charge'],
                   scf_algorithm=d['scf_algorithm'], use_symmetries=d['use_symmetries'],
                   relax_algo=d['relax_algo'], **d['extra_abivars'])
Esempio n. 19
0
    def from_dict(cls, d):
        """
        Args:
            d (dict): from as_dict()

        Returns:
            A ComputedReaction object.
        """
        dec = MontyDecoder()
        reactants = [dec.process_decoded(e) for e in d["reactants"]]
        products = [dec.process_decoded(e) for e in d["products"]]
        return cls(reactants, products)
Esempio n. 20
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     working_ion_entry = dec.process_decoded(d["working_ion_entry"])
     balanced_rxn = dec.process_decoded(d["balanced_rxn"])
     entries_charge = dec.process_decoded(d["entries_charge"])
     entries_discharge = dec.process_decoded(d["entries_discharge"])
     return ConversionVoltagePair(balanced_rxn, d["voltage"], d["mAh"],
                                d["vol_charge"], d["vol_discharge"],
                                d["mass_charge"], d["mass_discharge"],
                                d["frac_charge"], d["frac_discharge"],
                                entries_charge, entries_discharge,
                                working_ion_entry)
Esempio n. 21
0
    def from_dict(cls, d):
        """
        Args:
            d (dict): Dict representation

        Returns:
            InsertionElectrode
        """
        from monty.json import MontyDecoder
        dec = MontyDecoder()
        return cls(dec.process_decoded(d["entries"]),
                   dec.process_decoded(d["working_ion_entry"]))
Esempio n. 22
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     if 'is_valid' in d:
         return cls(controller=dec.process_decoded(d['controller']),
                    state=d['state'], problems=d['problems'],
                    actions=dec.process_decoded(d['actions']),
                    restart=d['restart'], is_valid=d['is_valid'])
     else:
         return cls(controller=dec.process_decoded(d['controller']),
                    state=d['state'], problems=d['problems'],
                    actions=dec.process_decoded(d['actions']),
                    restart=d['restart'])
Esempio n. 23
0
    def from_dict(cls, d):
        """
        Args:
            d (dict): Dict representation

        Returns:
            ConversionElectrode
        """
        dec = MontyDecoder()
        return cls(dec.process_decoded(d["voltage_pairs"]),
                   dec.process_decoded(d["working_ion_entry"]),
                   Composition(d["initial_comp"]))
Esempio n. 24
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     working_ion_entry = dec.process_decoded(d["working_ion_entry"])
     balanced_rxn = dec.process_decoded(d["balanced_rxn"])
     entries_charge = dec.process_decoded(d["entries_charge"])
     entries_discharge = dec.process_decoded(d["entries_discharge"])
     return ConversionVoltagePair(balanced_rxn, d["voltage"], d["mAh"],
                                  d["vol_charge"], d["vol_discharge"],
                                  d["mass_charge"], d["mass_discharge"],
                                  d["frac_charge"], d["frac_discharge"],
                                  entries_charge, entries_discharge,
                                  working_ion_entry)
Esempio n. 25
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     sub_d = {"optional_files": {}}
     potcar=d.get('POTCAR',False) 
     if potcar:
        infiles=["INCAR", "POSCAR", "POTCAR", "KPOINTS"]
     else:
        infiles=["INCAR", "POSCAR", "KPOINTS"] 
     for k, v in d.items():
         if k in infiles:
             sub_d[k.lower()] = dec.process_decoded(v)
         elif k not in ["@module", "@class"]:
             sub_d["optional_files"][k] = dec.process_decoded(v)
     return cls(**sub_d)
Esempio n. 26
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(d["composition"],
                d["calculator"],
                inputs={
                    k: dec.process_decoded(v)
                    for k, v in d.get("inputs", {}).items()
                },
                data={
                    k: dec.process_decoded(v)
                    for k, v in d.get("data", {}).items()
                },
                entry_id=d.get("entry_id", None),
                attribute=d["attribute"] if "attribute" in d else None,
                tag=d["tag"] if "tag" in d else None)
Esempio n. 27
0
    def from_dict(cls, d):
        a = d["about"]
        dec = MontyDecoder()

        created_at = dec.process_decoded(a.get("created_at"))
        data = {k: v for k, v in d["about"].items()
                if k.startswith("_")}
        data = dec.process_decoded(data)

        structure = Structure.from_dict(d) if "lattice" in d \
            else Molecule.from_dict(d)
        return cls(structure, a["authors"], projects=a.get("projects", None),
                   references=a.get("references", ""),
                   remarks=a.get("remarks", None), data=data,
                   history=a.get("history", None), created_at=created_at)
Esempio n. 28
0
    def from_dict_legacy(cls, d):
        """
        Args:
            d (dict): Dict representation

        Returns:
            InsertionElectrode
        """
        from monty.json import MontyDecoder

        dec = MontyDecoder()
        return InsertionElectrode(  # pylint: disable=E1120
            dec.process_decoded(d["entries"]),
            dec.process_decoded(d["working_ion_entry"]),
        )
Esempio n. 29
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     kwargs = {
         k: dec.process_decoded(v)
         for k, v in d.items() if k in inspect.getargspec(cls.__init__).args
     }
     return cls(**kwargs)
Esempio n. 30
0
 def from_dict(cls, d):
     d = d.copy()
     d.pop('@module', None)
     d.pop('@class', None)
     dec = MontyDecoder()
     d['kpts'] = dec.process_decoded(d['kpts'])
     return cls(**d)
Esempio n. 31
0
 def from_dict(cls, d):
     d = d.copy()
     d.pop('@module', None)
     d.pop('@class', None)
     dec = MontyDecoder()
     d['kpts'] = dec.process_decoded(d['kpts'])
     return cls(**d)
Esempio n. 32
0
    def apply_corrections(self, fw_to_correct, corrections):
        # Apply the corrections
        spec = fw_to_correct.spec
        modder = Modder()
        for correction in corrections:
            actions = correction['actions']
            for action in actions:
                if action['action_type'] == 'modify_object':
                    if action['object']['source'] == 'fw_spec':
                        myobject = spec[action['object']['key']]
                    else:
                        raise NotImplementedError('Object source "{}" not implemented in '
                                                  'CheckTask'.format(action['object']['source']))
                    newobj = modder.modify_object(action['action'], myobject)
                    spec[action['object']['key']] = newobj
                elif action['action_type'] == 'modify_dict':
                    if action['dict']['source'] == 'fw_spec':
                        mydict = spec[action['dict']['key']]
                    else:
                        raise NotImplementedError('Dict source "{}" not implemented in '
                                                  'CheckTask'.format(action['dict']['source']))
                    modder.modify(action['action'], mydict)
                else:
                    raise NotImplementedError('Action type "{}" not implemented in '
                                              'CheckTask'.format(action['action_type']))
        # Keep track of the corrections that have been applied
        spec['SRC_check_corrections'] = corrections

        # Update the task index
        fws_task_index = int(fw_to_correct.spec['wf_task_index'].split('_')[-1])
        new_index = fws_task_index + 1
        # Update the Fireworks _queueadapter key
        #TODO: in the future, see whether the FW queueadapter might be replaced by the qtk_queueadapter ?
        #      ... to be discussed with Anubhav, when the qtk queueadapter is in a qtk toolkit and not anymore
        #          in pymatgen/io/abinit
        spec['_queueadapter'] = spec['qtk_queueadapter'].get_subs_dict()
        queue_adapter_update = get_queue_adapter_update(qtk_queueadapter=spec['qtk_queueadapter'],
                                                        corrections=corrections)

        # Get and update the task_input if needed
        # TODO: make this more general ... right now, it is based on AbinitInput and thus is strongly tight
        #       to abinit due to abiinput, deps, ...
        mytask = fw_to_correct.tasks[0]
        task_class = mytask.__class__
        decoder = MontyDecoder()
        task_input = decoder.process_decoded(fw_to_correct.spec['_tasks'][0]['abiinput'])
        initialization_info = fw_to_correct.spec['initialization_info']
        deps = mytask.deps

        # Create the new Setup/Run/Check fireworks
        SRC_fws = createSRCFireworksOld(task_class=task_class, task_input=task_input, SRC_spec=spec,
                                        initialization_info=initialization_info,
                                        wf_task_index_prefix=spec['wf_task_index_prefix'],
                                        current_task_index=new_index,
                                        handlers=self.handlers, validators=self.validators,
                                        deps=deps,
                                        task_type=mytask.task_type, queue_adapter_update=queue_adapter_update)
        wf = Workflow(fireworks=SRC_fws['fws'], links_dict=SRC_fws['links_dict'])
        return FWAction(detours=[wf])
Esempio n. 33
0
 def __setstate__(self, d):
     del d["@class"]
     del d["@module"]
     if "@version" in d:
         del d["@version"]
     md = MontyDecoder()
     d = md.process_decoded(d)
     self.__init__(**d)
Esempio n. 34
0
 def from_dict(cls, d) -> 'ComputedStructureEntry':
     """
     :param d: Dict representation.
     :return: ComputedStructureEntry
     """
     dec = MontyDecoder()
     return cls(dec.process_decoded(d["structure"]),
                d["energy"],
                d["correction"],
                parameters={
                    k: dec.process_decoded(v)
                    for k, v in d.get("parameters", {}).items()
                },
                data={
                    k: dec.process_decoded(v)
                    for k, v in d.get("data", {}).items()
                },
                entry_id=d.get("entry_id", None))
Esempio n. 35
0
 def __setstate__(self, d):
     """
     Double underscore method used by pickle to deserialize this object
     This uses MSONable deerialization instead
     """
     del d["@class"]
     del d["@module"]
     md = MontyDecoder()
     d = md.process_decoded(d)
     self.__init__(**d)
Esempio n. 36
0
 def run_task(self, fw_spec):
     struct = self.get("structure") or fw_spec["structure"]
     s = Structure.from_dict(struct.as_dict())
     user_incar_settings = fw_spec.get("user_incar_settings", {})
     vasp_input_set = MPRelaxSet(s, user_incar_settings=user_incar_settings)
     dec = MontyDecoder()
     vis = dec.process_decoded(vasp_input_set.as_dict())
     output_dir = os.getcwd()
     vis.write_input(output_dir=output_dir)
     return FWAction()
Esempio n. 37
0
    def from_dict(d):
        a = d["about"]
        dec = MontyDecoder()

        created_at = dec.process_decoded(a["created_at"]) if "created_at" in a \
            else None
        data = {k: v for k, v in d["about"].items() if k.startswith("_")}
        data = dec.process_decoded(data)

        structure = Structure.from_dict(d) if "lattice" in d \
            else Molecule.from_dict(d)
        return EGStructureNL(structure,
                             a["authors"],
                             projects=a.get("projects", None),
                             references=a.get("references", ""),
                             remarks=a.get("remarks", None),
                             data=data,
                             history=a.get("history", None),
                             created_at=created_at)
Esempio n. 38
0
    def featurize(self, dict_data):
        """Convert a string to a pymatgen Composition.

        Args:
            dict_data (dict): A MSONable dictionary. E.g. Produced from
                `pymatgen.core.structure.Structure.as_dict()`.

        Returns:
            (object): An object with the type specified by `dict_data`.
        """
        md = MontyDecoder()
        return [md.process_decoded(dict_data)]
Esempio n. 39
0
    def featurize(self, dict_data):
        """Convert a string to a pymatgen Composition.

        Args:
            dict_data (dict): A MSONable dictionary. E.g. Produced from
                `pymatgen.core.structure.Structure.as_dict()`.

        Returns:
            (object): An object with the type specified by `dict_data`.
        """
        md = MontyDecoder()
        return [md.process_decoded(dict_data)]
Esempio n. 40
0
 def run_task(self, fw_spec):
     material_id = self["material_id"]
     mode = self["mode"]
     dest_root = fw_spec["_fw_env"]["run_dest_root"]
     dest = "{}/{}/bs/{}/static".format(dest_root, os.environ["USER"],
                                        material_id)
     user_incar_settings = fw_spec.get("user_incar_settings", {})
     if mode.lower() == "line":
         vasp_input_set = MPNonSCFSet.from_prev_calc(
             dest,
             standardize=1e-3,
             user_incar_settings=user_incar_settings,
             mode=mode)
         dec = MontyDecoder()
         vis = dec.process_decoded(vasp_input_set.as_dict())
         vis.write_input(".")
     elif mode.lower() == "uniform":
         vasp_input_set = MPNonSCFSet.from_prev_calc(
             dest, user_incar_settings=user_incar_settings, mode=mode)
         dec = MontyDecoder()
         vis = dec.process_decoded(vasp_input_set.as_dict())
         vis.write_input(".")
Esempio n. 41
0
 def run_task(self, fw_spec):
     material_id = self["material_id"]
     dest_root = fw_spec["_fw_en"]["run_dest_root"]
     dest = "{}/{}/bs/{}/relax".format(dest_root, os.environ["USER"],
                                       material_id)
     user_incar_settings = fw_spec.get("user_incar_settings", {})
     vasp_input_set = MPStaticSet.from_prev_calc(
         prev_calc_dir=dest,
         standardize=1e-3,
         user_incar_settings=user_incar_settings)
     dec = MontyDecoder()
     vis = dec.process_decoded(vasp_input_set.as_dict())
     vis.write_input(".")
Esempio n. 42
0
    def from_dict(cls, d):
        """
        Generates object from JSON representation.
        Overwrites base method to handle sets.

        Args:
            d (dict): json representation of the object.

        Returns:
            An instance of MoleculeSystem.
        """
        d = d.copy()
        d.pop('@module', None)
        d.pop('@class', None)
        dec = MontyDecoder()
        d['molecule'] = dec.process_decoded(d['molecule'])
        d['int_def'] = [dec.process_decoded(i) for i in d['int_def']]
        d['frozen_indices'] = set(
            dec.process_decoded(i) for i in d['frozen_indices'])
        d['user_defined_bonds'] = set(
            tuple(i) for i in d['user_defined_bonds'])
        return cls(**d)
Esempio n. 43
0
 def process_item(self, item):
     mp_id = item['mp-id']
     self.logger.debug("Processing {}".format(mp_id))
     decoder = MontyDecoder()
     ph_bs = decoder.process_decoded(item['ph_bs'])
     web_doc = ph_bs.as_phononwebsite()
     plotter = PhononBSPlotter(ph_bs)
     ylim = (0, max(py_.flatten_deep(plotter.bs_plot_data()['frequency'])))
     filelike = io.BytesIO()
     plotter.save_plot(filelike, ylim=ylim, img_format="png")
     image = Binary(filelike.getvalue())
     filelike.close()
     return dict(mp_id=mp_id, web_doc=web_doc, image=image)
Esempio n. 44
0
    def run_task(self, fw_spec):

        """
            Required Parameters:
                dir (str path): directory containing the vasp inputs
                jobs (VaspJob): Contains the cmd needed to run vasp
            Optional Parameters:
                custodian_params (dict **kwargs): Contains the job and the
                    scratch directory for a custodian run
                handlers (list of custodian handlers): Defaults to empty list
        """

        dec = MontyDecoder()
        dir = dec.process_decoded(self['dir'])
        cwd = dec.process_decoded(self['cwd'])

        # Change to the directory with the vasp inputs to run custodian
        os.chdir(cwd+dir)

        handlers = dec.process_decoded(self.get('handlers', []))
        jobs = dec.process_decoded(self['jobs'])
        max_errors = dec.process_decoded(self['max_errors'])

        fw_env = fw_spec.get("_fw_env", {})
        cust_params = self.get("custodian_params", {})

        # Get the scratch directory
        if fw_env.get('scratch_root'):
            cust_params['scratch_dir'] = os.path.expandvars(
                fw_env['scratch_root'])

        c = Custodian(handlers=handlers, jobs=jobs, max_errors=max_errors, gzipped_output=True, **cust_params)

        output = c.run()

        return FWAction(stored_data=output)
Esempio n. 45
0
 def process_decoded(self, d):
     """
     Recursive method to support decoding dicts and lists containing
     pymatgen objects.
     """
     if isinstance(d, dict) and "module" in d and "class" in d:
         modname = d["module"]
         classname = d["class"]
         mod = __import__(modname, globals(), locals(), [classname], 0)
         if hasattr(mod, classname):
             cls_ = getattr(mod, classname)
             data = {k: v for k, v in d.items() if k not in ["module", "class"]}
             if hasattr(cls_, "from_dict"):
                 return cls_.from_dict(data)
         return {self.process_decoded(k): self.process_decoded(v) for k, v in d.items()}
     return MontyDecoder.process_decoded(self, d)
 def from_dict(cls, dd):
     dec = MontyDecoder()
     return cls(mp_symbol=dd['mp_symbol'],
                name=dd['name'],
                alternative_names=dd['alternative_names'],
                IUPAC_symbol=dd['IUPAC_symbol'],
                IUCr_symbol=dd['IUCr_symbol'],
                coordination=dd['coordination'],
                central_site=dd['central_site'],
                points=dd['points'],
                solid_angles=(dd['solid_angles'] if 'solid_angles' in dd
                              else [4.0 * np.pi / dd['coordination']] * dd['coordination']),
                deactivate=dd['deactivate'],
                faces=dd['_faces'],
                edges=dd['_edges'],
                algorithms=[dec.process_decoded(algo_d)
                            for algo_d in dd['_algorithms']] if dd['_algorithms'] is not None else None,
                equivalent_indices=dd['equivalent_indices'] if 'equivalent_indices' in dd else None)
Esempio n. 47
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     reactants = [dec.process_decoded(e) for e in d["reactants"]]
     products = [dec.process_decoded(e) for e in d["products"]]
     return cls(reactants, products)
Esempio n. 48
0
    def test_msonable(self):

        compat_dict = self.aqcompat.as_dict()
        decoder = MontyDecoder()
        temp_compat = decoder.process_decoded(compat_dict)
        self.assertIsInstance(temp_compat,MITAqueousCompatibility)
Esempio n. 49
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls([dec.process_decoded(i) for i in d['items']])
Esempio n. 50
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     details = dec.process_decoded(d['details']) if 'details' in d else None
     return cls(event_type=d['event_type'], details=details)
Esempio n. 51
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(*dec.process_decoded(d['args']), **dec.process_decoded(d['kwargs']))
Esempio n. 52
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     kwargs = {k: dec.process_decoded(v) for k, v in d.items()
               if k in inspect.getargspec(cls.__init__).args}
     return cls(**kwargs)
Esempio n. 53
0
 def from_dict(cls, m_dict):
     m = MontyDecoder()
     return cls(handlers=m.process_decoded(m_dict['handlers']), validators=m.process_decoded(m_dict['validators'])
                , max_restarts=m_dict['max_restarts'])
Esempio n. 54
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(controllers=dec.process_decoded(d['controllers']))
Esempio n. 55
0
    def test_msonable(self):

        compat_dict = self.compat.as_dict()
        decoder = MontyDecoder()
        temp_compat = decoder.process_decoded(compat_dict)
        self.assertIsInstance(temp_compat,MaterialsProjectCompatibility)
Esempio n. 56
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     entries = dec.process_decoded(d["original_entries"])
     terminal_compositions = dec.process_decoded(d["terminal_compositions"])
     return cls(entries, terminal_compositions,
                d["normalize_terminal_compositions"])
Esempio n. 57
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(inverse_power=d['inverse_power'], weights_setup=dec.process_decoded(d['weights_setup']))
Esempio n. 58
0
 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(handler=dec.process_decoded(d['handler']), actions=d['actions'],
                event=dec.process_decoded(d['event']), reset=d['reset'])
Esempio n. 59
0
 def from_dict(cls, d):
     from monty.json import MontyDecoder
     dec = MontyDecoder()
     return cls(dec.process_decoded(d["entries"]),
                dec.process_decoded(d["working_ion_entry"]))