fluidimage.executors.base#

Base class for executors#

class fluidimage.executors.base.ExecutorBase(topology, path_dir_result, nb_max_workers=None, nb_items_queue_max=None, logging_level='info', sleep_time=None, stop_if_error=False, path_log=None)[source]#

Bases: ABC

Base class for executors.

Parameters:
topologyfluidimage.topology.base.TopologyBase

A computational topology.

path_dir_resultstr or pathlib.Path

The path of the directory where the results have to be saved.

nb_max_workersint, optional (None)
nb_items_queue_maxint, optional (None),
logging_levelstr, optional {“info”},
sleep_timenumber, optional {None},
stop_if_errorbool, optional {False}
log_in_file(*args, sep=' ', end='\n')[source]#

Simple write in the log file (without print)

log_in_file_memory_usage(txt, color='OKGREEN', end='\n')[source]#

Write the memory usage in the log file

exec_one_shot_works()[source]#

Execute all “one shot” functions.

log_exception(exception, work_name, key)[source]#

Log an exception in a file.

class fluidimage.executors.base.MultiExecutorBase(topology, path_dir_result, nb_max_workers=None, nb_items_queue_max=None, sleep_time=0.01, logging_level='info', stop_if_error=False)[source]#

Bases: ExecutorBase

Manage the multi-executor mode

This class is not the one whose really compute the topology. The topology is split and each slice is computed with an ExecutorAsync

Parameters:
nb_max_workersNone, int

Limits the numbers of workers working in the same time.

nb_items_queue_maxNone, int

Limits the numbers of items that can be in a output_queue.

sleep_timeNone, float

Defines the waiting time (from trio.sleep) of a function. Async functions await trio.sleep(sleep_time) when they have done a work on an item, and when there is nothing in their input_queue.

abstract _start_processes()[source]#

Start the processes doing the hard work

compute()[source]#

Compute the topology.

_join_processes()[source]#

Join the processes

Classes

ExecutorBase(topology, path_dir_result[, ...])

Base class for executors.

MultiExecutorBase(topology, path_dir_result)

Manage the multi-executor mode