Skip to content

Commit

Permalink
Snake case payloads (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
adelinag08 authored May 24, 2024
1 parent de84ddb commit bebc038
Show file tree
Hide file tree
Showing 33 changed files with 436 additions and 190 deletions.
2 changes: 1 addition & 1 deletion docs/snd.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ SnD CLI is a tool for interacting with various internal and external services in
* [snd upgrade](snd_upgrade.md) - Upgrade the CLI to the latest version
* [snd version](snd_version.md) - Print the version number of the SnD CLI.

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
35 changes: 21 additions & 14 deletions docs/snd_algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,28 @@ The payload should be provided as a JSON file with the structure below.

<pre><code>
{
"AlgorithmName": "<string> (optional) - The name of the algorithm to run",
"AlgorithmParameters": "<object> (required) - Any additional parameters for the algorithm",
"CustomConfiguration": {
"imageRepository": "",
"imageTag": "",
"deadlineSeconds": 123,
"maximumRetries": 1,
"cpuLimit": "",
"memoryLimit": "",
"monitoringParameters": [],
"speculativeAttempts": 2,
}, - <CustomConfiguration> (optional) - Custom configuration for the algorithm",
"Tag": "<string> (optional) - Client-side submission identifier"
"algorithm_name": "&lt;string&gt; (optional) - The name of the algorithm to run",
"algorithm_parameters": "&lt;object&gt; (required) - Any additional parameters for the algorithm",
"custom_configuration": {
"image_repository": &lt;string&gt;,
"image_tag": &lt;string&gt;,
"deadline_seconds": &lt;int&gt;,
"maximum_retries": &lt;int&gt;,
"env": {"name": &lt;string&gt;, "value": &lt;string&gt;, "value_from": "PLAIN" | "RELATIVE_REFERENCE"}
"secrets": &lt;string[]&gt;,
"args": {"name": &lt;string&gt;, "value": &lt;string&gt;, "value_from": "PLAIN" | "RELATIVE_REFERENCE"},
"cpu_limit": &lt;string&gt;,
"memory_limit": &lt;string&gt;,
"workgroup": &lt;string&gt;,
"additional_workgroups": &lt;map[string]string&gt;,
"version": &lt;string&gt;,
"monitoring_parameters": &lt;string[]&gt;,
"custom_resources": &lt;map[string]string&gt;,
"speculative_attempts": int
} - &lt;CustomConfiguration&gt; (optional) - Custom configuration for the algorithm",
"tag": "&lt;string&gt; (optional) - Client-side submission identifier"
}
</code></pre>


###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_algorithm_cancel.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ snd algorithm cancel --id 762b07c-c67a-4327-970a-18d923fd --algorithm rdc-auto-r

* [snd algorithm](snd_algorithm.md) - Manage ML algorithm jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_algorithm_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ snd algorithm get --id 762b07c-c67a-4327-970a-18d923fd --algorithm rdc-auto-repl

* [snd algorithm](snd_algorithm.md) - Manage ML algorithm jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_algorithm_payload.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ snd algorithm payload --id 762b07c-c67a-4327-970a-18d923fd --algorithm rdc-auto-

* [snd algorithm](snd_algorithm.md) - Manage ML algorithm jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
35 changes: 21 additions & 14 deletions docs/snd_algorithm_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@ The payload should be provided as a JSON file with the structure below.

<pre><code>
{
"AlgorithmName": "<string> (optional) - The name of the algorithm to run",
"AlgorithmParameters": "<object> (required) - Any additional parameters for the algorithm",
"CustomConfiguration": {
"imageRepository": "",
"imageTag": "",
"deadlineSeconds": 123,
"maximumRetries": 1,
"cpuLimit": "",
"memoryLimit": "",
"monitoringParameters": [],
"speculativeAttempts": 2,
}, - <CustomConfiguration> (optional) - Custom configuration for the algorithm",
"Tag": "<string> (optional) - Client-side submission identifier"
"algorithm_name": "&lt;string&gt; (optional) - The name of the algorithm to run",
"algorithm_parameters": "&lt;object&gt; (required) - Any additional parameters for the algorithm",
"custom_configuration": {
"image_repository": &lt;string&gt;,
"image_tag": &lt;string&gt;,
"deadline_seconds": &lt;int&gt;,
"maximum_retries": &lt;int&gt;,
"env": {"name": &lt;string&gt;, "value": &lt;string&gt;, "value_from": "PLAIN" | "RELATIVE_REFERENCE"}
"secrets": &lt;string[]&gt;,
"args": {"name": &lt;string&gt;, "value": &lt;string&gt;, "value_from": "PLAIN" | "RELATIVE_REFERENCE"},
"cpu_limit": &lt;string&gt;,
"memory_limit": &lt;string&gt;,
"workgroup": &lt;string&gt;,
"additional_workgroups": &lt;map[string]string&gt;,
"version": &lt;string&gt;,
"monitoring_parameters": &lt;string[]&gt;,
"custom_resources": &lt;map[string]string&gt;,
"speculative_attempts": int
} - &lt;CustomConfiguration&gt; (optional) - Custom configuration for the algorithm",
"tag": "&lt;string&gt; (optional) - Client-side submission identifier"
}
</code></pre>

Expand Down Expand Up @@ -55,4 +62,4 @@ snd algorithm run --algorithm rdc-auto-replenishment-crystal-orchestrator --payl

* [snd algorithm](snd_algorithm.md) - Manage ML algorithm jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_claim.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ $ snd claim user remove --claims-provider azuread --user test@ecco.com
* [snd claim remove](snd_claim_remove.md) - Removes a claim from an existing user
* [snd claim user](snd_claim_user.md) - Manage (add/remove) a user

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_claim_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ snd claim add -c "service.test.sneaksanddata.com/.*:.*" -u user@ecco.com --claim

* [snd claim](snd_claim.md) - Manage claims

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_claim_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ snd claim get -u user@ecco.com --claims-provider azuread

* [snd claim](snd_claim.md) - Manage claims

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_claim_remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ snd claim remove -c "service.test.sneaksanddata.com/.*:.*" -u user@ecco.com --cl

* [snd claim](snd_claim.md) - Manage claims

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_claim_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ Manage (add/remove) a user
* [snd claim user add](snd_claim_user_add.md) - Add a user
* [snd claim user remove](snd_claim_user_remove.md) - Remove a user

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_claim_user_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ snd claim user add -u user@ecco.com --claims-provider azuread

* [snd claim user](snd_claim_user.md) - Manage (add/remove) a user

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_claim_user_remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ snd claim user remove -u user@ecco.com --claims-provider azuread

* [snd claim user](snd_claim_user.md) - Manage (add/remove) a user

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ $ snd login --auth-provider azuread --env production

* [snd](snd.md) - SnD CLI

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
24 changes: 12 additions & 12 deletions docs/snd_spark.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,25 @@ If 'extraArguments', 'projectInputs', 'projectOutputs', or 'expectedParallelism'

<pre><code>
{
"clientTag": "<string> - A tag for the client making the submission",
"extraArguments": "<object> - Any additional arguments for the job",
"projectInputs": [{
"alias": "<string> - An alias for the input",
"dataPath": "<string> - The path to the input data",
"dataFormat": "<string> - The format of the input data"
"client_tag": "&lt;string&gt; - A tag for the client making the submission",
"extra_arguments": "&lt;object&gt; - Any additional arguments for the job",
"project_inputs": [{
"alias": "&lt;string&gt; - An alias for the input",
"data_path": "&lt;string&gt; - The path to the input data",
"data_format": "&lt;string&gt; - The format of the input data"
}
// More input objects can be added here
],
"projectOutputs": [{
"alias": "<string> - An alias for the output",
"dataPath": "<string> - The path where the output data should be stored",
"dataFormat": "<string> - The format of the output data"
"project_outputs": [{
"alias": "&lt;string&gt; - An alias for the output",
"data_path": "&lt;string&gt; - The path where the output data should be stored",
"data_format": "&lt;string&gt; - The format of the output data"
}
// More output objects can be added here
],
"expectedParallelism": "<integer> - The expected level of parallelism for the job"
"expected_parallelism": "&lt;integer&gt; - The expected level of parallelism for the job"
}
</code></pre>


###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_spark_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ snd spark configuration --name common-kit-hive-publish

* [snd spark](snd_spark.md) - Manage Spark jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_spark_encrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ snd spark encrypt [flags]

* [snd spark](snd_spark.md) - Manage Spark jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_spark_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ snd spark logs --id 14abbec-e517-4135-bf01-fc041a4e

* [snd spark](snd_spark.md) - Manage Spark jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_spark_request-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ snd spark request-status --id 14abbec-e517-4135-bf01-fc041a4e

* [snd spark](snd_spark.md) - Manage Spark jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_spark_runtime-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ snd spark runtime-info --id 14abbec-e517-4135-bf01-fc041a4e

* [snd spark](snd_spark.md) - Manage Spark jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
24 changes: 12 additions & 12 deletions docs/snd_spark_submit.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ If 'extraArguments', 'projectInputs', 'projectOutputs', or 'expectedParallelism'

<pre><code>
{
"clientTag": "<string> - A tag for the client making the submission",
"extraArguments": "<object> - Any additional arguments for the job",
"projectInputs": [{
"alias": "<string> - An alias for the input",
"dataPath": "<string> - The path to the input data",
"dataFormat": "<string> - The format of the input data"
"client_tag": "&lt;string&gt; - A tag for the client making the submission",
"extra_arguments": "&lt;object&gt; - Any additional arguments for the job",
"project_inputs": [{
"alias": "&lt;string&gt; - An alias for the input",
"data_path": "&lt;string&gt; - The path to the input data",
"data_format": "&lt;string&gt; - The format of the input data"
}
// More input objects can be added here
],
"projectOutputs": [{
"alias": "<string> - An alias for the output",
"dataPath": "<string> - The path where the output data should be stored",
"dataFormat": "<string> - The format of the output data"
"project_outputs": [{
"alias": "&lt;string&gt; - An alias for the output",
"data_path": "&lt;string&gt; - The path where the output data should be stored",
"data_format": "&lt;string&gt; - The format of the output data"
}
// More output objects can be added here
],
"expectedParallelism": "<integer> - The expected level of parallelism for the job"
"expected_parallelism": "&lt;integer&gt; - The expected level of parallelism for the job"
}
</code></pre>

Expand Down Expand Up @@ -58,4 +58,4 @@ snd spark submit [flags]

* [snd spark](snd_spark.md) - Manage Spark jobs

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ snd upgrade [flags]

* [snd](snd.md) - SnD CLI

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
2 changes: 1 addition & 1 deletion docs/snd_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ snd version [flags]

* [snd](snd.md) - SnD CLI

###### Auto generated by spf13/cobra on 15-May-2024
###### Auto generated by spf13/cobra on 16-May-2024
11 changes: 11 additions & 0 deletions pkg/cmd/ml/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ func NewCmdCancel(authServiceFactory *cmdutil.AuthServiceFactory, serviceFactory
fmt.Println("failed to mark 'id' as a required flag: %w", err)
return nil
}
err = cmd.MarkFlagRequired("initiator")
if err != nil {
fmt.Println("failed to mark 'initiator' as a required flag: %w", err)
return nil
}

err = cmd.MarkFlagRequired("reason")
if err != nil {
fmt.Println("failed to mark 'reason' as a required flag: %w", err)
return nil
}

return cmd
}
Expand Down
81 changes: 81 additions & 0 deletions pkg/cmd/ml/payload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package ml

import (
"encoding/json"
algorithmClient "github.com/SneaksAndData/esd-services-api-client-go/algorithm"
)

// Payload defines the structure of the request body for creating algorithm runs.
type Payload struct {
AlgorithmParameters map[string]interface{} `validate:"required" json:"algorithm_parameters"`
AlgorithmName string `json:"algorithm_name"`
CustomConfiguration CustomConfiguration `json:"custom_configuration"`
Tag string `json:"tag"`
}

func (p Payload) MarshalJSON() ([]byte, error) {
type T struct {
AlgorithmParameters map[string]interface{} `validate:"required" json:"AlgorithmParameters"`
AlgorithmName string `json:"AlgorithmName"`
CustomConfiguration CustomConfiguration `json:"CustomConfiguration"`
Tag string `json:"Tag"`
}

return json.Marshal(T(p))
}

type CustomConfiguration struct {
ImageRepository *string `json:"image_repository"`
ImageTag *string `json:"image_tag"`
DeadlineSeconds *int `json:"deadline_seconds"`
MaximumRetries *int `json:"maximum_retries"`
Env []ConfigurationEntry `json:"env"`
Secrets []string `json:"secrets"`
Args []ConfigurationEntry `json:"args"`
CpuLimit *string `json:"cpu_limit"`
MemoryLimit *string `json:"memory_limit"`
Workgroup *string `json:"workgroup"`
AdditionalWorkgroups map[string]string `json:"additional_workgroups"`
Version *string `json:"version"`
MonitoringParameters []string `json:"monitoring_parameters"`
CustomResources map[string]string `json:"custom_resources"`
SpeculativeAttempts *int `json:"speculative_attempts"`
}

func (c CustomConfiguration) MarshalJSON() ([]byte, error) {
type T struct {
ImageRepository *string `json:"imageRepository"`
ImageTag *string `json:"imageTag"`
DeadlineSeconds *int `json:"deadlineSeconds"`
MaximumRetries *int `json:"maximumRetries"`
Env []ConfigurationEntry `json:"env"`
Secrets []string `json:"secrets"`
Args []ConfigurationEntry `json:"args"`
CpuLimit *string `json:"cpuLimit"`
MemoryLimit *string `json:"memoryLimit"`
Workgroup *string `json:"workgroup"`
AdditionalWorkgroups map[string]string `json:"additionalWorkgroups"`
Version *string `json:"version"`
MonitoringParameters []string `json:"monitoringParameters"`
CustomResources map[string]string `json:"customResources"`
SpeculativeAttempts *int `json:"speculativeAttempts"`
}

return json.Marshal(T(c))
}

type ConfigurationEntry struct {
Name string `json:"name"`
Value string `json:"value"`
ValueType *algorithmClient.ConfigurationValueType `json:"value_from"`
}

func (c ConfigurationEntry) MarshalJSON() ([]byte, error) {
type T struct {
Name string `json:"name"`
Value string `json:"value"`
ValueType *algorithmClient.ConfigurationValueType `json:"valueFrom"`
}

return json.Marshal(T(c))
}
Loading

0 comments on commit bebc038

Please sign in to comment.