Skip to content

Commit 5005173

Browse files
authored
Merge pull request #316 from djarecka/doc_upd
[doc] updating the docstrings for messenger and audit
2 parents 07b20bf + de31d25 commit 5005173

File tree

2 files changed

+55
-15
lines changed

2 files changed

+55
-15
lines changed

pydra/engine/audit.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ def __init__(self, audit_flags, messengers, messenger_args, develop=None):
1818
----------
1919
audit_flags : :class:`AuditFlag`
2020
Base configuration of auditing.
21-
messengers :
22-
TODO
23-
messenger_args :
24-
TODO
25-
develop :
26-
TODO
21+
messengers : :obj:`pydra.util.messenger.Messenger` or list of :class:`pydra.util.messenger.Messenger`, optional
22+
Specify types of messenger used by Audit to send a message.
23+
Could be `PrintMessenger`, `FileMessenger`, or `RemoteRESTMessenger`.
24+
messenger_args : :obj:`dict`, optional
25+
Optional arguments for the `Messenger.send` method.
26+
develop : :obj:`bool`, optional
27+
If True, the local context.jsonld file is used, otherwise the one from github is used.
2728
2829
"""
2930
self.audit_flags = audit_flags
@@ -115,10 +116,10 @@ def audit_message(self, message, flags=None):
115116
116117
Parameters
117118
----------
118-
message :
119-
TODO
120-
flags :
121-
TODO
119+
message : :obj:`dict`
120+
A message in Pydra is a JSON-LD message object.
121+
flags : :obj:`bool`, optional
122+
If True and self.audit_flag, the message is sent.
122123
123124
"""
124125
if self.develop:
@@ -149,8 +150,12 @@ def audit_check(self, flag):
149150
150151
Parameters
151152
----------
152-
flag :
153-
TODO
153+
flag : :obj: `bool`
154+
The flag that is checked.
154155
156+
Returns
157+
-------
158+
bool
159+
Boolean AND for self.oudit_flags and flag
155160
"""
156161
return self.audit_flags & flag

pydra/utils/messenger.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PrintMessenger(Messenger):
5656

5757
def send(self, message, **kwargs):
5858
"""
59-
Send to standard output.
59+
Send the message to standard output.
6060
6161
Parameters
6262
----------
@@ -88,6 +88,10 @@ def send(self, message, append=True, **kwargs):
8888
append : :obj:`bool`
8989
Do not truncate file when opening (i.e. append to it).
9090
91+
Returns
92+
-------
93+
str
94+
Returns the unique identifier used in the file's name.
9195
"""
9296
import json
9397

@@ -114,6 +118,11 @@ def send(self, message, **kwargs):
114118
message : :obj:`dict`
115119
The message to be printed.
116120
121+
Returns
122+
-------
123+
int
124+
The status code from the `request.post`
125+
117126
"""
118127
import requests
119128

@@ -134,7 +143,21 @@ def send_message(message, messengers=None, **kwargs):
134143

135144

136145
def make_message(obj, context=None):
137-
"""Build a message."""
146+
"""
147+
Build a message using the specific context
148+
149+
Parameters
150+
----------
151+
obj : :obj:`dict`
152+
A dictionary containing the non-context information of a message record.
153+
context : :obj:`dict`, optional
154+
Dictionary with the link to the context file or containing a JSON-LD context.
155+
156+
Returns
157+
-------
158+
dict
159+
The message with the context.
160+
"""
138161
if context is None:
139162
context = {
140163
"@context": "https://raw.githubusercontent.com/nipype/pydra/master/pydra/schema/context.jsonld"
@@ -145,7 +168,19 @@ def make_message(obj, context=None):
145168

146169

147170
def collect_messages(collected_path, message_path, ld_op="compact"):
148-
"""Gather messages."""
171+
"""
172+
Compile all messages into a single provenance graph.
173+
174+
Parameters
175+
----------
176+
collected_path : :obj:`os.pathlike`
177+
A place to write all of the collected messages. (?TODO)
178+
message_path : :obj:`os.pathlike`
179+
A path with the message file (?TODO)
180+
ld_op : :obj:`str`, optional
181+
Option used by pld.jsonld
182+
"""
183+
149184
import pyld as pld
150185
import json
151186
from glob import glob

0 commit comments

Comments
 (0)