Utilities#

class autode.utils.NumericStringDict(string: str, delim: str = ' = ')#
class autode.utils.StringDict(string: str, delim: str = ' = ')#
Immutable dictionary stored as a single string. For example::

‘a = b c = d’

__init__(string: str, delim: str = ' = ')#
get(item: str, default: Any) Any#

Get an item or return a default

autode.utils.check_sufficient_memory(func: Callable)#

Decorator to check that enough memory is available for a calculation

autode.utils.checkpoint_rxn_profile_step(name: str) Callable#

Decorator for a function that will save a checkpoint file with the reaction state at that point in time. If the checkpoint exists then the state will be reloaded and the execution skipped

autode.utils.cleanup_after_timeout()#
autode.utils.deprecated(func: Callable) Callable#
autode.utils.get_total_memory() int#

Returns total amount of physical memory available in bytes

autode.utils.hashable(_method_name: str, _object: Any)#

Multiprocessing requires hashable top-level functions to be executed, so convert a method into a top-level function

autode.utils.log_time(prefix: str = 'Executed in: ', units: str = 'ms') Callable#

A function requiring a number of atoms to run

autode.utils.no_exceptions(func) Any#

Calculation method requiring the output filename to be set

autode.utils.requires_atoms(func: Callable) Callable#

A function requiring a number of atoms to run

autode.utils.requires_conformers(func: Callable) Callable#

A function requiring the species to have a list of conformers

autode.utils.requires_graph(func: Callable) Callable#

A function requiring a number of atoms to run

autode.utils.requires_hl_level_methods(func: Callable) Callable#

A function requiring both high and low-level methods to be available

autode.utils.requires_output(func: Callable) Callable#

A function requiring an output file and output file lines

autode.utils.requires_output_to_exist(func: Callable) Callable#

Calculation method requiring the output filename to be set

autode.utils.run_external(params: List[str], output_filename: str, stderr_to_log: bool = True)#

Standard method to run a EST calculation with subprocess writing the output to the calculation output filename

Parameters:

stderr_to_log – Should the stderr be added to the logged warnings?

autode.utils.run_external_monitored(params: Sequence[str], output_filename: str, break_word: str = 'MPI_ABORT', break_words: List[str] | None = None)#

Run an external process monitoring the standard output and error for a word that will terminate the process

Parameters:
  • output_filename (str) –

  • break_word (str) – String that if found will terminate the process

  • break_words (list(str) | None) – List of break_word-s

autode.utils.run_in_tmp_environment(**kwargs) Callable#

Apply a set of environment variables, execute a function and reset them

autode.utils.temporary_config()#

Context manager to temporarily change autodE’s Config. When it exits, the Config will be restored to whatever it was before calling the context manager.

Example usage:


>>> import autode as ade
>>> from autode import Config
>>> Config.hcode = 'ORCA'
>>> with ade.temporary_config():
...     # change some config vars
...     Config.n_cores = 16
...     Config.ORCA.keywords.sp.functional = 'B3LYP'
...     # then do some calculations
...     # ------
>>> # When context manager returns, Config should be restored to what it was before
>>> assert Config.n_cores == 4
>>> assert str(Config.ORCA.keywords.sp.functional).lower() == 'pbe0'
autode.utils.timeout(seconds: float, return_value: Any | None = None) Any#

Function decorator that times-out after a number of seconds (default version, uses forking)

Parameters:
  • seconds – The number of seconds to timeout

  • return_value – Value returned if the function times out

Returns:

result of function | return_value

Return type:

(Any)

autode.utils.work_in(dir_ext: str) Callable#

Execute a function in a different directory

autode.utils.work_in_tmp_dir(filenames_to_copy: Sequence[str] | None = None, kept_file_exts: Sequence[str] | None = None, use_ll_tmp: bool = False) Callable#

Execute a function in a temporary directory.

Parameters:

use_ll_tmp (bool) – If true then use autode.config.Config.ll_tmp_dir