hackingmaterials / atomate

atomate is a powerful software for computational materials science and contains pre-built workflows.
https://hackingmaterials.github.io/atomate
Other
244 stars 175 forks source link

get_settings error when using any builder #206

Closed ardunn closed 6 years ago

ardunn commented 6 years ago

System

Summary

Example code

from atomate.vasp.builders.fix_tasks import FixTasksBuilder
DB_FILE = "/Users/me/path/to/db.json"
fix = FixTasksBuilder.from_file(DB_FILE)

Error message

Traceback (most recent call last):
  File "/Users/ardunn/alex/lbl/projects/thermoelectrics/code/thermoelectrics_work/thermoelectrics_work/build_te_database.py", line 28, in <module>
    fix = FixTasksBuilder.from_file(DB_FILE)
  File "/Users/ardunn/alex/lbl/projects/common_env/common_env/lib/python2.7/site-packages/atomate/vasp/builders/fix_tasks.py", line 72, in from_file
    db_write = get_database(db_file, admin=True)
  File "/Users/ardunn/alex/lbl/projects/common_env/common_env/lib/python2.7/site-packages/atomate/utils/utils.py", line 338, in get_database
    d = get_settings(config_file) if settings is None else settings
NameError: global name 'get_settings' is not defined

Suggested solution (if any)

albalu commented 6 years ago

Yes I am not sure where this get_setting should come from pycharm finds 3 different sources for it including matgendb.dbconfig is that the correct address? Also seems like MongoClient needs to be imported which is minor. What about _log? My guess is that get_database was moved to atomate.atomate.utils.utils recently but these functions are not imported?

computron commented 6 years ago

@shyamd is this related to your refactoring to take out matgendb?

I presume it is an accident that it happens to break the competing builders technology? lol

shyamd commented 6 years ago

Yeah, total accident. I thought I had the imports properly ported since the tests were all working out. Should be a simple fix.

These lines need to be copied over to atomate.atomate.utils.utils: https://github.com/materialsproject/pymatgen-db/blob/master/matgendb/dbconfig.py#L136-L213 Or we could just refactor in pymatgen-db as a dependency. There was just a long period of time in which pymatgen-db imports were causing conflicts so I thought it would be easier to just not rely on it since we don't rely the base query engine or vasp drone.

shyuep commented 6 years ago

Erm, I am confused. Why are pymatgen-db causing conflicts on imports?

shyamd commented 6 years ago

It was when the changes were made. Question for @computron: Shall I re-factor pymatgen-db as a dependency again or leave it out?

computron commented 6 years ago

I think the get_settings() function usage in that atomate function is not doing much? is it functioning the same as a json.load()?

Also there is a line that says _log.warn( which is going to be an error since _log was never defined. And there is no docstring for that function. Sorry to say but that function is a train wreck...

computron commented 6 years ago

(and Alireza's comment about MongoClient needing to be imported)

I suggest that people start using an IDE. It will put angry red underlines to prevent these kinds of errors.

shyamd commented 6 years ago

this should be fixed. Any update?

computron commented 6 years ago

@ardunn please check and close issue if fixed

ardunn commented 6 years ago

Yes this is fixed.