Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Commit 8b5789a

Browse files
manju956rranjan3
authored andcommitted
Documentation changes for Graphene python worker
Signed-off-by: manju956 <[email protected]>
1 parent fc0753a commit 8b5789a

File tree

3 files changed

+156
-135
lines changed

3 files changed

+156
-135
lines changed

examples/graphene_apps/cppopenvino/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,72 @@ https://creativecommons.org/licenses/by/4.0/
7373

7474
`docker-compose -f docker-compose.yaml -f docker-compose-sgx.yaml up`
7575

76+
## Testing OpenVino Object detection with Python worker
77+
78+
### Testing OpenVino (without Avalon)
79+
80+
- For non SGX mode, execute below steps from [cppopenvino](http://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/cppopenvino) directory
81+
82+
- Build Openvino python workload image
83+
`docker-compose -f compose/python-worker-graphene.yaml build`
84+
- Run Openvino inference workloads with python worker
85+
`docker-compose -f docker-compose.yaml -f compose/python-worker-graphene.yaml -f compose/ov-subnet.yaml up`
86+
87+
- For SGX mode, execute below steps
88+
89+
- Build Openvino python workload image
90+
`docker-compose -f compose/python-worker-graphene.yaml build`
91+
- Run Openvino inference workloads with graphene python worker
92+
`docker-compose -f docker-compose.yaml -f docker-compose-sgx.yaml -f compose/python-worker-graphene.yaml -f compose/python-worker-gsgx.yaml -f compose/ov-subnet.yaml up`
93+
94+
### Testing OpenVino (with Avalon)
95+
96+
- If Intel SGX is not used, execute following commands from Avalon repository top-level directory
97+
98+
1. Combine the docker compose files to create `openvino.yaml`
99+
100+
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-ov-graphene.yaml -f docker/compose/avalon-ov-subnet.yaml config > openvino.yaml`
101+
102+
2. Start Avalon containers. This will also start Avalon openvino python workload and openvino containers in detached mode.
103+
104+
`docker-compose -f openvino.yaml up -d`
105+
106+
- For Intel SGX, execute the following commands:
107+
108+
1. Combine the docker compose files to create `openvino-sgx.yaml`
109+
110+
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-ov-graphene.yaml -f docker/compose/avalon-ov-gsgx.yaml -f docker/compose/avalon-ov-subnet.yaml config > openvino-sgx.yaml`
111+
112+
2. Start Avalon containers. This will also start Avalon python openvino workload and openvino containers running inside Graphene-SGX in detached mode.
113+
114+
`docker-compose -f openvino-sgx.yaml up -d`
115+
116+
- In case of Intel SGX, Graphene-SGX openvino python workload and openvino containers will take around 3 minutes to get ready. To view the logs of python worker and openvino containers, execute the following command:
117+
118+
`docker-compose -f openvino-sgx.yaml logs -f graphene-python-workload ov-work-order`
119+
120+
- To send openvino work orders to python worker, we can use [generic client](https://github.com/hyperledger/avalon/tree/master/examples/apps/generic_client) application. Execute the following commands:
121+
122+
1. Get into Avalon Shell container : `sudo docker exec -it avalon-shell bash`
123+
124+
2. cd `/project/avalon/examples/apps/generic_client/`
125+
126+
3. Send openvino work order request with *"ov-inference"* workload id to Graphene worker *"graphene-worker-1"*
127+
128+
`./generic_client.py --uri "http://avalon-listener:1947" -w "graphene-worker-1" --workload_id "ov-inference" --in_data "street.jpg" -o`
129+
130+
If everything goes fine, then you should see the following output in stdout:
131+
132+
*Decryption result at client - Openvino Success: Generated output file: street.bmp*
133+
134+
output file *street.bmp* will be present in *output* folder in Avalon repository top level directory.
135+
136+
- To restart the openvino python workload we have to first bring all the containers down before bringing it up again. This is to ensure that python worker generates new worker signing and encryption keys and Avalon Graphene Enclave Manager gets the updated signup information from python worker.
137+
138+
- If Intel SGX is not used, execute the command: `docker-compose -f openvino.yaml down`
139+
140+
- For Intel SGX, execute the command: `docker-compose -f openvino-sgx.yaml down`
141+
76142
## Known issues
77143

78144
- Graphene Production blockers: [oscarlab/graphene#1544](https://github.com/oscarlab/graphene/issues/1544)
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<!--
2+
Licensed under Creative Commons Attribution 4.0 International License
3+
https://creativecommons.org/licenses/by/4.0/
4+
-->
5+
6+
# Hyperledger Avalon Python Workload for Graphene SGX
7+
8+
## Building and Running the Fibonacci python workload without Intel SGX
9+
10+
- To build Avalon Python worker run the following command from [python_worker](https://github.com/hyperledger/avalon/tree/master/tc/graphene/python_worker) directory:
11+
12+
`docker-compose build`
13+
14+
This will create docker image *avalon-python-worker-dev*. This image contains Avalon python worker, hello workload and a test application to send fibonacci work orders to python worker.
15+
16+
- To build Fibonacci python workload, run the following command from [fibonacci](https://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_workloads/fibonacci) directory.
17+
`docker-compose build`
18+
19+
This will create docker image *avalon-fibonacci-workload-dev*. This image contains Avalon python worker, fibonacci workload and a test application to send fibonacci work orders to python worker.
20+
21+
### Test Fibonacci python workload using Avalon
22+
23+
- To run fibonacci python workload with Avalon Graphene Enclave Manager, go to Avalon repository top level directory and execute the following command:
24+
25+
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-fib-graphene.yaml up`
26+
27+
- To send work orders to fibonacci workload running python worker we can use [generic client](https://github.com/hyperledger/avalon/tree/master/examples/apps/generic_client) application. Execute following commands:
28+
29+
1. Get into Avalon Shell container : `sudo docker exec -it avalon-shell bash`
30+
31+
2. `cd /project/avalon/examples/apps/generic_client/`
32+
33+
3. Send work order request with *"python-fib"* workload id to fibonacci workload running in graphene worker *"graphene-worker-1"*
34+
35+
`./generic_client.py --uri "http://avalon-listener:1947" -w "graphene-worker-1" --workload_id "python-fib" --in_data "10" -o`
36+
37+
If everything goes fine, then you should see following output in stdout:
38+
39+
*Decryption result at client - Fibonacci number at position 10 = 55*
40+
41+
## Building and Running Fibonacci workload in Graphene SGX
42+
43+
- Run the following command from Graphene git repository root directory:
44+
45+
1. Copy the Graphene python worker GSC build script file *build_gsc_fibonacci_workload.sh* from [here](https://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_workloads/fibonacci/graphene_sgx) to <graphene_repo>/Tools/gsc using following command :
46+
47+
`cp <path of build_gsc_fibonacci_workload.sh> Tools/gsc`
48+
49+
2. Set *TCF_HOME* to the top level directory of your avalon source repository.
50+
51+
`export TCF_HOME=<path of avalon repo top level directory>`
52+
53+
3. Graphenize Avalon python worker docker image using following command :
54+
55+
`./build_gsc_fibonacci_workload.sh`
56+
57+
Above command if run successfully will generate a Graphene based docker image *gsc-avalon-fibonacci-workload-dev*.
58+
59+
### Test Fibonacci workload using test client (without Avalon)
60+
61+
- To run fibonacci workload as a docker container in Graphene-SGX environment and to use a test application to send work order requests, execute the following command from [fibonacci](https://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_workloads/fibonacci) directory.
62+
63+
`docker-compose -f docker-compose.yaml -f compose/graphene-sgx.yaml up`
64+
65+
Above command will run test work orders listed in file [*test_fib_work_orders.json*](http://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_workloads/fibonacci/tests/test_fib_work_orders.json).
66+
67+
### Test Fibonacci workload using Avalon
68+
69+
- To run fibonacci workload in Graphene-SGX with Avalon Graphene Enclave Manager, go to Avalon repository top level directory and execute the following commands :
70+
71+
1. Start all the required containers in detached mode.
72+
73+
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-fib-graphene.yaml -f docker/compose/avalon-fib-gsgx.yaml up -d`
74+
75+
2. Graphene-SGX Fibonacci workload service will take around 3 minutes to get ready. Check the logs of graphene python workload using below command
76+
77+
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-fib-graphene.yaml -f docker/compose/avalon-fib-gsgx.yaml logs -f graphene-python-workload`
78+
79+
If everything goes fine you should see following log in stdout
80+
81+
*graphene-python-workload | Generate worker signing and encryption keys*
82+
*graphene-python-workload | Start listening to ZMQ for work orders*
83+
*graphene-python-workload | Bind to zmq port*
84+
*graphene-python-workload | waiting for next request*
85+
86+
3. To send work orders to fibonacci workload running in python worker we can use Avalon generic client application as shown [above](https://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_workloads#test-python-worker-using-avalon).
87+
88+
4. To restart the python worker you have to first bring all the containers down before bringing it up again. This is to ensure that python worker generate new keys and Avalon Graphene Enclave Manager gets the updated sign up information from python worker.
89+
90+
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-fib-graphene.yaml -f docker/compose/avalon-fib-gsgx.yaml down`

tc/graphene/python_worker/README.md

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,6 @@ https://creativecommons.org/licenses/by/4.0/
3636

3737
Above command will run test work orders listed in file [*test_work_orders.json*](http://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_worker/tests/test_work_orders.json).
3838

39-
### Test python worker using Avalon
40-
41-
- To run python worker with Avalon Graphene Enclave Manager, go to Avalon repository top level directory and execute the following command:
42-
43-
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-graphene.yaml up`
44-
45-
- To send work orders to python worker we can use [generic client](https://github.com/hyperledger/avalon/tree/master/examples/apps/generic_client) application. Execute following commands:
46-
47-
1. Get into Avalon Shell container : `sudo docker exec -it avalon-shell bash`
48-
49-
2. `cd /project/avalon/examples/apps/generic_client/`
50-
51-
3. Send work order request with *"python-hello"* workload id to Graphene worker *"graphene-worker-1"*
52-
53-
`./generic_client.py --uri "http://avalon-listener:1947" -w "graphene-worker-1" --workload_id "python-hello" --in_data "Krsna" -o`
54-
55-
If everything goes fine, then you should see following output in stdout:
56-
57-
*Decryption result at client - Hello Krsna*
58-
5939
## Building and Running the worker in Graphene SGX
6040

6141
- Before building and running application for Graphene-SGX, we need to install Intel SGX driver and Graphene SGX driver.
@@ -113,121 +93,6 @@ https://creativecommons.org/licenses/by/4.0/
11393
11494
Above command will run test work orders listed in file [*test_work_orders.json*](http://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_worker/tests/test_work_orders.json).
11595
116-
### Test python worker using Avalon
117-
118-
- To run python worker in Graphene-SGX with Avalon Graphene Enclave Manager, go to Avalon repository top level directory and execute the following commands :
119-
120-
1. Start all the required containers in detached mode.
121-
122-
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-graphene.yaml -f docker/compose/avalon-graphene-sgx.yaml up -d`
123-
124-
2. Graphene-SGX Python worker will take around 3 minutes to get ready. Check the logs of graphene python worker using below command
125-
126-
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-graphene.yaml -f docker/compose/avalon-graphene-sgx.yaml logs -f graphene-python-worker`
127-
128-
If everything goes fine you should see following log in stdout
129-
130-
*graphene-python-worker | Generate worker signing and encryption keys*
131-
*graphene-python-worker | Start listening to ZMQ for work orders*
132-
*graphene-python-worker | Bind to zmq port*
133-
*graphene-python-worker | waiting for next request*
134-
135-
3. To send work orders to python worker we can use Avalon generic client application as shown [above](https://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_worker#test-python-worker-using-avalon).
136-
137-
4. To restart the python worker you have to first bring all the containers down before bringing it up again. This is to ensure that python worker generate new keys and Avalon Graphene Enclave Manager gets the updated sign up information from python worker.
138-
139-
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-graphene.yaml -f docker/compose/avalon-graphene-sgx.yaml down`
140-
141-
## Adding a new Python Workload
142-
143-
- Avalon Python worker supports two sample workloads: "python-hello" and "python-fib".
144-
145-
- List of sample workloads are listed in *workloads.json* file kept in [python_worker](http://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_worker) directory.
146-
147-
*{*
148-
*"python-hello": {*
149-
*"module": "sample_workloads.workload.hello",*
150-
*"class": "HelloWorkLoad"*
151-
*},*
152-
*"python-fib": {*
153-
*"module": "sample_workloads.workload.fibonacci",*
154-
*"class": "FibonacciWorkLoad"*
155-
*}*
156-
*}*
157-
158-
- Python sample workloads are is kept in [sample_workloads](http://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_worker/sample_workloads) directory.
159-
160-
- To add a new python workload, keep the python workload implementation class in sample workloads directory and also edit the *workloads.json* file to add new workload. The format of workload in *workloads.json* file is as shown below :
161-
162-
*"workload-id": {*
163-
*"module": "<workload python module>",*
164-
*"class": "<workload implementation class name>"*
165-
*}*
166-
167-
## Testing OpenVino Object detection with Python worker
168-
169-
- First build OpenVino docker image and GSC docker image using the steps mentioned in cppopenvino [ReadMe](https://github.com/hyperledger/avalon/blob/master/examples/graphene_apps/cppopenvino/README.md)
170-
171-
- Below steps will run sample openvino inference test cases in [test_ov_work_orders.json](http://github.com/hyperledger/avalon/tree/master/examples/graphene_apps/python_worker/tests/test_ov_work_orders.json)
172-
173-
### Testing OpenVino (without Avalon)
174-
175-
- For non SGX mode, execute below command
176-
177-
`docker-compose -f docker-compose.yaml -f compose/ov.yaml -f compose/ov-subnet.yaml up`
178-
179-
- For SGX mode, execute below command
180-
181-
`docker-compose -f docker-compose.yaml -f compose/graphene-sgx.yaml -f compose/ov.yaml -f compose/ov-sgx.yaml -f compose/ov-subnet.yaml up`
182-
183-
### Testing OpenVino (with Avalon)
184-
185-
- If Intel SGX is not used , execute following commands from Avalon repository top-level directory
186-
187-
1. Combine the docker compose files to create `openvino.yaml`
188-
189-
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-graphene.yaml -f docker/compose/avalon-graphene-ov.yaml -f docker/compose/avalon-ov-subnet.yaml config > openvino.yaml`
190-
191-
2. Start Avalon containers. This will also start Avalon python worker and openvino containers in detached mode.
192-
193-
`docker-compose -f openvino.yaml up -d`
194-
195-
- For Intel SGX, execute the following commands:
196-
197-
1. Combine the docker compose files to create `openvino-sgx.yaml`
198-
199-
`docker-compose -f docker-compose.yaml -f docker/compose/avalon-graphene.yaml -f docker/compose/avalon-graphene-sgx.yaml -f docker/compose/avalon-graphene-ov.yaml -f docker/compose/avalon-graphene-ov-sgx.yaml -f docker/compose/avalon-ov-subnet.yaml config > openvino-sgx.yaml`
200-
201-
2. Start Avalon containers. This will also start Avalon python worker and openvino containers running inside Graphene-SGX in detached mode.
202-
203-
`docker-compose -f openvino-sgx.yaml up -d`
204-
205-
- In case of Intel SGX, Graphene-SGX python worker and openvino containers will take around 3 minutes to get ready. To view the logs of python worker and openvino containers, execute the following command:
206-
207-
`docker-compose -f openvino-sgx.yaml logs -f graphene-python-worker ov-work-order`
208-
209-
- To send openvino work orders to python worker, we can use [generic client](https://github.com/hyperledger/avalon/tree/master/examples/apps/generic_client) application. Execute the following commands:
210-
211-
1. Get into Avalon Shell container : `sudo docker exec -it avalon-shell bash`
212-
213-
2. cd `/project/avalon/examples/apps/generic_client/`
214-
215-
3. Send openvino work order request with *"ov-inference"* workload id to Graphene worker *"graphene-worker-1"*
216-
217-
`./generic_client.py --uri "http://avalon-listener:1947" -w "graphene-worker-1" --workload_id "ov-inference" --in_data "street.jpg" -o`
218-
219-
If everything goes fine, then you should see the following output in stdout:
220-
221-
*Decryption result at client - Openvino Success: Generated output file: street.bmp*
222-
223-
output file *street.bmp* will be present in *output* folder in Avalon repository top level directory.
224-
225-
- To restart the python worker we have to first bring all the containers down before bringing it up again. This is to ensure that python worker generates new worker signing and encryption keys and Avalon Graphene Enclave Manager gets the updated signup information from python worker.
226-
227-
If Intel SGX is not used, execute the command: `docker-compose -f openvino.yaml down`
228-
229-
For Intel SGX, execute the command: `docker-compose -f openvino-sgx.yaml down`
230-
23196
## Known issues
23297
23398
- Knows issues are captured in GitHub : https://github.com/hyperledger/avalon/issues/621

0 commit comments

Comments
 (0)