This demo performs a heart disease evaluation based on input parameters. Three clients are available: batch command line client, interactive command line client, and GUI client.
The command line client, Demo.py
, runs a set of pre-built JSON requests.
To run, follow the instructions in the "Testing" section of the
build document.
You may run the CLI demo in standalone mode or in a Docker container.
The command line client generic_client.py
allows you to submit
requests on the command line.
- If needed, update the Ethereum account and direct registry contract
information in
docker/Dockerfile.tcf-dev
andexamples/common/python/connectors/tcf_connector.toml
- Follow instructions in the "Docker-based Build and Execution" section of the build document through step 5 (activating a virtual environment)
- Terminal 1 is running the Avalon Enclave Manager and Listener with
docker-compose
. Terminal 2 is running the Docker container shell - In Terminal 2, set environment variable
WALLET_PRIVATE_KEY
if not set. This should match the value in filedocker/Dockerfile.tcf-dev
from step 3 above:export WALLET_PRIVATE_KEY="B413189C95B48737AE2D9AF4CAE97EB03F4DE40599DF8E6C89DCE4C2E2CBA8DE"
- In Terminal 2 run
cd $TCF_HOME/examples/apps/generic_client
- In Terminal 2, run
./generic_client.py --workload_id "heart-disease-eval" \ --in_data "Data: 25 10 1 67 102 125 1 95 5 10 1 11 36 1"
- The data will be submitted to the worker and the results will appear shortly:
[04:31:55 INFO utility.utility] Decryption result at client - You have a 46% risk of heart disease.
- Optionally submit another request.
Use the
--help
option to see other available options - In Terminal 1, press Ctrl-c to stop the Avalon Enclave Manager and Listener
The GUI client, heart_gui.py
opens a X window on your display.
You must run this on your graphical console or a terminal emulator that
supports X Windows.
The Avalon Enclave Manager and Avalon Listener run in a Docker container.
- If needed, in file
docker/Dockerfile.tcf-dev
changeENV DISPLAY
to the X Windows$DISPLAY
value. By default, it is the console,:0
- If needed, also update the Ethereum account and direct registry contract
information in
docker/Dockerfile.tcf-dev
andexamples/common/python/connectors/tcf_connector.toml
- Follow instructions in the "Docker-based Build and Execution" section of the build document through step 4 (activating a virtual environment)
- Terminal 1 is running the Avalon Enclave Manager and Listener with
docker-compose
. Terminal 2 is running the Docker container shell - In Terminal 2 run
cd $TCF_HOME/examples/apps/heart_disease_eval/client
- In Terminal 2 install Python3's TKInter GUI library with
export DEBIAN_FRONTEND=noninteractive; apt update; apt -y install python3-tk
- In Terminal 2 install the Solidity compiler as follows:
mkdir -p $HOME/.py-solc/solc-v0.4.25/bin \ && curl -LsS https://github.com/ethereum/solidity/releases/download/v0.4.25/solc-static-linux \ -o /root/.py-solc/solc-v0.4.25/bin/solc \ && chmod 0755 /root/.py-solc/solc-v0.4.25/bin/solc && export SOLC_BINARY=/root/.py-solc/solc-v0.4.25/bin/solc
- In Terminal 2, set environment variable
WALLET_PRIVATE_KEY
if not set. This should match the value in filedocker/Dockerfile.tcf-dev
from step 3 above:export WALLET_PRIVATE_KEY="B413189C95B48737AE2D9AF4CAE97EB03F4DE40599DF8E6C89DCE4C2E2CBA8DE"
- If your DISPLAY is not the local console,
:0
, you need to give access to your display from the GUI. Open a new terminal, Terminal 3, and runxhost +
- In Terminal 2, run
./heart_gui.py
. Use the--help
option to see other available options - A new window will pop up with the GUI. See the screenshot below for an example.
- Input all the heart disease evaluation values.
Alternatively, check the "Input variables as string" box to input the
values as a string of 14 integers separated by spaces. For example,
25 10 1 67 102 125 1 95 5 10 1 11 36 1
or32 1 1 156 132 125 1 95 1 0 1 1 3 1
- Click the "Evaluate" button and a new window will appear with the heart disease evaluation result. The "View Request", "View Result", and "View Receipt" buttons will pop up windows displaying the raw JSON RPC files
- Close the GUI windows when done
- If you ran
xhost +
above, close access to your display withxhost -
in Terminal 3 - In Terminal 1, press Ctrl-c to stop the Avalon Enclave Manager and Listener