Skip to content

Commit

Permalink
Merge pull request #41 from WashingtonKK/updateAlgoArgs
Browse files Browse the repository at this point in the history
NOISSUE: Add Documentation for Running Algo with Args
  • Loading branch information
drasko authored Sep 11, 2024
2 parents 9102684 + 03510b2 commit 66171a2
Showing 1 changed file with 61 additions and 2 deletions.
63 changes: 61 additions & 2 deletions docs/algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ MANAGER_QEMU_OVMF_VARS_FILE=/usr/share/edk2/x64/OVMF_VARS.fd \
go run main.go
```

Export the agent grpc url from computation server logs
Export the agent grpc url from computation server logs, by default port 6100 will be allocated. If the port is not available, a different (random) port will be allocated, within the range 6100 - 6200. The port will be indicated on the computation server logs.

```bash
export AGENT_GRPC_URL=localhost:6066
export AGENT_GRPC_URL=localhost:6100
```

Upload the algorithm
Expand Down Expand Up @@ -478,6 +478,65 @@ Terminal recording session

For real-world examples to test with cocos, see our [AI repository](https://github.com/ultravioletrs/ai).

## Running Algorithms with arguments

To run an algorithm that requires command line arguments, you can append the algo command on cli with the arguments needed as shown in the addition example, which we will run with args below:

NOTE: Make sure you have terminated the previous computation before starting a new one.

Start the computation server:

```bash
go run ./test/computations/main.go ./test/manual/algo/addition.py public.pem false
```

Start the manager

```bash
sudo \
MANAGER_QEMU_SMP_MAXCPUS=4 \
MANAGER_GRPC_URL=localhost:7001 \
MANAGER_LOG_LEVEL=debug \
MANAGER_QEMU_ENABLE_SEV_SNP=false \
MANAGER_QEMU_OVMF_CODE_FILE=/usr/share/edk2/x64/OVMF_CODE.fd \
MANAGER_QEMU_OVMF_VARS_FILE=/usr/share/edk2/x64/OVMF_VARS.fd \
go run main.go
```

Export the agent grpc url from computation server logs, by default port 6100 will be allocated. If the port is not available, a different (random) port will be allocated, within the range 6100 - 6200. The port will be indicated on the computation server logs.

```bash
export AGENT_GRPC_URL=localhost:6100
```

Upload the algorithm

```bash
./build/cocos-cli algo ./test/manual/algo/addition.py ./private.pem -a python --args="--a" --args="100" --args="--b" --args="20"
```

The order and args of the algorithm should be as they are required by the algorithm. In the addition example, for instance, the args are set in order of how they are expected:

```bash
python3 addition.py --a 100 --b 200
```

Watch the agent logs until the computation is complete.

```bash
&{event_type:"algorithm-run" timestamp:{seconds:1723411516 nanos:935138750} computation_id:"1" originator:"agent" status:"error"}
received agent event
&{event_type:"resultsReady" timestamp:{seconds:1723411517 nanos:882446542} computation_id:"1" originator:"agent" status:"in-progress"}
received agent log
&{message:"Transition: resultsReady -> resultsReady\n" computation_id:"1" level:"DEBUG" timestamp:{seconds:1723411517 nanos:882432675}}
```

Finally, download the results

```bash
./build/cocos-cli result ./private.pem
```

## Docker

Docker is a platform designed to build, share, and run containerized applications. A container packages the application code, runtime, system tools, libraries, and all necessary settings into a single unit. This ensures the container can be reliably transferred between different computing environments and be executed as expected.
Expand Down

0 comments on commit 66171a2

Please sign in to comment.