pydra.utils.messenger module

Messaging of states.

class pydra.utils.messenger.AuditFlag(value)[source]

Bases: Flag

Auditing flags.

ALL = 3[source]

Track provenance and resource utilization.

NONE = 0[source]

Do not track provenance or monitor resources.

PROV = 1[source]

Track provenance only.

RESOURCE = 2[source]

Monitor resource utilization only.

class pydra.utils.messenger.FileMessenger[source]

Bases: Messenger

A messenger that redirects to a file.

send(message, append=True, **kwargs)[source]

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[source]

Bases: object

Base messenger class.

abstract send(message, **kwargs)[source]

Send a message.

class pydra.utils.messenger.PrintMessenger[source]

Bases: Messenger

A messenger that redirects to standard output.

send(message, **kwargs)[source]

Send the message to standard output.

Parameters:

message (dict) – The message to be printed.

class pydra.utils.messenger.RemoteRESTMessenger[source]

Bases: Messenger

A messenger that redirects to remote REST endpoint.

send(message, **kwargs)[source]

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)[source]

Bases: IntEnum

Allowed points to hook into the process.

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

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()[source]

Generate a unique identifier.

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

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()[source]

Get a formatted timestamp.

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

Send NIDM messages for logging provenance and auditing.