2022-05-14 17:54:35 +00:00
|
|
|
package launch
|
2022-05-13 15:43:54 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
2022-05-14 17:54:35 +00:00
|
|
|
"github.com/databricks/bricks/cmd/root"
|
2022-05-13 15:43:54 +00:00
|
|
|
"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() {
|
2022-09-07 09:55:59 +00:00
|
|
|
// TODO: detect if we can skip registering
|
2022-05-16 10:50:50 +00:00
|
|
|
// launch command for DBSQL projects
|
2022-05-14 17:54:35 +00:00
|
|
|
root.RootCmd.AddCommand(launchCmd)
|
2022-05-13 15:43:54 +00:00
|
|
|
}
|