rxn_network.utils#

rxn_network.utils.funcs#

Utility functions used throughout the reaction-network package.

rxn_network.utils.funcs.limited_powerset(iterable, max_size)[source]#

Helper method for generating subsets ranging from singular length to maximum length specified by max_size.

Parameters:
  • iterable (Iterable) – all objects to consider.

  • max_size (int) – upper limit for size of combination subsets.

Returns:

All combination sets up to maximum size

Return type:

Iterable

rxn_network.utils.funcs.grouper(iterable, n, fillvalue=None)[source]#

Collects data into fixed-length chunks or blocks.

Parameters:
  • iterable (Iterable) – An iterable object to group.

  • n (int) – The number of items to include in each group.

  • fillvalue (Any) – The value to use for the last group, if the length of the group is less than n.

Return type:

Iterable

rxn_network.utils.funcs.get_project_root()[source]#

Gets a Path object for the reaction-network project root directory.

Note

This is specific to this file and project.

Returns:

Path object for the project root directory.

Return type:

Path

rxn_network.utils.funcs.get_logger(name, level=10, log_format='%(asctime)s %(levelname)s %(name)s %(message)s', stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]#

Code borrowed from the atomate package.

Helper method for acquiring logger.

Parameters:

name (str) –

rxn_network.utils.funcs.datetime_str()[source]#

Get a string representation of the current time. Borrowed from atomate2 package.

Return type:

str

rxn_network.utils.ray#

Functions for working with Ray (parallelization library).

rxn_network.utils.ray.initialize_ray(quiet=False)[source]#

Simple function to initialize ray. Basic support for running ray on multiple nodes. Currently supports SLURM and PBS job schedulers.

SLURM:

Checks enviornment for existence of “ip_head” for situations where the user is running on multiple nodes. Automatically creats a new ray cluster if it has not been initialized. See https://github.com/NERSC/slurm-ray-cluster/

PBS:

Checks environment for PBS_NNODES > 1.

Parameters:

quiet (bool) –

rxn_network.utils.ray.to_iterator(obj_ids, get_obj_ids=False)[source]#

Method to convert a list of ray object ids to an iterator that can be used in a for loop.

Parameters:

get_obj_ids (bool) –