This demo shows a user_manual_scenarios_collaborative_learning
and the nodes involved: user_manual_nodes_model_receiver
and user_manual_nodes_model_sender
. With these 2 nodes implemented, the user can deploy as many nodes of each kind as desired and check the behavior of a simulated network running. They are implemented in Python to prove the communication between the 2 implementations.
The purpose of the demo is to show how a Sender and a Receiver node can communicate. The Receiver node awaits model statistics from the Sender. Since the Sender doesn't have a real AML Engine, it sends the model statistics as a string. Upon receiving the statistics, the Receiver sends a model request, also as a string since it doesn't have an AML Engine. Then, the Sender converts the received model request to uppercase and sends it back as a model reply.
Before running this demo, ensure that AML-IP
is correctly installed using one of the following installation methods:
installation_manual_linux
installation_manual_windows
docker
If the demo package is not compiled, please refer to developer_manual_installation_sources_linux_colcon_demos
or run the command below.
colcon build --packages-up-to amlip_demo_nodes
Once AML-IP packages are installed and built, import the libraries using the following command.
source install/setup.bash
In this section, we will delve into the details of the demo and how it works.
This is the Python code for the user_manual_nodes_model_receiver
application. It does not use real AML Models, but strings. It is implemented in using amlip_py
API.
This code can be found here.
The next block includes the Python header files that allow the use of the AML-IP Python API.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_receiver_custom.py
Let's continue explaining the global variables.
DOMAIN_ID
variable isolates the execution within a specific domain. Nodes with the same domain ID can communicate with each other.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_receiver_custom.py
waiter
is a WaitHandler
that waits on a boolean value. Whenever this value is True
, threads awake. Whenever it is False
, threads wait.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_receiver_custom.py
The CustomModelListener
class listens to user_manual_scenarios_collaborative_learning_statistics
and user_manual_scenarios_collaborative_learning_model_reply
messages received from a user_manual_nodes_model_sender
. This class is supposed to be implemented by the user in order to process the messages received from other nodes in the network.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_receiver_custom.py
The main function orchestrates the execution of the Model Manager Receiver node. It creates an instance of the ModelManagerReceiverNode and starts its execution with the specified listener.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_receiver_custom.py
After starting the node, it waits for statistics to arrive from the user_manual_nodes_model_sender
.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_receiver_custom.py
Then, it requests a model from the user_manual_nodes_model_sender
using the received server ID.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_receiver_custom.py
Finally, the node stops.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_receiver_custom.py
This is the Python code for the user_manual_nodes_model_sender
application. It does not use real AML Models, but strings. It does not have a real AML Engine but instead the calculation is an upper-case conversion of the string received. It is implemented in using amlip_py
API.
This code can be found here.
The following block includes the Python header files necessary for using the AML-IP Python API.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
Let's continue explaining the global variables.
DOMAIN_ID
isolates the execution within a specific domain. Nodes with the same domain ID can communicate with each other.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
waiter
is a WaitHandler
that waits on a boolean value. Whenever this value is True
, threads awake. Whenever it is False
, threads wait.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
The CustomModelReplier
class listens to user_manual_scenarios_collaborative_learning_model_request
request messages received from a user_manual_nodes_model_receiver
. This class is supposed to be implemented by the user in order to process the messages.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
The main function orchestrates the execution of the Model Manager Sender node. It creates an instance of ModelManagerSenderNode.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
After starting the node, it publishes statistics using the publish_statistics()
function, which fills a user_manual_scenarios_collaborative_learning_statistics
and publishes it.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
Then we start the node execution, passing the previously defined CustomModelReplier()
class, which is responsible for managing the request received.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
Waits for the response model to be sent to the user_manual_nodes_model_receiver
.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
Finally, it stops and closes the node.
/../amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo/model_sender_custom.py
This demo runs the implemented nodes in amlip_demo_nodes/amlip_collaborative_learning_demo
.
Run the following command:
# Source colcon installation
source install/setup.bash
# To execute Model Manager Receiver Node
cd ~/AML-IP-ws/src/AML-IP/amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo
python3 model_receiver_custom.py
The expected output is the following:
Starting Manual Test Model Manager Receiver Node Py execution. Creating Node...
Node created: ModelManagerReceiver.0f.19.23.2d. Already processing models.
Model reply received from server
solution: MOBILENET V1
Finishing Manual Test Model Manager Receiver Node Py execution.
Run the following command to answer before closing:
# Source colcon installation
source install/setup.bash
# To execute Model Manager Sender Node
cd ~/AML-IP-ws/src/AML-IP/amlip_demo_nodes/amlip_collaborative_learning_demo/amlip_collaborative_learning_demo
python3 model_sender_custom.py
This execution expects an output similar to the one shown below:
Starting Manual Test Model Manager Sender Node Py execution. Creating Node...
Node created: ModelManagerSender.0a.14.1e.28. Already processing models.
Model request received from client
model: MobileNet V1
solution: MOBILENET V1
Finishing Manual Test Model Manager Sender Node Py execution.