Write Readme.md for Agent CLI

Signed-off-by: fbugarski <filipbugarski@gmail.com>
This commit is contained in:
fbugarski
2023-08-04 13:19:44 +02:00
parent c2240066f9
commit 1a1785e1c7
5 changed files with 106 additions and 6 deletions
+26 -2
View File
@@ -5,6 +5,8 @@ GOARCH ?= amd64
VERSION ?= $(shell git describe --abbrev=0 --tags)
COMMIT ?= $(shell git rev-parse HEAD)
TIME ?= $(shell date +%F_%T)
CLI_SOURCE = ./cmd/cli/main.go
AGENT_CLI_PATH = ${BUILD_DIR}/agent-cli
define compile_service
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
@@ -17,11 +19,31 @@ endef
.PHONY: all $(SERVICES)
all: $(SERVICES)
$(SERVICES):
$(call compile_service,$(@))
agent-cli: $(CLI_SOURCE)
CGO_ENABLED=$(CGO_ENABLED) GOARCH=$(GOARCH) \
go build -mod=vendor -ldflags "-s -w \
-X 'github.com/ultravioletrs/cocos/internal/http.BuildTime=$(TIME)' \
-X 'github.com/ultravioletrs/cocos/internal/http.Version=$(VERSION)' \
-X 'github.com/ultravioletrs/cocos/internal/http.Commit=$(COMMIT)'" \
-o ${AGENT_CLI_PATH} $(CLI_SOURCE)
install: agent-cli
sudo cp ${AGENT_CLI_PATH} /usr/local/bin
run-computation:
${AGENT_CLI_PATH} run --computation '{"name": "my-computation"}'
upload-algorithm:
${AGENT_CLI_PATH} algorithm /path/to/algorithm
upload-dataset:
${AGENT_CLI_PATH} dataset path/to/dataset.csv
retrieve-result:
${AGENT_CLI_PATH} result
QCOW2_PATH = ~/go/src/github.com/ultravioletrs/manager/cmd/manager/img/boot.img
@@ -49,3 +71,5 @@ copy-agent-rc-sh:
protoc:
protoc -I. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative agent/agent.proto
+77 -1
View File
@@ -1,11 +1,87 @@
# Agent CLI
This repository contains the command-line interface (CLI) tool for interacting with the UltraVioletrs Agent service. The CLI allows you to perform various tasks such as running computations, uploading algorithms and datasets, and retrieving results.
## Build
From the project root:
```bash
make cli
make agent-cli
```
## Usage
#### Run Computation
To run a computation, use the following command:
```bash
./build/agent-cli run --computation '{"name": "my-computation"}'
```
#### Upload Algorithm
To upload an algorithm, use the following command:
```bash
./build/agent-cli algorithm /path/to/algorithm
```
#### Upload Dataset
To upload a dataset, use the following command:
```bash
./build/agent-cli dataset /path/to/dataset.csv
```
#### Retrieve result
To retrieve the computation result, use the following command:
```bash
./build/agent-cli result
```
## Installtion
If you want to install the CLI globally, you can use the following command:
```bash
sudo cp build/agent-cli /usr/local/bin/
```
This will make the agent-cli executable available from any location in your terminal.
#### Run Computation
To run a computation, use the following command:
```bash
agent-cli run --computation '{"name": "my-computation"}'
```
#### Upload Algorithm
To upload an algorithm, use the following command:
```bash
agent-cli algorithm /path/to/algorithm
```
#### Upload Dataset
To upload a dataset, use the following command:
```bash
agent-cli dataset /path/to/dataset.csv
```
#### Retrieve result
To retrieve the computation result, use the following command:
```bash
agent-cli result
```
+1 -1
View File
@@ -9,7 +9,7 @@ import (
func NewAlgorithmsCmd(sdk agentsdk.SDK) *cobra.Command {
return &cobra.Command{
Use: "upload-algorithm",
Use: "algorithm",
Short: "Upload an algorithm binary",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
+1 -1
View File
@@ -9,7 +9,7 @@ import (
func NewDatasetsCmd(sdk agentsdk.SDK) *cobra.Command {
return &cobra.Command{
Use: "upload-dataset",
Use: "dataset",
Short: "Upload a dataset CSV file",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
+1 -1
View File
@@ -10,7 +10,7 @@ import (
func NewResultsCmd(sdk agentsdk.SDK) *cobra.Command {
return &cobra.Command{
Use: "retrieve-result",
Use: "result",
Short: "Retrieve computation result file",
Run: func(cmd *cobra.Command, args []string) {
log.Println("Retrieving computation result file")