mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-08-07 07:14:50 +00:00
046b549079
The HTTP server-related code, documentation, and configurations have been removed as part of a shift towards prioritizing gRPC for service communication. This update includes deletions of HTTP host and port configs across various components, the manager HTTP API alongside its Swagger definition, and the removal of related scaffolding and utility code. This change simplifies the overall architecture and eliminates redundant HTTP support, focusing on optimizing gRPC performance and security features. Signed-off-by: SammyOina <sammyoina@gmail.com>
59 lines
1.6 KiB
Go
59 lines
1.6 KiB
Go
// Copyright (c) Ultraviolet
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
package cli
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/ultravioletrs/cocos/agent"
|
|
"github.com/ultravioletrs/cocos/manager"
|
|
)
|
|
|
|
func (cli *CLI) NewRunCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "run",
|
|
Short: "Upload a computation manifest json",
|
|
Example: "run '<computation>'",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
computationStr := args[0]
|
|
|
|
var cmp agent.Computation
|
|
if err := json.Unmarshal([]byte(computationStr), &cmp); err != nil {
|
|
log.Fatalf("Error unmarshling computation json: %v", err)
|
|
}
|
|
|
|
req := manager.Computation{
|
|
Id: cmp.ID,
|
|
Description: cmp.Description,
|
|
Name: cmp.Name,
|
|
ResultConsumers: cmp.ResultConsumers,
|
|
AgentConfig: &manager.AgentConfig{
|
|
Port: cmp.AgentConfig.Port,
|
|
Host: cmp.AgentConfig.Host,
|
|
CertFile: cmp.AgentConfig.CertFile,
|
|
KeyFile: cmp.AgentConfig.KeyFile,
|
|
LogLevel: cmp.AgentConfig.LogLevel,
|
|
},
|
|
}
|
|
|
|
for _, data := range cmp.Datasets {
|
|
req.Datasets = append(req.Datasets, &manager.Dataset{Id: data.ID, Provider: data.Provider})
|
|
}
|
|
|
|
for _, algo := range cmp.Algorithms {
|
|
req.Algorithms = append(req.Algorithms, &manager.Algorithm{Id: algo.ID, Provider: algo.Provider})
|
|
}
|
|
|
|
response, err := cli.managerSDK.Run(cmd.Context(), &req)
|
|
if err != nil {
|
|
log.Fatalf("Error running computation: %v", err)
|
|
}
|
|
|
|
log.Printf("Successfully run computation, agent address: %v", response)
|
|
},
|
|
}
|
|
}
|