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

Add resource generic load, unload, status to CLI #4660

Merged
merged 2 commits into from
Feb 14, 2023
Merged

Add resource generic load, unload, status to CLI #4660

merged 2 commits into from
Feb 14, 2023

Conversation

ukclivecox
Copy link
Contributor

@ukclivecox ukclivecox commented Feb 13, 2023

  • Allow generic load, unload, status from stream or file

Examples:
Run kustomize to create a set of Seldon Core V2 artifacts and pipe to load:

kustomize build config | seldon load

Also, wait for a set of resources to be ready

kustomize build config | seldon status -w

A future PR can also allow for -f to take a folder rather than a file like kubectl.

}
return "", "", nil, false, err
}
// Get the resource kind nad original bytes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Get the resource kind nad original bytes
// Get the resource kind and original bytes

return dec
}

func getNextResource(dec *yaml2.YAMLOrJSONDecoder) (string, string, []byte, bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many returns and it is hard to know what we are getting back. Consider adding at least description.

"os"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
yaml2 "k8s.io/apimachinery/pkg/util/yaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it have to be yaml2?

func (sc *SchedulerClient) Load(data []byte, showRequest bool, showResponse bool) error {
dec := createDecoder(data)
for {
kind, _, data, keepGoing, err := getNextResource(dec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are also not checking err before the switch

if !keepGoing {
return err
}
switch kind {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a warning if it is not part of these 3 resources? should we stop?

func (sc *SchedulerClient) Unload(data []byte, showRequest bool, showResponse bool) error {
dec := createDecoder(data)
for {
kind, _, data, keepGoing, err := getNextResource(dec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}
err = sc.PipelineStatus(name, showRequest, showResponse, waitCondition)
case "Experiment":
err = sc.ExperimentStatus(name, showRequest, showResponse, wait)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no wait on Experiments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bool is passed directly to function - experiments don't take a string waitCondition

}
waitCondition := ""
switch kind {
case "Model":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider extracting the values of the switch into enum as it is used in 3 different places already.

operator/cmd/seldon/cli/unload.go Show resolved Hide resolved
var rootCmd = &cobra.Command{Use: "seldon", SilenceErrors: false, SilenceUsage: true}

rootCmd.DisableAutoGenTag = true

rootCmd.AddCommand(cmdModel, cmdServer, cmdExperiment, cmdPipeline, cmdConfig)
rootCmd.AddCommand(cmdModel, cmdServer, cmdExperiment, cmdPipeline, cmdConfig, cmdLoad, cmdUnload, cmdStatus)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to keep consistency with previous usage (i.e. seldon model load and seldon pipeline load), an alternative is perhaps to use
seldon all load? I am personally not entirely sure which approach is better so happy to leave it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems a bit verbose - maybe will leave for now

Copy link
Member

@sakoush sakoush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ukclivecox ukclivecox merged commit cba1c07 into SeldonIO:v2 Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants