mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-06-23 04:10:25 +00:00
NOISSUE - Fix docs (#203)
* fix docs Signed-off-by: Sammy Oina <sammyoina@gmail.com> * fix typos Signed-off-by: Sammy Oina <sammyoina@gmail.com> * cli Signed-off-by: Sammy Oina <sammyoina@gmail.com> * add build instructions Signed-off-by: Sammy Oina <sammyoina@gmail.com> * remove file Signed-off-by: Sammy Oina <sammyoina@gmail.com> --------- Signed-off-by: Sammy Oina <sammyoina@gmail.com>
This commit is contained in:
committed by
GitHub
parent
8f2cbd349d
commit
066dacd46a
+36
-22
@@ -3,15 +3,17 @@
|
||||
## CLI
|
||||
|
||||
Throughout the tests, we assume that our current working directory is the root of the `cocos` repository, both on the host machine and in the VM.
|
||||
First, we will build cli by running in the root directory of `cocos`:
|
||||
```bash
|
||||
make cli
|
||||
```
|
||||
|
||||
The cli will be compiled to the build directory `./build/cocos-cli`.
|
||||
|
||||
### Algorithm requirements
|
||||
|
||||
Agent accepts the algorithm as a binary that take in two command line arguments.
|
||||
```shell
|
||||
algorithm-file <unix socket path> <dataset file paths>
|
||||
```
|
||||
|
||||
The algorithm program should return the results to a socket and an example can be seen in this [file](./algo/lin_reg.py).
|
||||
Agent accepts the algorithm as a binary or python or wasm file.
|
||||
All assets/datasets the algorithm uses are stored in the `datasets` directory. The results from the algorithm run should be stored in the `results` directory. All these paths are relative to the algorithm working directory.
|
||||
|
||||
### Agent-CLI interaction
|
||||
|
||||
@@ -32,7 +34,7 @@ sev-snp-measure --mode snp --vcpus 4 --vcpu-type EPYC-v4 --ovmf $OVMF_CODE --ker
|
||||
|
||||
To speed up the verification process of attested TLS, download the ARK and ASK certificates using the CLI tool. The CLI tool will download the certificates under your home directory in the `.cocos` directory.
|
||||
```bash
|
||||
go run cmd/cli/main.go ca-bundle <path/to/platfrom_info.json>
|
||||
./build/cocos-cli ca-bundle <path/to/platfrom_info.json>
|
||||
```
|
||||
|
||||
In the following text, we can see an example of how the CLI tool is used.
|
||||
@@ -52,36 +54,35 @@ cd ../..
|
||||
# The CLI should also be aware of the VM measurement. To add the measurement
|
||||
# to the .json file that contains the information about the platform, run CLI
|
||||
# with the measurement in base64 format and the path of the backend_info.json file.:
|
||||
go run cmd/cli/main.go backend measurement '<measurement>' '<backend_info.json>'
|
||||
./build/cocos-cli backend measurement '<measurement>' '<backend_info.json>'
|
||||
|
||||
# If the VM is booted with the QEMU host data option, the CLI should also know
|
||||
# the host data information. To add the host data to the .json file that contains
|
||||
# the information about the platform, run CLI with the host data in base64 format
|
||||
# and the path of the backend_info.json file.:
|
||||
go run cmd/cli/main.go backend measurement '<host-data>' '<backend_info.json>'
|
||||
./build/cocos-cli backend measurement '<host-data>' '<backend_info.json>'
|
||||
|
||||
# For attested TLS, also define the path to the backend_info.json that contains reference values for the fields of the attestation report
|
||||
export AGENT_GRPC_MANIFEST=./scripts/backend_info/backend_info.json
|
||||
export AGENT_GRPC_ATTESTED_TLS=true
|
||||
|
||||
# Retieve Attestation
|
||||
go run cmd/cli/main.go attestation get '<report_data>'
|
||||
./build/cocos-cli attestation get '<report_data>'
|
||||
|
||||
# Validate Attestation
|
||||
# Product name must be Milan or Genoa
|
||||
go run cmd/cli/main.go attestation validate '<attesation>' --report_data '<report_data>' --product <product_name>
|
||||
./build/cocos-cli attestation validate '<attesation>' --report_data '<report_data>' --product <product_name>
|
||||
|
||||
# Run the CLI program with algorithm input
|
||||
go run cmd/cli/main.go algo test/manual/algo/lin_reg.bin <private_key_file_path>
|
||||
./build/cocos-cli algo test/manual/algo/lin_reg.py <private_key_file_path> -a python -r test/manual/algo/requirements.py
|
||||
# 2023/09/21 10:43:53 Uploading algorithm binary: test/manual/algo/lin_reg.bin
|
||||
|
||||
# Run the CLI program with dataset input
|
||||
go run cmd/cli/main.go data test/manual/data/iris.csv <private_key_file_path>
|
||||
go run cmd/cli/main.go data test/manual/data/iris.csv <private_key_file_path>
|
||||
./build/cocos-cli data test/manual/data/iris.csv <private_key_file_path>
|
||||
# 2023/09/21 10:45:25 Uploading dataset CSV: test/manual/data/iris.csv
|
||||
|
||||
# Run the CLI program to fetch computation result
|
||||
go run cmd/cli/main.go result <private_key_file_path>
|
||||
./build/cocos-cli result <private_key_file_path>
|
||||
# 2023/09/21 10:45:39 Retrieving computation result file
|
||||
# 2023/09/21 10:45:40 Computation result retrieved and saved successfully!
|
||||
```
|
||||
@@ -89,18 +90,12 @@ go run cmd/cli/main.go result <private_key_file_path>
|
||||
Now there is a `result.bin` file in the current working directory. The file holds the trained logistic regression model. To test the model, run
|
||||
|
||||
```sh
|
||||
python3 test/manual/algo/lin_reg_test.py test/manual/data/iris.csv result.bin
|
||||
python ./test/manual/algo/lin_reg.py predict results.zip ./test/manual/data
|
||||
```
|
||||
|
||||
You should get an output (truncated for the sake of brevity):
|
||||
|
||||
```sh
|
||||
Id SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species
|
||||
0 1 5.1 3.5 1.4 0.2 Iris-setosa
|
||||
1 2 4.9 3.0 1.4 0.2 Iris-setosa
|
||||
2 3 4.7 3.2 1.3 0.2 Iris-setosa
|
||||
3 4 4.6 3.1 1.5 0.2 Iris-setosa
|
||||
4 5 5.0 3.6 1.4 0.2 Iris-setosa
|
||||
Precision, Recall, Confusion matrix, in training
|
||||
|
||||
precision recall f1-score support
|
||||
@@ -112,4 +107,23 @@ Iris-versicolor 0.923 0.889 0.906 27
|
||||
accuracy 0.933 75
|
||||
macro avg 0.939 0.938 0.938 75
|
||||
weighted avg 0.934 0.933 0.933 75
|
||||
|
||||
[[21 0 0]
|
||||
[ 0 24 3]
|
||||
[ 0 2 25]]
|
||||
Precision, Recall, Confusion matrix, in testing
|
||||
|
||||
precision recall f1-score support
|
||||
|
||||
Iris-setosa 1.000 1.000 1.000 29
|
||||
Iris-versicolor 1.000 1.000 1.000 23
|
||||
Iris-virginica 1.000 1.000 1.000 23
|
||||
|
||||
accuracy 1.000 75
|
||||
macro avg 1.000 1.000 1.000 75
|
||||
weighted avg 1.000 1.000 1.000 75
|
||||
|
||||
[[29 0 0]
|
||||
[ 0 23 0]
|
||||
[ 0 0 23]]
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ python3 test/manual/algo/lin_reg.py
|
||||
The linear regression example is a more complex algorithm that requires external dependencies.It returns a linear regression model trained on the iris dataset found [here](../data/) for demonstration purposes.
|
||||
|
||||
```bash
|
||||
python3 test/manual/algo/lin_reg.py predict result.zip test/manual/data
|
||||
python3 test/manual/algo/lin_reg.py predict results.zip test/manual/data
|
||||
```
|
||||
|
||||
This will make inference on the results of the linear regression model.
|
||||
@@ -71,7 +71,7 @@ Next we need to upload the dataset
|
||||
After some time when the results are ready, you can run the following command to get the results:
|
||||
|
||||
```bash
|
||||
./build/cocos-cli results ./private.pem
|
||||
./build/cocos-cli result ./private.pem
|
||||
```
|
||||
|
||||
This will return the results of the algorithm.
|
||||
@@ -79,13 +79,13 @@ This will return the results of the algorithm.
|
||||
To make inference on the results, you can use the following command:
|
||||
|
||||
```bash
|
||||
python3 test/manual/algo/lin_reg.py predict result.zip test/manual/data
|
||||
python3 test/manual/algo/lin_reg.py predict results.zip test/manual/data
|
||||
```
|
||||
|
||||
For addition example, you can use the following command:
|
||||
|
||||
```bash
|
||||
go run ./test/computations/main.go ./test/manual/algo/addition.py public.pem false
|
||||
./build/cocos-cli ./test/manual/algo/addition.py public.pem false
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -93,7 +93,7 @@ go run ./test/computations/main.go ./test/manual/algo/addition.py public.pem fal
|
||||
```
|
||||
|
||||
```bash
|
||||
./build/cocos-cli results ./private.pem
|
||||
./build/cocos-cli result ./private.pem
|
||||
```
|
||||
|
||||
## Wasm Example
|
||||
|
||||
Reference in New Issue
Block a user