Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove createCalculation() #10

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CLI tool for ccb-operator

```
Examples of usage:
ccboc --teff=10000 --logG=4.0 create (Creates a calculation with teff=10000 and LogG=4.0)
ccboc get calculation calc-1881i9dh5zvnllip (Gets the calculation with id='calc-1881i9dh5zvnllip')
ccboc get calculations (Gets all active calculations)
ccboc --teff=10000 --logG=4.0 get results (Downloads the result of a calculation with teff=10000 and LogG=4.0)
Expand All @@ -19,7 +18,7 @@ Usage:

Available Commands:
completion generate the autocompletion script for the specified shell
create Creates a calculation/bulks in the cluster.
create Create a bulk in the cluster.
get Get an object - calculation/bulk/workerpool.
help Help about any command
login Login to api server using the provided url and token. Also it generates the configuration file (default path is $HOME/.config/ccbo/config)
Expand All @@ -28,5 +27,4 @@ Flags:
-h, --help help for ccboc

Use "ccboc [command] --help" for more information about a command.

```
22 changes: 0 additions & 22 deletions cmd/ccboc/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,28 +333,6 @@ func createCalculationBulk() error {
return nil
}

func createCalculation() error {
if teff == 0 || logG == 0 {
return fmt.Errorf("--teff and --logG must specified together")
}

jsonData := fmt.Sprintf("{\"teff\": \"%0.1f\", \"logG\": \"%0.1f\"}", teff, logG)
body, responseError, err := request("POST", globalConfig.APIURL+"/calculations/create", bytes.NewBuffer([]byte(jsonData)))
if err != nil {
return err
} else if responseError != nil {
logrus.WithFields(logrus.Fields{"message": responseError.Message, "status_code": responseError.StatusCode}).Fatal("errors occurred")
}

var calc *calculationsv1.Calculation
if err := json.Unmarshal(body, &calc); err != nil {
return err
}

fmt.Printf("Calculation created: %s\n", calc.Name)
return nil
}

func request(method, endpoint string, buffer *bytes.Buffer) ([]byte, *errorResponse, error) {
req, err := http.NewRequest(method, endpoint, buffer)
if err != nil {
Expand Down
18 changes: 1 addition & 17 deletions cmd/ccboc/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var (
Use: "ccboc",
Short: "CLI tool for integrating with the active calculations by communicating with the API server (see https://github.com/vega-project/ccb-operator/tree/master/cmd/apiserver)",
Long: "Examples of usage:" + "\n" +
"ccboc --teff=10000 --logG=4.0 create (Creates a calculation with teff=10000 and LogG=4.0)\n" +
"ccboc get calculation calc-1881i9dh5zvnllip (Gets the calculation with id='calc-1881i9dh5zvnllip')\n" +
"ccboc get calculations (Gets all active calculations)\n" +
"ccboc --teff=10000 --logG=4.0 get results (Downloads the result of a calculation with teff=10000 and LogG=4.0)\n" +
Expand Down Expand Up @@ -108,22 +107,10 @@ var (

createCmd = &cobra.Command{
Use: "create",
Short: "Creates a calculation/bulks in the cluster.",
Short: "Create a bulk in the cluster.",
TraverseChildren: true,
}

createCalcCmd = &cobra.Command{
Use: "calculation",
Short: "Create a calculation in the cluster with specified logG and teff values.",
Run: func(cmd *cobra.Command, args []string) {
initializeConfig()
err := createCalculation()
if err != nil {
logrus.WithError(err).Fatal("create calculation command failed")
}
},
}

createBulkCmd = &cobra.Command{
Use: "bulk",
Short: "Creates a calculation bulk in the cluster using a .json file.",
Expand Down Expand Up @@ -192,9 +179,6 @@ func init() {
resultsCmd.Flags().StringVar(&path, "results-download-path", "", "Specified path to download the calculation to.")

rootCmd.AddCommand(createCmd)
createCmd.AddCommand(createCalcCmd)
createCalcCmd.Flags().Float64Var(&teff, "teff", 0.0, "Teff value to create a calculation.")
createCalcCmd.Flags().Float64Var(&logG, "logG", 0.0, "LogG value to create a calculation.")

createCmd.AddCommand(createBulkCmd)
createBulkCmd.Flags().StringVar(&bulkFile, "bulk-file", "", "File in .json format to create a calculation bulk.")
Expand Down