Devices with MacOS initially use ndbm type as database manager in dbm package which has much less capabilities than gdbm and undocumented limitations. In order to prevent errors connected with a calculations' database that may appear during usage of siman package, it is highly recommended to install gdbm (GNU database manager) from the start or reconstruct your database from ndbm using gdbm. To do this you need to repeat the following instructions:
- Install Homebrew (https://brew.sh)
Paste that in a macOS Terminal.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Using Homebrew install gdbm
brew install gdbm
- Install python using Homebrew
brew install python@X.XX
Where X.XX is a python version, checked with python@3.12.
- Install Python interface to gdbm
brew install python-gdbm@X.XX
Notice that version of installed python should be the same as its interface for gdbm
- Create a virtual environment to install siman and other packages using pip
pythonX.XX -m venv path/to/venv source path/to/venv/bin/activate pythonX.XX -m pip install xyz # where xyz is a package you want to install
At this step you can use siman and be calm about your data in db. If you need to copy data from the ndbm database to the new gdbm database then you need to complete the following steps:
- Write all keys you want to copy in a new db in one list
- Run the python script to extract data from db into pickles files
from siman.database import write_database, read_database from siman.header import db read_database() for key in keys: # where keys is a list with calculations' keys path = 'pickle/'+'.'.join(map(str, key)) db[key].serialize(path)
- Copy your db files ('only_calc.gdbm3' and 'calc.gdbm3') into another directory and delete in the main directory
- Run the script to transform your pickles files into new database
from pathlib import Path
from siman.calculators.vasp import CalculationVasp
from siman.database import write_database, read_database
from siman import header
from siman.header import db
read_database()
pickle_files = Path('pickle')
for file in pickle_files.iterdir():
# print(file, 'processing')
file_str = str(file)
if file_str == 'pickle/.DS_Store':
print('skip DS_Store')
else:
cl = CalculationVasp()
cl = cl.deserialize(file)
filename = file_str.split('/')[-1]
# print(filename, 'ok')
filename_without_extension = filename.rsplit('.', 1)[0]
main_part, numeric_part = filename_without_extension.rsplit('.', 1)
numeric_value = int(numeric_part)
first_part, second_part = main_part.rsplit('.', 1)
key = (first_part, second_part, numeric_value)
if cl.id[1] == '0':
cl.path["output"] = cl.id[0]
cl.id = (first_part, second_part, numeric_value)
db[key] = cl
print(key, "ready")
write_database()
- Enjoy siman and db as it was designed