pymatgen.apps.borg.queen module

class BorgQueen(drone, rootpath=None, number_of_drones=1)[source]

Bases: object

The Borg Queen controls the drones to assimilate data in an entire directory tree. Uses multiprocessing to speed up things considerably. It also contains convenience methods to save and load data between sessions.

Parameters:
  • drone (Drone) – An implementation of pymatgen.apps.borg.hive.AbstractDrone to use for assimilation.
  • rootpath (str) – The root directory to start assimilation. Leave it as None if you want to do assimilation later, or is using the BorgQueen to load previously assimilated data.
  • ndrones (int) – Number of drones to parallelize over. Typical machines today have up to four processors. Note that you won’t see a 100% improvement with two drones over one, but you will definitely see a significant speedup of at least 50% or so. If you are running this over a server with far more processors, the speedup will be even greater.
get_data()[source]

Returns an list of assimilated objects

load_data(filename)[source]

Load assimilated data from a file

parallel_assimilate(rootpath)[source]

Assimilate the entire subdirectory structure in rootpath.

save_data(filename)[source]

Save the assimilated data to a file.

Parameters:filename (str) – filename to save the assimilated data to. Note that if the filename ends with gz or bz2, the relevant gzip or bz2 compression will be applied.
serial_assimilate(rootpath)[source]

Assimilate the entire subdirectory structure in rootpath serially.

order_assimilation(args)[source]

Internal helper method for BorgQueen to process assimilation