-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfix - direct messaging between nodes & multihop messages (#99)
Addresses #93 - allows messages to be sent directly between net nodes with less fuss, as well as allows messages to be addressed with a list, see the appropriate tests and the discussion in the linked issue In addition, fixed a number of things en passant - added a few tests, including the testing framework to allow GUI tests to be run on the CI, and added tests to the docs experimentally - send full continuous sound through queue rather than in frames, which was causing the continous sound to become truncated - pop a dialogue if terminal is launched without any pilots prompting to add a pilot, addressing #27 - better identification of objects in log creation, looking first for an `id` field that will eventually be the uniform way of identifying objects - split networking into its own module - more type hinting - continued work on removing ad-hoc logic, failing loudly instead of trying to do things implicitly - added favicon to docs <3 - refactored docs into subfolders rather than long period-delimited filenames. - bumped zmq and tornado dep versions Squashed commits: * travis basics * travis test 2 * travis test 3 - no enc setup scripts in setup.py * travis test 4 - get the command right * named test file right * reversing test of event invoker * jesuz * drop all chunks at once * debug flag * handling emptiness and making logger from process * fixing multihop messages... just the send part, now need to fix the 'handle listen' in both the Station and the Net_Node also some type hinting and docstring fixes and cleanup as we go * refactoring networking to own module refactoring docs to use folders instead of extremely long paths * image links * api links * favicon * somehow still missing networking docs * favicon * actually adding scripts * draft of direct messaging between net_nodes * networking docs * clean up station object - absolutely had no idea what class attributes were when i made this i guess - fixing docstring - type hinting - spawning thread in the process by putting it in run rather than in init * correct type hints * maybe get scripts to render? * node-to-node test * multihop test - station objects and node objects count how many messages they receive - let station objects be instantiated programmatically - fixing programmatic station release - loggers check id first before name * fixing prefs test defaults * coverage of mp? * coverage of mp? * coverage of mp? * coverage of mp? * coverage of mp? * coverage of mp? * testing delay in sound trigger * testing delay in sound trigger * set agent clear method for prefs * the godforsaken managers module * the godforsaken managers module * the godforsaken managers module * - terminal test - get app from QApplication.instance() instead of implicitly - close ioloop on release of net nodes - 'float' type in setup - don't save prefs if in tests - bumping requirements to support some features we rely on * asyncio debug mode * do it except not in different build configs * do it except not in different build configs * close event? * istg * again istg * again istg * graspin at straws * graspin at straws * good heavens finally. reverting exploratory attempts at fixes * adding tests to the docs * prompt to add pilots on blank screen init
- Loading branch information
1 parent
c08d3ed
commit cc86611
Showing
100 changed files
with
1,779 additions
and
1,291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[run] | ||
concurrency = multiprocessing | ||
parallel = 1 | ||
omit = | ||
*/site-packages/_pytest/* | ||
*/site-packages/py/* | ||
*/site-packages/pytest/* | ||
*/site-packages/pytest_cov/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
""" | ||
Classes for network communication. | ||
There are two general types of network objects - | ||
* :class:`autopilot.networking.Station` and its children are independent processes that should only be instantiated once | ||
per piece of hardware. They are used to distribute messages between :class:`.Net_Node` s, | ||
forward messages up the networking tree, and responding to messages that don't need any input from | ||
the :class:`~.pilot.Pilot` or :class:`~.terminal.Terminal`. | ||
* :class:`.Net_Node` is a pop-in networking class that can be given to any other object that | ||
wants to send or receive messages. | ||
The :class:`~autopilot.networking.Message` object is used to serialize and pass | ||
messages. When sent, messages are ``JSON`` serialized (with some special magic | ||
to compress/encode numpy arrays) and sent as ``zmq`` multipart messages. | ||
Each serialized message, when sent, can have ``n`` frames of the format:: | ||
[hop_0, hop_1, ... hop_n, final_recipient, serialized_message] | ||
Or, messages can have multiple "hops" (a typical message will have one 'hop' specified | ||
by the ``to`` field), the second to last frame is always the final intended recipient, | ||
and the final frame is the serialized message. Note that the ``to`` field of a | ||
:class:`~autopilot.networking.Message` object will always be the final recipient | ||
even if a list is passed for ``to`` when sending. This lets :class:`~.networking.Station` | ||
objects efficiently forward messages without deserializing them at every hop. | ||
""" | ||
|
||
|
||
import base64 | ||
|
||
import blosc | ||
|
||
from autopilot.networking.station import Station, Terminal_Station, Pilot_Station | ||
from autopilot.networking.node import Net_Node | ||
from autopilot.networking.message import Message | ||
|
||
|
||
def serialize_array(array): | ||
""" | ||
Pack an array with :func:`blosc.pack_array` and serialize with :func:`base64.b64encode` | ||
Args: | ||
array (:class:`numpy.ndarray`): Array to serialize | ||
Returns: | ||
dict: {'NUMPY_ARRAY': base-64 encoded, blosc-compressed array.} | ||
""" | ||
compressed = base64.b64encode(blosc.pack_array(array)).decode('ascii') | ||
return {'NUMPY_ARRAY': compressed} |
Oops, something went wrong.