Skip to content

Commit

Permalink
Fix some bugs (#14)
Browse files Browse the repository at this point in the history
* collection.update is removed in PyMongo 4+

collection.update is removed
https://pymongo.readthedocs.io/en/stable/migrate-to-pymongo4.html#collection-update-is-removed

* Update setup.py

The files in dfttk/analysis/database is required. It should included into package_data
  • Loading branch information
hitliaomq authored Jul 18, 2022
1 parent 89223ee commit 8d8aff0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions dfttk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ def mark_adopted_TF(tag, db_file, adpoted, phonon=False):
t_file = loadfn(config_to_dict()["FWORKER_LOC"])["env"]["db_file"]
vasp_db = VaspCalcDb.from_db_file(t_file, admin=True)
if vasp_db:
vasp_db.collection.update({'metadata.tag': tag}, {'$set': {'adopted': adpoted}}, upsert = True, multi = True)
vasp_db.collection.update_many({'metadata.tag': tag}, {'$set': {'adopted': adpoted}}, upsert = True)
if phonon:
vasp_db.db['phonon'].update({'metadata.tag': tag}, {'$set': {'adopted': adpoted}}, upsert = True, multi = True)
vasp_db.db['phonon'].update_many({'metadata.tag': tag}, {'$set': {'adopted': adpoted}}, upsert = True)


def mark_adopted(tag, db_file, volumes, phonon=False):
Expand All @@ -533,11 +533,11 @@ def mark_adopted(tag, db_file, volumes, phonon=False):
t_file = loadfn(config_to_dict()["FWORKER_LOC"])["env"]["db_file"]
vasp_db = VaspCalcDb.from_db_file(t_file, admin=True)
for volume in volumes:
vasp_db.collection.update({'$and':[ {'metadata.tag': tag}, {'output.structure.lattice.volume': volume} ]},
{'$set': {'adopted': True}}, upsert = True, multi = False) # Mark only one
vasp_db.collection.update_one({'$and':[ {'metadata.tag': tag}, {'output.structure.lattice.volume': volume} ]},
{'$set': {'adopted': True}}, upsert = True) # Mark only one
if phonon:
vasp_db.db['phonon'].update({'$and':[ {'metadata.tag': tag}, {'volume': volume} ]},
{'$set': {'adopted': True}}, upsert = True, multi = False)
vasp_db.db['phonon'].update_one({'$and':[ {'metadata.tag': tag}, {'volume': volume} ]},
{'$set': {'adopted': True}}, upsert = True)


def consistent_check_db(db_file, tag):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def readme():
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]},
package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"],
'dfttk.analysis' : ['database/*']},
description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab',
long_description=readme(),
install_requires=['atomate>=0.9.4', 'tinydb', 'phonopy', 'ase', 'pymatgen', 'numpy>=1.20.1'],
Expand Down

0 comments on commit 8d8aff0

Please sign in to comment.