iprPy.database package

Module contents

class RunManager(database, run_directory, orphan_directory=None, hold_directory=None, log=True)

Bases: object

Manages the execution of iprPy calculations

property calclist

The current list of calculation names in the run directory.

Type:

list

property database

The records database for the calculations to interact with.

Type:

iprPy.Database

property hold_directory

The directory where calculations are sent if uploading to the database fails.

Type:

pathlib.Path

property logfilename

The name/path of the log file the runner saves info to.

Type:

pathlib.Path

property orphan_directory

The directory where calculations missing .py or .in files, or database records are sent.

Type:

pathlib.Path

property pid

The processor id for the runner.

Type:

str

run(calc_name, temp=False, temp_directory=None, bidverbose=False)

Runs one calculation from the run_directory.

Parameters:
  • calc_name (str) – The name of the calculation in run_directory to run.

  • use_temp (bool, optional) – If True, a new temporary directory will be created and used for this run.

  • temp_directory (path-like object, optional) – The path to an existing temporary directory where the calculations are to be performed.

  • bidverbose (bool, optional) – If True, info about the calculation bidding process will be printed. Default value is False.

Returns:

status – The status of the calculation after calling run.

Return type:

str

property run_directory

The path to the run_directory containing the calculation folders.

Type:

pathlib.Path

runall(bidtries=10, temp=False, temp_directory=None, bidverbose=False)

Sequentially runs calculations within the run_directory until all are finished.

Parameters:
  • bidtries (int, optional) – The runner will stop if it fails on bidding this many times in a row. This allows for the cleanup of excess competing runners. Default value is 10.

  • temp (bool, optional) – If True, a new temporary directory will be created and used for this run.

  • temp_directory (path-like object, optional) – The path to an existing temporary directory where the calculations are to be performed.

  • bidverbose (bool, optional) – If True, info about the calculation bidding process will be printed. Default value is False.

load_database(name=None, style=None, host=None, **kwargs)

Loads a database object. Can be either loaded from stored settings or by defining all needed access information.

Parameters:
  • name (str, optional) – The name assigned to a pre-defined database. If given, can be the only parameter.

  • style (str, optional) – The database style to use.

  • host (str, optional) – The URL/file path where the database is hosted.

  • kwargs (dict, optional) – Any other keyword parameters defining necessary access information. Allowed keywords are database style-specific.

Returns:

The database object.

Return type:

Subclass of yabadaba.Database

master_prepare(database, input_script=None, debug=False, **kwargs)

Prepares one or more calculations according to the workflows used by the NIST Interatomic Potentials Repository.

Parameters:
  • database (iprPy.database.Database) – The database that will host the records for the prepared calculations.

  • input_script (str or file-like object, optional) – The file, path to file, or contents of an input script containing parameters for preparing the calculation.

  • debug (bool) – If set to True, will throw errors associated with failed/invalid calculation builds. Default is False.

  • **kwargs (str or list) – Allows for input parameters for preparing the calculation to be directly specified. Any kwargs parameters that have names matching input_script parameters will overwrite the input_script values. Values must be strings or list of strings if allowed by the calculation for the particular parameter.

prepare(database, run_directory, calculation, input_script=None, debug=False, **kwargs)

Function for preparing any iprPy calculation for high-throughput execution. Input parameters for preparing can either be given within an input script or by passing in keyword parameters.

Parameters:
  • database (iprPy.database.Database) – The database that will host the records for the prepared calculations.

  • run_directory (str) – The path or name for the run_directory where the prepared calculations are to be placed.

  • calculation (iprPy.calculation.Calculation or str) – The calculation style or an instance of the calculation style to prepare.

  • input_script (str or file-like object, optional) – The file, path to file, or contents of an input script containing parameters for preparing the calculation.

  • debug (bool) – If set to True, will throw errors associated with failed/invalid calculation builds. Default is False.

  • **kwargs (str or list) – Allows for input parameters for preparing the calculation to be directly specified. Any kwargs parameters that have names matching input_script parameters will overwrite the input_script values. Values must be strings or list of strings if allowed by the calculation for the particular parameter.

reset_orphans(run_directory, orphan_directory=None)

Resets calculations that were moved to an orphan directory back to a run directory and removes any bid files that they contain. Can be useful if connection is lost to a remote database or a runner was accidentally started with the wrong database.

Parameters:
  • run_directory (str) – The directory to move the orphaned calculations to.

  • orphan_directory (str, optional) – The orphan directory containing archived calculation folders. The default value assumes that the orphan directory is a directory named “orphan” that is in the same parent directory as run_directory, i.e. is at “../orphan” relative to run_directory.

runner(database, run_directory, calc_name=None, orphan_directory=None, hold_directory=None, log=True, bidtries=10, bidverbose=False, temp=False, temp_directory=None)

High-throughput calculation runner.

Parameters:
  • database (iprPy.Database) – The database to interact with.

  • run_directory (path-like object or str) – The run_directory name or path to the directory where the calculations to run are located.

  • calc_name (str, optional) – The name of a specific calculation to run. If not given, all calculations in run_directory will be performed one at a time.

  • orphan_directory (path-like object, optional) – The path for the orphan directory where incomplete calculations are moved. If None (default) then will use ‘orphan’ at the same level as the run_directory.

  • hold_directory (str, optional) – The path for the hold directory where tar archives that failed to be uploaded are moved to. If None (default) then will use ‘hold’ at the same level as the run_directory.

  • log (bool, optional) – If True (default), the runner will create and save a log file detailing the status of each calculation that it runs.

  • bidtries (int, optional) – The runner will stop if it fails on bidding this many times in a row. This allows for the cleanup of excess competing runners. Default value is 10.

  • bidverbose (bool, optional) – If True, info about the calculation bidding process will be printed. Default value is False.

  • temp (bool, optional) – If True, a temporary directory will be automatically created and used for this run.

  • temp_directory (path-like object, optional) – The path to an existing temporary directory where the calculations are to be copied to and executed there instead of in the run_directory.