Utils

General purpose utilities

Functions

gefest.core.utils.functions.project_root() Path[source]

Returns project root folder.

gefest.core.utils.functions.parse_structs(path: str) list[Structure][source]

Generates list of structures from file with dicts.

Parameters:

path (str) – Path to file contains Structure object dumps, splitted with new line.

Returns:

Serialized population.

Return type:

list[Structure]

gefest.core.utils.functions.where(sequence: list[Any], mask_rule: Callable[[Callable], bool]) list[int][source]

Finds indexes of values in a sequence satisfying the mask_rule.

Parameters:
  • sequence (list[Any]) – list of values

  • mask_rule (Callable[[Callable], bool]) – rule for selecting values (e.g. lambda val: val is not None)

Returns:

List of indexes of elements satisfying the condition.

Return type:

list[int]

Logger

class gefest.core.utils.logger.LogDispatcher(log_dir: str = 'logs', run_name='new_run')[source]

Bases: object

Makes some logging stuff.

log_pop(pop: list[Structure], step: str)[source]

Saves provided population to json.

Parallel execution

class gefest.core.utils.parallel_manager.BaseParallelDispatcher(n_jobs: int = -1)[source]

Bases: object

Provides api for easy to use parallel execution with joblib backernd.

exec_parallel(func: Callable, arguments: list[tuple[Any]], use: bool = True, flatten: bool = True) list[Any][source]

Executes provided function in parallel.

Parameters:
  • func (Callable) – Function to execute.

  • arguments (list[tuple[Any]]) – Each tuple in list is *args for separate func call.

  • use (bool, optional) – If True, each arg in args will be used as func argument, otherwise func will be called without arguments len(args) times. Defaults to True.

  • flatten (bool) – If true, makes flatten list from function ouput lists.

Returns:

list[Any]