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

Adding support for experiments in the CLI. #159

Merged
merged 14 commits into from
Nov 9, 2018
Merged
Prev Previous commit
Next Next commit
Adding integrations test for the CLI commands related to pipelines.
  • Loading branch information
vicaire committed Nov 7, 2018
commit 425403ae8393742b3ce685a74dbda5f60826d076
19 changes: 19 additions & 0 deletions backend/src/cmd/ml/cmd/client_factory.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"bytes"
"io"
"os"

Expand All @@ -20,10 +21,12 @@ type ClientFactoryInterface interface {
client.RunInterface, error)
Time() util.TimeInterface
Writer() io.Writer
Result() string
}

type ClientFactory struct {
time util.TimeInterface
buffer *bytes.Buffer
writer io.Writer
}

Expand All @@ -34,6 +37,15 @@ func NewClientFactory() *ClientFactory {
}
}

func NewClientFactoryWithByteBuffer() *ClientFactory {
buffer := new(bytes.Buffer)
return &ClientFactory{
time: util.NewRealTime(),
buffer: buffer,
writer: buffer,
}
}

func (f *ClientFactory) CreatePipelineUploadClient(config clientcmd.ClientConfig, debug bool) (
client.PipelineUploadInterface, error) {
return client.NewPipelineUploadClient(config, debug)
Expand Down Expand Up @@ -61,3 +73,10 @@ func (f *ClientFactory) Time() util.TimeInterface {
func (f *ClientFactory) Writer() io.Writer {
return f.writer
}

func (f *ClientFactory) Result() string {
if f.buffer == nil {
return "The writer is set to 'os.Stdout'. The result is not recorded."
}
return (*f.buffer).String()
}
2 changes: 1 addition & 1 deletion backend/src/cmd/ml/cmd/client_factory_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (f *ClientFactoryFake) Result() string {
return (*f.buffer).String()
}

func getFakeRootCommand() (*RootCommand, *ClientFactoryFake) {
func GetFakeRootCommand() (*RootCommand, *ClientFactoryFake) {
factory := NewClientFactoryFake()
rootCmd := NewRootCmd(factory)
rootCmd = CreateSubCommands(rootCmd, 10)
Expand Down
12 changes: 6 additions & 6 deletions backend/src/cmd/ml/cmd/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func NewJobCreateCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), job)
PrettyPrintResult(root.Writer(), root.OutputFormat(), job)
return nil
},
}
Expand Down Expand Up @@ -223,7 +223,7 @@ func NewJobGetCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), pkg)
PrettyPrintResult(root.Writer(), root.OutputFormat(), pkg)
return nil
},
}
Expand Down Expand Up @@ -259,7 +259,7 @@ func NewJobListCmd(root *RootCommand, pageSize int32) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), results)
PrettyPrintResult(root.Writer(), root.OutputFormat(), results)
return nil
},
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func NewJobEnableCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), "")
PrettyPrintResult(root.Writer(), root.OutputFormat(), "")
return nil
},
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func NewJobDisableCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), "")
PrettyPrintResult(root.Writer(), root.OutputFormat(), "")
return nil
},
}
Expand Down Expand Up @@ -354,7 +354,7 @@ func NewJobDeleteCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), "")
PrettyPrintResult(root.Writer(), root.OutputFormat(), "")
return nil
},
}
Expand Down
Loading