materialsvirtuallab / megnet

Graph Networks as a Universal Machine Learning Framework for Molecules and Crystals
BSD 3-Clause "New" or "Revised" License
501 stars 155 forks source link

Error: converter or convertor and include_site #17

Closed ckae95 closed 5 years ago

ckae95 commented 5 years ago

When I run the test_models.py script, I get a "TypeError: init() got an unexpected keyword argument 'bond_converter'", which can be fixed by changing "converter" to "convertor".

However, then I get another error further down, namely: RuntimeError: get_all_neighbors() got an unexpected keyword argument 'include_site'. The same happens by the way when I run the crystal_example notebook.

Thanks for your help.

chc273 commented 5 years ago

hi @ckae95

Could you update to the latest megnet and pymatgen on github and see what happens?

These problems seem to be a version issue.

ckae95 commented 5 years ago

Thanks. Updating pymatgen helped. But in the crystal_example notebook I now get a new error related to pymatgen:


MPRestError Traceback (most recent call last) ~/.local/lib/python3.6/site-packages/pymatgen/ext/matproj.py in _make_request(self, sub_url, payload, method, mp_decode) 170 raise MPRestError("REST query returned with error status code {}" --> 171 .format(response.status_code)) 172

MPRestError: REST query returned with error status code 403

During handling of the above exception, another exception occurred:

MPRestError Traceback (most recent call last)

in () 3 4 # let's get some structure ----> 5 structure = mpr.get_structure_by_material_id('mp-1142') ~/.local/lib/python3.6/site-packages/pymatgen/ext/matproj.py in get_structure_by_material_id(self, material_id, final, conventional_unit_cell) 539 """ 540 prop = "final_structure" if final else "initial_structure" --> 541 data = self.get_data(material_id, prop=prop) 542 if conventional_unit_cell: 543 data[0][prop] = SpacegroupAnalyzer(data[0][prop]). \ ~/.local/lib/python3.6/site-packages/pymatgen/ext/matproj.py in get_data(self, chemsys_formula_id, data_type, prop) 227 if prop: 228 sub_url += "/" + prop --> 229 return self._make_request(sub_url) 230 231 def get_materials_ids(self, chemsys_formula): ~/.local/lib/python3.6/site-packages/pymatgen/ext/matproj.py in _make_request(self, sub_url, payload, method, mp_decode) 174 msg = "{}. Content: {}".format(str(ex), response.content) \ 175 if hasattr(response, "content") else str(ex) --> 176 raise MPRestError(msg) 177 178 def get_materials_id_from_task_id(self, task_id): MPRestError: REST query returned with error status code 403. Content: b'{"valid_response": false, "error": "API_KEY is not supplied.", "version": {"db": "2019.05", "pymatgen": "2019.7.2", "rest": "2.0"}, "created_at": "2019-07-21T18:01:02.035913"}'
shyuep commented 5 years ago

As the error message implies, you need to set your Materials Project API key to get structures from MP. Pls look at the pymatgen documentation on how to set the API key.

ckae95 commented 5 years ago

Thanks. But still: in the transfer_learning notebook: When I try to run

model_form = MEGNetModel.from_file('../mvl_models/mp-2019.4.1/formation_energy.hdf5')

I still get an error: TypeError: init() got an unexpected keyword argument 'atom_converter'

chc273 commented 5 years ago

@ckae95 This error is caused by the older API and has been fixed (convertor to converter in all names). Again, please update to the latest megnet version and model files (the one in github, not pypi) and set the correct path for the model hdf5. It should work.

PS: Just updated the correct path for the model. It should be model_form = MEGNetModel.from_file('../mvl_models/mp-2018.6.1/formation_energy.hdf5').