Skip to content

Commit ebf85a1

Browse files
committed
Updated docs for v0.5.1
1 parent c00486f commit ebf85a1

File tree

2 files changed

+78
-91
lines changed

2 files changed

+78
-91
lines changed

docs/index.html

Lines changed: 77 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ <h1 class="title">Module <code>state_signals</code></h1>
114114
@dataclass
115115
class Signal:
116116
&#34;&#34;&#34;
117-
Standard event signal protocol payload. All required fields, defaults,
118-
and type restrictions are defined in this dataclass. Also includes a
117+
Standard event signal protocol payload. All required fields, defaults,
118+
and type restrictions are defined in this dataclass. Also includes a
119119
method for converting object data to json string.
120120

121121
Fields:
122122

123-
- publisher_id: A unique id generated by the SignalExporter for identification
124-
- process_name: The name of the process that the state signals are describing
125-
- event: The current state of the process
126-
- runner_host: The host that the process is currently being run on
127-
- sample_no: The current sample number (if applicable, default -1)
128-
- tag: Any user-supplied string tag for the signal (default &#39;No tag specified&#39;)
123+
- publisher_id: A unique id generated by the SignalExporter for identification
124+
- process_name: The name of the process that the state signals are describing
125+
- event: The current state of the process
126+
- runner_host: The host that the process is currently being run on
127+
- sample_no: The current sample number (if applicable, default -1)
128+
- tag: Any user-supplied string tag for the signal (default &#39;No tag specified&#39;)
129129
- metadata: Dictionary containing any additional necessary data (optional)
130130
&#34;&#34;&#34;
131131

@@ -165,20 +165,20 @@ <h1 class="title">Module <code>state_signals</code></h1>
165165
@dataclass
166166
class Response:
167167
&#34;&#34;&#34;
168-
Standard signal response protocol payload. All required fields, defaults,
169-
and type restrictions are defined in this dataclass. Also includes a
168+
Standard signal response protocol payload. All required fields, defaults,
169+
and type restrictions are defined in this dataclass. Also includes a
170170
method for converting object data to json string.
171171

172172
Fields:
173173

174-
- responder_id: A unique id generated by the SignalResponder for identification
175-
- publisher_id: The id of the publisher that is being responded to
176-
- event: The published state of the signal-publishing process
177-
- ras: Response Action Success code
178-
- Whether or not the responding process successfully processed/acted upon the signal
179-
- 1 = successful, 0 (or other) = unsuccessful
174+
- responder_id: A unique id generated by the SignalResponder for identification
175+
- publisher_id: The id of the publisher that is being responded to
176+
- event: The published state of the signal-publishing process
177+
- ras: Response Action Success code
178+
- Whether or not the responding process successfully processed/acted upon the signal
179+
- 1 = successful, 0 (or other) = unsuccessful
180180
- Not needed when not subscribed or responding to initialization
181-
- message: Optional string message for further detail
181+
- message: Optional string message for further detail
182182
&#34;&#34;&#34;
183183

184184
responder_id: str
@@ -233,11 +233,11 @@ <h1 class="title">Module <code>state_signals</code></h1>
233233
init: Sets exporter object fields and generates unique publisher_id.
234234
Allows for specification of redis host/port. Will continue to attempt
235235
to connect to redis server for conn_timeout seconds. Also allows runner
236-
hostname to be inputted manually (otherwise will default to
237-
platform.node() value).
236+
hostname to be inputted manually (otherwise will default to
237+
platform.node() value).
238238
&#34;&#34;&#34;
239239
self.logger = _create_logger(&#34;SignalExporter&#34;, process_name, log_level)
240-
self.subs = []
240+
self.subs = set()
241241
self.proc_name = process_name
242242
self.runner_host = runner_host
243243
self.pub_id = process_name + &#34;-&#34; + str(uuid.uuid4())
@@ -314,7 +314,7 @@ <h1 class="title">Module <code>state_signals</code></h1>
314314
and data[&#34;event&#34;] == &#34;initialization&#34;
315315
and data[&#34;publisher_id&#34;] == self.pub_id
316316
):
317-
self.subs.append(data[&#34;responder_id&#34;])
317+
self.subs.add(data[&#34;responder_id&#34;])
318318

319319
subscriber.subscribe(**{&#34;event-signal-response&#34;: _init_handler})
320320
self.init_listener = subscriber.run_in_thread()
@@ -328,7 +328,7 @@ <h1 class="title">Module <code>state_signals</code></h1>
328328
if not self.subs:
329329
return None, [0], {}
330330

331-
to_check = set(self.subs)
331+
to_check = self.subs.copy()
332332
subscriber = self.redis.pubsub(ignore_subscribe_messages=True)
333333
result_code_holder = [ResultCodes.ALL_SUBS_SUCCESS]
334334
msgs = {}
@@ -385,8 +385,8 @@ <h1 class="title">Module <code>state_signals</code></h1>
385385

386386
Result Codes:
387387

388-
- ALL_SUBS_SUCCESS = 0 = all subs responded well
389-
- SUB_FAILED = 1 = one or more sub responded badly
388+
- ALL_SUBS_SUCCESS = 0 = all subs responded well
389+
- SUB_FAILED = 1 = one or more sub responded badly
390390
- MISSING_RESPONSE = 2 = not all subs responded
391391
&#34;&#34;&#34;
392392
if not isinstance(timeout, int):
@@ -451,7 +451,7 @@ <h1 class="title">Module <code>state_signals</code></h1>
451451
&#34;&#39;expected_hosts&#39; arg must be a list of string hostnames&#34;
452452
)
453453
for resp in expected_resps:
454-
self.subs.append(resp)
454+
self.subs.add(resp)
455455

456456
self.legal_events = legal_events
457457
sig = self._sig_builder(event=&#34;initialization&#34;, tag=tag)
@@ -505,7 +505,7 @@ <h1 class="title">Module <code>state_signals</code></h1>
505505
sig = self._sig_builder(event=&#34;shutdown&#34;, tag=tag)
506506
self.init_listener.stop()
507507
self.init_listener.join()
508-
self.subs = []
508+
self.subs = set()
509509
self.redis.publish(channel=&#34;event-signal-pubsub&#34;, message=sig.to_json_str())
510510
self.logger.debug(&#34;Shutdown successful!&#34;)
511511

@@ -608,7 +608,7 @@ <h1 class="title">Module <code>state_signals</code></h1>
608608
) -&gt; None:
609609
&#34;&#34;&#34;
610610
Publish a legal response to a certain publisher_id&#39;s event signal.
611-
Also allows for optional ras code to be added on (required for
611+
Also allows for optional ras code to be added on (required for
612612
publisher acknowledgement, but not for initialization response),
613613
as well as an optional message.
614614
&#34;&#34;&#34;
@@ -620,7 +620,7 @@ <h1 class="title">Module <code>state_signals</code></h1>
620620
&#34;&#34;&#34;
621621
Publish a legal response to a given signal. Serves as a wrapper
622622
for the respond method. Also allows for optional ras code to be
623-
added on (required for publisher acknowledgement, but not for
623+
added on (required for publisher acknowledgement, but not for
624624
initialization response), as well as an optional message.
625625
&#34;&#34;&#34;
626626
self.respond(signal.publisher_id, signal.event, ras, message)
@@ -677,18 +677,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
677677
method for converting object data to json string.</p>
678678
<h2 id="fields">Fields</h2>
679679
<ul>
680-
<li>responder_id: A unique id generated by the SignalResponder for identification
681-
</li>
682-
<li>publisher_id: The id of the publisher that is being responded to
683-
</li>
684-
<li>event: The published state of the signal-publishing process
685-
</li>
686-
<li>ras: Response Action Success code
687-
<ul>
688-
<li>Whether or not the responding process successfully processed/acted upon the signal
689-
</li>
690-
<li>1 = successful, 0 (or other) = unsuccessful
691-
</li>
680+
<li>responder_id: A unique id generated by the SignalResponder for identification</li>
681+
<li>publisher_id: The id of the publisher that is being responded to</li>
682+
<li>event: The published state of the signal-publishing process</li>
683+
<li>ras: Response Action Success code<ul>
684+
<li>Whether or not the responding process successfully processed/acted upon the signal</li>
685+
<li>1 = successful, 0 (or other) = unsuccessful</li>
692686
<li>Not needed when not subscribed or responding to initialization</li>
693687
</ul>
694688
</li>
@@ -700,20 +694,20 @@ <h2 id="fields">Fields</h2>
700694
</summary>
701695
<pre><code class="python">class Response:
702696
&#34;&#34;&#34;
703-
Standard signal response protocol payload. All required fields, defaults,
704-
and type restrictions are defined in this dataclass. Also includes a
697+
Standard signal response protocol payload. All required fields, defaults,
698+
and type restrictions are defined in this dataclass. Also includes a
705699
method for converting object data to json string.
706700

707701
Fields:
708702

709-
- responder_id: A unique id generated by the SignalResponder for identification
710-
- publisher_id: The id of the publisher that is being responded to
711-
- event: The published state of the signal-publishing process
712-
- ras: Response Action Success code
713-
- Whether or not the responding process successfully processed/acted upon the signal
714-
- 1 = successful, 0 (or other) = unsuccessful
703+
- responder_id: A unique id generated by the SignalResponder for identification
704+
- publisher_id: The id of the publisher that is being responded to
705+
- event: The published state of the signal-publishing process
706+
- ras: Response Action Success code
707+
- Whether or not the responding process successfully processed/acted upon the signal
708+
- 1 = successful, 0 (or other) = unsuccessful
715709
- Not needed when not subscribed or responding to initialization
716-
- message: Optional string message for further detail
710+
- message: Optional string message for further detail
717711
&#34;&#34;&#34;
718712

719713
responder_id: str
@@ -848,18 +842,12 @@ <h3>Class variables</h3>
848842
method for converting object data to json string.</p>
849843
<h2 id="fields">Fields</h2>
850844
<ul>
851-
<li>publisher_id: A unique id generated by the SignalExporter for identification
852-
</li>
853-
<li>process_name: The name of the process that the state signals are describing
854-
</li>
855-
<li>event: The current state of the process
856-
</li>
857-
<li>runner_host: The host that the process is currently being run on
858-
</li>
859-
<li>sample_no: The current sample number (if applicable, default -1)
860-
</li>
861-
<li>tag: Any user-supplied string tag for the signal (default 'No tag specified')
862-
</li>
845+
<li>publisher_id: A unique id generated by the SignalExporter for identification</li>
846+
<li>process_name: The name of the process that the state signals are describing</li>
847+
<li>event: The current state of the process</li>
848+
<li>runner_host: The host that the process is currently being run on</li>
849+
<li>sample_no: The current sample number (if applicable, default -1)</li>
850+
<li>tag: Any user-supplied string tag for the signal (default 'No tag specified')</li>
863851
<li>metadata: Dictionary containing any additional necessary data (optional)</li>
864852
</ul></div>
865853
<details class="source">
@@ -868,18 +856,18 @@ <h2 id="fields">Fields</h2>
868856
</summary>
869857
<pre><code class="python">class Signal:
870858
&#34;&#34;&#34;
871-
Standard event signal protocol payload. All required fields, defaults,
872-
and type restrictions are defined in this dataclass. Also includes a
859+
Standard event signal protocol payload. All required fields, defaults,
860+
and type restrictions are defined in this dataclass. Also includes a
873861
method for converting object data to json string.
874862

875863
Fields:
876864

877-
- publisher_id: A unique id generated by the SignalExporter for identification
878-
- process_name: The name of the process that the state signals are describing
879-
- event: The current state of the process
880-
- runner_host: The host that the process is currently being run on
881-
- sample_no: The current sample number (if applicable, default -1)
882-
- tag: Any user-supplied string tag for the signal (default &#39;No tag specified&#39;)
865+
- publisher_id: A unique id generated by the SignalExporter for identification
866+
- process_name: The name of the process that the state signals are describing
867+
- event: The current state of the process
868+
- runner_host: The host that the process is currently being run on
869+
- sample_no: The current sample number (if applicable, default -1)
870+
- tag: Any user-supplied string tag for the signal (default &#39;No tag specified&#39;)
883871
- metadata: Dictionary containing any additional necessary data (optional)
884872
&#34;&#34;&#34;
885873

@@ -1011,11 +999,11 @@ <h3>Methods</h3>
1011999
init: Sets exporter object fields and generates unique publisher_id.
10121000
Allows for specification of redis host/port. Will continue to attempt
10131001
to connect to redis server for conn_timeout seconds. Also allows runner
1014-
hostname to be inputted manually (otherwise will default to
1015-
platform.node() value).
1002+
hostname to be inputted manually (otherwise will default to
1003+
platform.node() value).
10161004
&#34;&#34;&#34;
10171005
self.logger = _create_logger(&#34;SignalExporter&#34;, process_name, log_level)
1018-
self.subs = []
1006+
self.subs = set()
10191007
self.proc_name = process_name
10201008
self.runner_host = runner_host
10211009
self.pub_id = process_name + &#34;-&#34; + str(uuid.uuid4())
@@ -1092,7 +1080,7 @@ <h3>Methods</h3>
10921080
and data[&#34;event&#34;] == &#34;initialization&#34;
10931081
and data[&#34;publisher_id&#34;] == self.pub_id
10941082
):
1095-
self.subs.append(data[&#34;responder_id&#34;])
1083+
self.subs.add(data[&#34;responder_id&#34;])
10961084

10971085
subscriber.subscribe(**{&#34;event-signal-response&#34;: _init_handler})
10981086
self.init_listener = subscriber.run_in_thread()
@@ -1106,7 +1094,7 @@ <h3>Methods</h3>
11061094
if not self.subs:
11071095
return None, [0], {}
11081096

1109-
to_check = set(self.subs)
1097+
to_check = self.subs.copy()
11101098
subscriber = self.redis.pubsub(ignore_subscribe_messages=True)
11111099
result_code_holder = [ResultCodes.ALL_SUBS_SUCCESS]
11121100
msgs = {}
@@ -1163,8 +1151,8 @@ <h3>Methods</h3>
11631151

11641152
Result Codes:
11651153

1166-
- ALL_SUBS_SUCCESS = 0 = all subs responded well
1167-
- SUB_FAILED = 1 = one or more sub responded badly
1154+
- ALL_SUBS_SUCCESS = 0 = all subs responded well
1155+
- SUB_FAILED = 1 = one or more sub responded badly
11681156
- MISSING_RESPONSE = 2 = not all subs responded
11691157
&#34;&#34;&#34;
11701158
if not isinstance(timeout, int):
@@ -1229,7 +1217,7 @@ <h3>Methods</h3>
12291217
&#34;&#39;expected_hosts&#39; arg must be a list of string hostnames&#34;
12301218
)
12311219
for resp in expected_resps:
1232-
self.subs.append(resp)
1220+
self.subs.add(resp)
12331221

12341222
self.legal_events = legal_events
12351223
sig = self._sig_builder(event=&#34;initialization&#34;, tag=tag)
@@ -1283,7 +1271,7 @@ <h3>Methods</h3>
12831271
sig = self._sig_builder(event=&#34;shutdown&#34;, tag=tag)
12841272
self.init_listener.stop()
12851273
self.init_listener.join()
1286-
self.subs = []
1274+
self.subs = set()
12871275
self.redis.publish(channel=&#34;event-signal-pubsub&#34;, message=sig.to_json_str())
12881276
self.logger.debug(&#34;Shutdown successful!&#34;)</code></pre>
12891277
</details>
@@ -1319,7 +1307,7 @@ <h3>Methods</h3>
13191307
&#34;&#39;expected_hosts&#39; arg must be a list of string hostnames&#34;
13201308
)
13211309
for resp in expected_resps:
1322-
self.subs.append(resp)
1310+
self.subs.add(resp)
13231311

13241312
self.legal_events = legal_events
13251313
sig = self._sig_builder(event=&#34;initialization&#34;, tag=tag)
@@ -1391,9 +1379,8 @@ <h3>Methods</h3>
13911379
signal publish/response success, as well as any included response messages.</p>
13921380
<p>Result Codes:</p>
13931381
<ul>
1394-
<li>ALL_SUBS_SUCCESS = 0 = all subs responded well </li>
1395-
<li>SUB_FAILED = 1 = one or more sub responded badly
1396-
</li>
1382+
<li>ALL_SUBS_SUCCESS = 0 = all subs responded well</li>
1383+
<li>SUB_FAILED = 1 = one or more sub responded badly</li>
13971384
<li>MISSING_RESPONSE = 2 = not all subs responded</li>
13981385
</ul></div>
13991386
<details class="source">
@@ -1417,8 +1404,8 @@ <h3>Methods</h3>
14171404

14181405
Result Codes:
14191406

1420-
- ALL_SUBS_SUCCESS = 0 = all subs responded well
1421-
- SUB_FAILED = 1 = one or more sub responded badly
1407+
- ALL_SUBS_SUCCESS = 0 = all subs responded well
1408+
- SUB_FAILED = 1 = one or more sub responded badly
14221409
- MISSING_RESPONSE = 2 = not all subs responded
14231410
&#34;&#34;&#34;
14241411
if not isinstance(timeout, int):
@@ -1484,7 +1471,7 @@ <h3>Methods</h3>
14841471
sig = self._sig_builder(event=&#34;shutdown&#34;, tag=tag)
14851472
self.init_listener.stop()
14861473
self.init_listener.join()
1487-
self.subs = []
1474+
self.subs = set()
14881475
self.redis.publish(channel=&#34;event-signal-pubsub&#34;, message=sig.to_json_str())
14891476
self.logger.debug(&#34;Shutdown successful!&#34;)</code></pre>
14901477
</details>
@@ -1605,7 +1592,7 @@ <h3>Methods</h3>
16051592
) -&gt; None:
16061593
&#34;&#34;&#34;
16071594
Publish a legal response to a certain publisher_id&#39;s event signal.
1608-
Also allows for optional ras code to be added on (required for
1595+
Also allows for optional ras code to be added on (required for
16091596
publisher acknowledgement, but not for initialization response),
16101597
as well as an optional message.
16111598
&#34;&#34;&#34;
@@ -1617,7 +1604,7 @@ <h3>Methods</h3>
16171604
&#34;&#34;&#34;
16181605
Publish a legal response to a given signal. Serves as a wrapper
16191606
for the respond method. Also allows for optional ras code to be
1620-
added on (required for publisher acknowledgement, but not for
1607+
added on (required for publisher acknowledgement, but not for
16211608
initialization response), as well as an optional message.
16221609
&#34;&#34;&#34;
16231610
self.respond(signal.publisher_id, signal.event, ras, message)
@@ -1737,7 +1724,7 @@ <h3>Methods</h3>
17371724
) -&gt; None:
17381725
&#34;&#34;&#34;
17391726
Publish a legal response to a certain publisher_id&#39;s event signal.
1740-
Also allows for optional ras code to be added on (required for
1727+
Also allows for optional ras code to be added on (required for
17411728
publisher acknowledgement, but not for initialization response),
17421729
as well as an optional message.
17431730
&#34;&#34;&#34;
@@ -1762,7 +1749,7 @@ <h3>Methods</h3>
17621749
&#34;&#34;&#34;
17631750
Publish a legal response to a given signal. Serves as a wrapper
17641751
for the respond method. Also allows for optional ras code to be
1765-
added on (required for publisher acknowledgement, but not for
1752+
added on (required for publisher acknowledgement, but not for
17661753
initialization response), as well as an optional message.
17671754
&#34;&#34;&#34;
17681755
self.respond(signal.publisher_id, signal.event, ras, message)</code></pre>
@@ -1864,4 +1851,4 @@ <h4><code><a title="state_signals.SignalResponder" href="#state_signals.SignalRe
18641851
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
18651852
</footer>
18661853
</body>
1867-
</html>
1854+
</html>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "state-signals"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
description = "Package for easy management of state/event signal publishing, subscribing, and responding"
55

66
license = "GPL-3.0-only"

0 commit comments

Comments
 (0)