Skip to content
Snippets Groups Projects
Commit 1aa33178 authored by Millian Poquet's avatar Millian Poquet
Browse files

python client

parent cca448c8
No related branches found
No related tags found
No related merge requests found
client.py
\ No newline at end of file
#!/usr/bin/env python3
import zmq
import protocol.hello_pb2 as proto
def main():
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:28000")
# Round 1: hello
msg = socket.recv()
order = proto.Order()
order.hello.name = 'client-py'
msg_str = order.SerializeToString()
socket.send(msg_str)
# Round2: compute flops
msg = socket.recv()
order = proto.Order()
order.compute_flops.flop_amount = 1e9
msg_str = order.SerializeToString()
socket.send(msg_str)
# Round3: bye
msg = socket.recv()
order = proto.Order()
order.bye.SetInParent()
msg_str = order.SerializeToString()
socket.send(msg_str)
if __name__ == '__main__':
main()
#!/usr/bin/env python
from distutils.core import setup
setup(name='client-py',
version='0.1.0',
py_modules=['client'],
scripts=['client-py'],
python_requires='>=3.6',
install_requires=[
'pyzmq>=22.3.0',
'protobuf>=3.19.4',
],
description="Example python client for DZ2 toy CI prototype.",
author='Millian Poquet',
author_email='millian.poquet@irit.fr',
url='https://gitlab.irit.fr/sepia/datazero/ci-prototype',
license='MIT',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
],
)
...@@ -77,6 +77,18 @@ let self = rec { ...@@ -77,6 +77,18 @@ let self = rec {
zeromq zeromq
]; ];
}; };
client-py = pythonPackages.buildPythonPackage {
name = "client-py-0.1.0";
src = pkgs.lib.sourceByRegex ./client-py [
"setup\.py"
"client\.py"
];
propagatedBuildInputs = [
protocol-python
pythonPackages.protobuf
pythonPackages.pyzmq
];
};
integration_shell_cpp = pkgs.mkShell { integration_shell_cpp = pkgs.mkShell {
buildInputs = [ buildInputs = [
...@@ -84,6 +96,12 @@ let self = rec { ...@@ -84,6 +96,12 @@ let self = rec {
client-cpp client-cpp
]; ];
}; };
integration_shell_py = pkgs.mkShell {
buildInputs = [
simgrid-simulator
client-py
];
};
}; };
in in
self self
[Fafard:orchestrator:(1) 0.000000] [orchestrator/INFO] started!
[Fafard:orchestrator:(1) 0.000000] [orchestrator/INFO] connecting to endpoint 'tcp://localhost:28000'...
[Fafard:orchestrator:(1) 0.000000] [orchestrator/INFO] connected!
[Fafard:orchestrator:(1) 0.000000] [orchestrator/INFO] sending what you wanna do
[Fafard:orchestrator:(1) 0.000000] [orchestrator/INFO] received hello from client-py
[Fafard:orchestrator:(1) 0.000000] [orchestrator/INFO] sending what you wanna do
[Fafard:orchestrator:(1) 0.000000] [orchestrator/INFO] computing 1e+09 flops
[Fafard:orchestrator:(1) 13.106847] [orchestrator/INFO] sending what you wanna do
[Fafard:orchestrator:(1) 13.106847] [orchestrator/INFO] received bye
#!/usr/bin/env sh
set -eu
simulator simgrid-simulator/platforms/small_platform.xml 1>simulator.out 2>simulator.err &
simulator_pid=$!
client-py 1>client-py.out 2>client-py.err &
client_pid=$!
wait ${client_pid}
wait ${simulator_pid}
script_dir=$(dirname "$0")
diff simulator.err "${script_dir}/simulator-py-client.expected.err" > simulator.err.diff || true
if [ -s simulator.err.diff ]; then
# file not empty, there is a diff!
echo "simulation output is not the expected one, aborting!"
cat simulator.err.diff
exit 1
else
# file is empty, everything is fine
echo "simulation output is the expected one"
exit 0
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment