Warning: This document is for an old version of Pydra: A simple dataflow engine with scalable semantics. The main version is master.

pydra.utils.messenger module

Messaging of states.

class pydra.utils.messenger.AuditFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Flag

Auditing flags.

ALL = 3

Track provenance and resource utilization.

NONE = 0

Do not track provenance or monitor resources.

PROV = 1

Track provenance only.

RESOURCE = 2

Monitor resource utilization only.

class pydra.utils.messenger.FileMessenger

Bases: Messenger

A messenger that redirects to a file.

send(message, append=True, **kwargs)

Append message to file.

Parameters:
  • message (dict) – The message to be printed.

  • append (bool) – Do not truncate file when opening (i.e. append to it).

Returns:

Returns the unique identifier used in the file’s name.

Return type:

str

class pydra.utils.messenger.Messenger

Bases: object

Base messenger class.

abstract send(message, **kwargs)

Send a message.

class pydra.utils.messenger.PrintMessenger

Bases: Messenger

A messenger that redirects to standard output.

send(message, **kwargs)

Send the message to standard output.

Parameters:

message (dict) – The message to be printed.

class pydra.utils.messenger.RemoteRESTMessenger

Bases: Messenger

A messenger that redirects to remote REST endpoint.

send(message, **kwargs)

Append message to file.

Parameters:

message (dict) – The message to be printed.

Returns:

The status code from the request.post

Return type:

int

class pydra.utils.messenger.RuntimeHooks(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

Allowed points to hook into the process.

resource_monitor_post_stop = 4
resource_monitor_pre_start = 3
task_execute_post_exit = 6
task_execute_pre_entry = 5
task_run_entry = 1
task_run_exit = 2
pydra.utils.messenger.collect_messages(collected_path, message_path, ld_op='compact')

Compile all messages into a single provenance graph.

Parameters:
  • collected_path (os.pathlike) – A place to write all of the collected messages. (?TODO)

  • message_path (os.pathlike) – A path with the message file (?TODO)

  • ld_op (str, optional) – Option used by pld.jsonld

pydra.utils.messenger.gen_uuid()

Generate a unique identifier.

pydra.utils.messenger.make_message(obj, context=None)

Build a message using the specific context

Parameters:
  • obj (dict) – A dictionary containing the non-context information of a message record.

  • context (dict, optional) – Dictionary with the link to the context file or containing a JSON-LD context.

Returns:

The message with the context.

Return type:

dict

pydra.utils.messenger.now()

Get a formatted timestamp.

pydra.utils.messenger.send_message(message, messengers=None, **kwargs)

Send NIDM messages for logging provenance and auditing.