message_passing

class aitoolbox.torchtrain.train_loop.components.message_passing.MessageHandling(value)[source]

Bases: Enum

An enumeration.

KEEP_FOREVER = 'keep_forever'
UNTIL_END_OF_EPOCH = 'until_end_of_epoch'
UNTIL_READ = 'until_read'
OVERWRITE = 'overwrite'
class aitoolbox.torchtrain.train_loop.components.message_passing.Message(key, value, msg_handling_settings)[source]

Bases: object

Wrapper object to represent the messages in the MessageService together with their handling settings

Parameters:
class aitoolbox.torchtrain.train_loop.components.message_passing.MessageService[source]

Bases: object

Message Passing Service

Primarily intended for passing the messages in the TrainLoop, especially for communication or data sharing between different callbacks.

read_messages(key)[source]

Read messages by key from the TrainLoop message service

Parameters:

key (str) – message key

Returns:

if message key present return content, otherwise return None

Return type:

list or None

write_message(key, value, msg_handling_settings=MessageHandling.UNTIL_END_OF_EPOCH)[source]

Write a new message to the message service

Parameters:
  • key (str) – message key

  • value – message content

  • msg_handling_settings (MessageHandling or list[MessageHandling]) –

    setting how to handle the lifespan of the message. Can use one of the following message lifecycle handling settings which are variables imported from this script file and can be found defined at the beginning of the script:

    • KEEP_FOREVER

    • UNTIL_END_OF_EPOCH

    • UNTIL_READ

    • OVERWRITE

Returns:

None

end_of_epoch_trigger()[source]

Purging of the message service at the end of the epoch

Normally executed by the TrainLoop automatically after all the callbacks were executed at the end of every epoch

Returns:

None

static validate_msg_handling_settings(msg_handling_settings)[source]