mirror of https://github.com/databricks/cli.git
Tune output of bundle deploy command (#1047)
## Changes Update the output of the `deploy` command to be more concise and consistent: ``` $ databricks bundle deploy Building my_project... Uploading my_project-0.0.1+20231207.205106-py3-none-any.whl... Uploading bundle files to /Users/lennart.kats@databricks.com/.bundle/my_project/dev/files... Deploying resources... Updating deployment state... Deployment complete! ``` This does away with the intermediate success messages, makes consistent use of `...`, and only prints the success message at the very end after everything is completed. Below is the original output for comparison: ``` $ databricks bundle deploy Detecting Python wheel project... Found Python wheel project at /tmp/output/my_project Building my_project... Build succeeded Uploading my_project-0.0.1+20231207.205134-py3-none-any.whl... Upload succeeded Starting upload of bundle files Uploaded bundle files at /Users/lennart.kats@databricks.com/.bundle/my_project/dev/files! Starting resource deployment Resource deployment completed! ```
This commit is contained in:
parent
42f21d82fe
commit
875c9d2db1
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
"github.com/databricks/cli/libs/filer"
|
"github.com/databricks/cli/libs/filer"
|
||||||
|
"github.com/databricks/cli/libs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mutatorFactory = func(name string) bundle.Mutator
|
type mutatorFactory = func(name string) bundle.Mutator
|
||||||
|
@ -67,7 +68,7 @@ func (m *basicBuild) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("build for %s failed, error: %w, output: %s", m.name, err, out)
|
return fmt.Errorf("build for %s failed, error: %w, output: %s", m.name, err, out)
|
||||||
}
|
}
|
||||||
cmdio.LogString(ctx, "Build succeeded")
|
log.Infof(ctx, "Build succeeded")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -124,7 +125,7 @@ func uploadArtifact(ctx context.Context, a *config.Artifact, uploadPath string,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmdio.LogString(ctx, "Upload succeeded")
|
log.Infof(ctx, "Upload succeeded")
|
||||||
f.RemotePath = path.Join(uploadPath, filepath.Base(f.Source))
|
f.RemotePath = path.Join(uploadPath, filepath.Base(f.Source))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
"github.com/databricks/cli/bundle/libraries"
|
"github.com/databricks/cli/bundle/libraries"
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,17 +31,17 @@ func (m *detectPkg) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
log.Infof(ctx, "No local wheel tasks in databricks.yml config, skipping auto detect")
|
log.Infof(ctx, "No local wheel tasks in databricks.yml config, skipping auto detect")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
cmdio.LogString(ctx, "Detecting Python wheel project...")
|
log.Infof(ctx, "Detecting Python wheel project...")
|
||||||
|
|
||||||
// checking if there is setup.py in the bundle root
|
// checking if there is setup.py in the bundle root
|
||||||
setupPy := filepath.Join(b.Config.Path, "setup.py")
|
setupPy := filepath.Join(b.Config.Path, "setup.py")
|
||||||
_, err := os.Stat(setupPy)
|
_, err := os.Stat(setupPy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmdio.LogString(ctx, "No Python wheel project found at bundle root folder")
|
log.Infof(ctx, "No Python wheel project found at bundle root folder")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdio.LogString(ctx, fmt.Sprintf("Found Python wheel project at %s", b.Config.Path))
|
log.Infof(ctx, fmt.Sprintf("Found Python wheel project at %s", b.Config.Path))
|
||||||
module := extractModuleName(setupPy)
|
module := extractModuleName(setupPy)
|
||||||
|
|
||||||
if b.Config.Artifacts == nil {
|
if b.Config.Artifacts == nil {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/cli/libs/python"
|
"github.com/databricks/cli/libs/python"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ func (m *build) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("build failed %s, error: %w, output: %s", m.name, err, out)
|
return fmt.Errorf("build failed %s, error: %w, output: %s", m.name, err, out)
|
||||||
}
|
}
|
||||||
cmdio.LogString(ctx, "Build succeeded")
|
log.Infof(ctx, "Build succeeded")
|
||||||
|
|
||||||
wheels := python.FindFilesWithSuffixInPath(distPath, ".whl")
|
wheels := python.FindFilesWithSuffixInPath(distPath, ".whl")
|
||||||
if len(wheels) == 0 {
|
if len(wheels) == 0 {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type upload struct{}
|
type upload struct{}
|
||||||
|
@ -15,7 +16,7 @@ func (m *upload) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) error {
|
func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
cmdio.LogString(ctx, "Starting upload of bundle files")
|
cmdio.LogString(ctx, fmt.Sprintf("Uploading bundle files to %s...", b.Config.Workspace.FilePath))
|
||||||
sync, err := getSync(ctx, b)
|
sync, err := getSync(ctx, b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -26,7 +27,7 @@ func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdio.LogString(ctx, fmt.Sprintf("Uploaded bundle files at %s!\n", b.Config.Workspace.FilePath))
|
log.Infof(ctx, "Uploaded bundle files")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/hashicorp/terraform-exec/tfexec"
|
"github.com/hashicorp/terraform-exec/tfexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ func (w *apply) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
return fmt.Errorf("terraform not initialized")
|
return fmt.Errorf("terraform not initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdio.LogString(ctx, "Starting resource deployment")
|
cmdio.LogString(ctx, "Deploying resources...")
|
||||||
|
|
||||||
err := tf.Init(ctx, tfexec.Upgrade(true))
|
err := tf.Init(ctx, tfexec.Upgrade(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -33,7 +34,7 @@ func (w *apply) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
return fmt.Errorf("terraform apply: %w", err)
|
return fmt.Errorf("terraform apply: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdio.LogString(ctx, "Resource deployment completed!")
|
log.Infof(ctx, "Resource deployment completed")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
"github.com/databricks/cli/libs/filer"
|
"github.com/databricks/cli/libs/filer"
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
)
|
)
|
||||||
|
@ -37,6 +38,7 @@ func (l *statePush) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
defer local.Close()
|
defer local.Close()
|
||||||
|
|
||||||
// Upload state file from local cache directory to filer.
|
// Upload state file from local cache directory to filer.
|
||||||
|
cmdio.LogString(ctx, "Updating deployment state...")
|
||||||
log.Infof(ctx, "Writing local state file to remote state directory")
|
log.Infof(ctx, "Writing local state file to remote state directory")
|
||||||
err = f.Write(ctx, TerraformStateFileName, local, filer.CreateParentDirectories, filer.OverwriteIfExists)
|
err = f.Write(ctx, TerraformStateFileName, local, filer.CreateParentDirectories, filer.OverwriteIfExists)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package bundle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogStringMutator struct {
|
||||||
|
message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *LogStringMutator) Name() string {
|
||||||
|
return "log_string"
|
||||||
|
}
|
||||||
|
|
||||||
|
func LogString(message string) Mutator {
|
||||||
|
return &LogStringMutator{
|
||||||
|
message: message,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LogStringMutator) Apply(ctx context.Context, b *Bundle) error {
|
||||||
|
cmdio.LogString(ctx, m.message)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -45,6 +45,7 @@ func Deploy() bundle.Mutator {
|
||||||
lock.Release(lock.GoalDeploy),
|
lock.Release(lock.GoalDeploy),
|
||||||
),
|
),
|
||||||
scripts.Execute(config.ScriptPostDeploy),
|
scripts.Execute(config.ScriptPostDeploy),
|
||||||
|
bundle.LogString("Deployment complete!"),
|
||||||
)
|
)
|
||||||
|
|
||||||
return newPhase(
|
return newPhase(
|
||||||
|
|
|
@ -24,6 +24,7 @@ func Destroy() bundle.Mutator {
|
||||||
),
|
),
|
||||||
lock.Release(lock.GoalDestroy),
|
lock.Release(lock.GoalDestroy),
|
||||||
),
|
),
|
||||||
|
bundle.LogString("Destroy complete!"),
|
||||||
)
|
)
|
||||||
|
|
||||||
return newPhase(
|
return newPhase(
|
||||||
|
|
Loading…
Reference in New Issue