mirror of https://github.com/databricks/cli.git
Move and hide launch and test commands (#222)
Semantics in the context of a bundle are not yet clearly defined. Moving and hiding these commands until then.
This commit is contained in:
parent
f0c35a2b27
commit
46cfa747ac
|
@ -0,0 +1,37 @@
|
||||||
|
package bundle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/databricks/bricks/cmd/root"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var launchCmd = &cobra.Command{
|
||||||
|
Use: "launch",
|
||||||
|
Short: "Launches a notebook on development cluster",
|
||||||
|
Long: `Reads a file and executes it on dev cluster`,
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
|
||||||
|
// We're not ready to expose this command until we specify its semantics.
|
||||||
|
Hidden: true,
|
||||||
|
|
||||||
|
PreRunE: root.MustConfigureBundle,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
return fmt.Errorf("TODO")
|
||||||
|
// contents, err := os.ReadFile(args[0])
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// results := project.RunPythonOnDev(cmd.Context(), string(contents))
|
||||||
|
// if results.Failed() {
|
||||||
|
// return results.Err()
|
||||||
|
// }
|
||||||
|
// fmt.Fprintf(cmd.OutOrStdout(), "Success: %s", results.Text())
|
||||||
|
// return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
AddCommand(launchCmd)
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package bundle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/databricks/bricks/cmd/root"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var testCmd = &cobra.Command{
|
||||||
|
Use: "test",
|
||||||
|
Short: "run tests for the project",
|
||||||
|
Long: `This is longer description of the command`,
|
||||||
|
|
||||||
|
// We're not ready to expose this command until we specify its semantics.
|
||||||
|
Hidden: true,
|
||||||
|
|
||||||
|
PreRunE: root.MustConfigureBundle,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
return fmt.Errorf("TODO")
|
||||||
|
// results := project.RunPythonOnDev(cmd.Context(), `return 1`)
|
||||||
|
// if results.Failed() {
|
||||||
|
// return results.Err()
|
||||||
|
// }
|
||||||
|
// fmt.Fprintf(cmd.OutOrStdout(), "Success: %s", results.Text())
|
||||||
|
// return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
AddCommand(testCmd)
|
||||||
|
}
|
|
@ -1,36 +0,0 @@
|
||||||
package launch
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/databricks/bricks/cmd/root"
|
|
||||||
"github.com/databricks/bricks/project"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
// launchCmd represents the launch command
|
|
||||||
var launchCmd = &cobra.Command{
|
|
||||||
Use: "launch",
|
|
||||||
Short: "Launches a notebook on development cluster",
|
|
||||||
Long: `Reads a file and executes it on dev cluster`,
|
|
||||||
Args: cobra.ExactArgs(1),
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
contents, err := os.ReadFile(args[0])
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
results := project.RunPythonOnDev(cmd.Context(), string(contents))
|
|
||||||
if results.Failed() {
|
|
||||||
log.Fatal(results.Error())
|
|
||||||
}
|
|
||||||
fmt.Println(results.Text())
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
// TODO: detect if we can skip registering
|
|
||||||
// launch command for DBSQL projects
|
|
||||||
root.RootCmd.AddCommand(launchCmd)
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/databricks/bricks/cmd/root"
|
|
||||||
"github.com/databricks/bricks/project"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
// testCmd represents the test command
|
|
||||||
var testCmd = &cobra.Command{
|
|
||||||
Use: "test",
|
|
||||||
Short: "run tests for the project",
|
|
||||||
Long: `This is longer description of the command`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
results := project.RunPythonOnDev(cmd.Context(), `return 1`)
|
|
||||||
if results.Failed() {
|
|
||||||
log.Fatal(results.Error())
|
|
||||||
}
|
|
||||||
log.Printf("Success: %s", results.Text())
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
root.RootCmd.AddCommand(testCmd)
|
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
|
||||||
|
|
||||||
// Cobra supports Persistent Flags which will work for this command
|
|
||||||
// and all subcommands, e.g.:
|
|
||||||
// testCmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
||||||
|
|
||||||
// Cobra supports local flags which will only run when this command
|
|
||||||
// is called directly, e.g.:
|
|
||||||
// testCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
||||||
}
|
|
2
main.go
2
main.go
|
@ -9,10 +9,8 @@ import (
|
||||||
_ "github.com/databricks/bricks/cmd/configure"
|
_ "github.com/databricks/bricks/cmd/configure"
|
||||||
_ "github.com/databricks/bricks/cmd/fs"
|
_ "github.com/databricks/bricks/cmd/fs"
|
||||||
_ "github.com/databricks/bricks/cmd/init"
|
_ "github.com/databricks/bricks/cmd/init"
|
||||||
_ "github.com/databricks/bricks/cmd/launch"
|
|
||||||
"github.com/databricks/bricks/cmd/root"
|
"github.com/databricks/bricks/cmd/root"
|
||||||
_ "github.com/databricks/bricks/cmd/sync"
|
_ "github.com/databricks/bricks/cmd/sync"
|
||||||
_ "github.com/databricks/bricks/cmd/test"
|
|
||||||
_ "github.com/databricks/bricks/cmd/version"
|
_ "github.com/databricks/bricks/cmd/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue