Monitor

class mosaic.runtime.monitor.Monitor(**kwargs)[source]

Bases: Runtime

The monitor takes care of keeping track of the state of the network and collects statistics about it.

It also handles the allocation of tesserae to certain workers.

add_task_event(sender_id, msgs)[source]
add_task_profile(sender_id, msgs)[source]
add_tessera_event(sender_id, msgs)[source]
add_tessera_profile(sender_id, msgs)[source]
append_description()[source]
async barrier(sender_id, timeout=None)[source]

Wait until all pending tasks are done. If no timeout is provided, the barrier will wait indefinitely.

Parameters:

timeout (float, optional)

async init(**kwargs)[source]

Asynchronous counterpart of __init__.

Parameters:

kwargs

async init_cluster(**kwargs)[source]

Init nodes in cluster mode.

Parameters:

kwargs

init_file(runtime_config)[source]
async init_local(**kwargs)[source]

Init nodes in local mode.

Parameters:

kwargs

is_monitor = True
async select_worker(sender_id)[source]

Select appropriate worker to allocate a tessera.

Parameters:

sender_id (str)

Returns:

UID of selected worker.

Return type:

str

set_logger()[source]

Set up logging.

set_profiler()[source]

Set up profiling.

async stop(sender_id=None)[source]

Stop runtime.

Parameters:

sender_id (str)

update_node(sender_id, update, sub_resources)[source]

Strategies

class mosaic.runtime.strategies.MonitorStrategy(monitor)[source]

Bases: object

Base class for the strategies used to allocate tesserae to workers.

select_worker(sender_id)[source]

Select an appropriate worker.

Parameters:

sender_id (str)

update_node(updated)[source]

Update inner record of node state.

Parameters:

updated (MonitoredNode)

update_task(updated)[source]

Update inner record of task state.

Parameters:

updated (MonitoredTask)

update_tessera(updated)[source]

Update inner record of tesserae state.

Parameters:

updated (MonitoredTessera)

class mosaic.runtime.strategies.RoundRobin(monitor)[source]

Bases: MonitorStrategy

Round robin strategy for allocating tesserae.

select_worker(sender_id)[source]

Select an appropriate worker.

Parameters:

sender_id (str)

update_node(updated)[source]

Update inner record of node state.

Parameters:

updated (MonitoredNode)