Skip to content

Commit 08839b5

Browse files
authored
Remove unused in-place progress logging mode (#3811)
## Changes The progress logger now only supports `append` (default) and `json` modes. The `json` mode is not used anywhere and is up for removal next. ## Why In-place mode was added in #276 (March 2023) to update job progress on the same line using ANSI escape codes. The intent was to (eventually) show a rich UI with job status and task status but this didn't materialize. It was only ever implemented for job run status events, where the number of states to cycle through is minimal. The feature was effectively disabled after commit 54e16d5 (#2213, Feb 2025) changed the default log level from `disabled` to `warn`. In-place mode required `(log.level == "disabled" OR log.file != "stderr") AND stderr.IsTerminal()`. With the new default, this is only met when `log.file != "stderr"` (uncommon). Additionally, only `JobProgressEvent` supported in-place updates while other events fell back to append mode. Before (when forcing in-place mode): ``` Run URL: ... 2025-10-23 16:45:01 "Test Progress Logger" TERMINATED SUCCESS ``` After: ``` Run URL: ... 2025-10-23 16:46:28 "Test Progress Logger" RUNNING 2025-10-23 16:47:09 "Test Progress Logger" TERMINATED SUCCESS ``` Related: the escape codes that were used are not VT100 compliant and don't work in Ghostty. ## Tests Tests pass. Manually confirmed `bundle run` works as expected.
1 parent f154a5b commit 08839b5

File tree

15 files changed

+16
-168
lines changed

15 files changed

+16
-168
lines changed

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### CLI
88

9+
* Remove `inplace` mode for the `--progress-format` flag. ([#3811](https://github.com/databricks/cli/pull/3811))
10+
911
### Dependency updates
1012

1113
### Bundles

bundle/deployplan/action.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ func (a Action) String() string {
1919
return fmt.Sprintf(" %s %s", a.ActionType.StringShort(), key)
2020
}
2121

22-
// Implements cmdio.Event for cmdio.Log
23-
func (a Action) IsInplaceSupported() bool {
24-
return false
25-
}
26-
2722
type ActionType int
2823

2924
// Actions are ordered in increasing severity.

bundle/run/progress/job.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,3 @@ func (event *JobProgressEvent) String() string {
3434

3535
return result.String()
3636
}
37-
38-
func (event *JobProgressEvent) IsInplaceSupported() bool {
39-
return true
40-
}

bundle/run/progress/job_events.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ func (event *TaskErrorEvent) String() string {
2727
return result.String()
2828
}
2929

30-
func (event *TaskErrorEvent) IsInplaceSupported() bool {
31-
return false
32-
}
33-
3430
type JobRunUrlEvent struct {
3531
Type string `json:"type"`
3632
Url string `json:"url"`
@@ -46,7 +42,3 @@ func NewJobRunUrlEvent(url string) *JobRunUrlEvent {
4642
func (event *JobRunUrlEvent) String() string {
4743
return fmt.Sprintf("Run URL: %s\n", event.Url)
4844
}
49-
50-
func (event *JobRunUrlEvent) IsInplaceSupported() bool {
51-
return false
52-
}

bundle/run/progress/pipeline.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ func (event *ProgressEvent) String() string {
3939
return result.String()
4040
}
4141

42-
func (event *ProgressEvent) IsInplaceSupported() bool {
43-
return false
44-
}
45-
46-
// TODO: Add inplace logging to pipelines. https://github.com/databricks/cli/issues/280
4742
type UpdateTracker struct {
4843
UpdateId string
4944
PipelineId string

bundle/run/progress/pipeline_events.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,3 @@ func NewPipelineUpdateUrlEvent(host, updateId, pipelineId string) *PipelineUpdat
2121
func (event *PipelineUpdateUrlEvent) String() string {
2222
return fmt.Sprintf("Update URL: %s\n", event.Url)
2323
}
24-
25-
func (event *PipelineUpdateUrlEvent) IsInplaceSupported() bool {
26-
return false
27-
}

cmd/pipelines/root/progress_logger.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,17 @@ package root
33

44
import (
55
"context"
6-
"errors"
7-
"os"
86

97
"github.com/databricks/cli/libs/cmdio"
108
"github.com/databricks/cli/libs/env"
119
"github.com/databricks/cli/libs/flags"
1210
"github.com/spf13/cobra"
13-
"golang.org/x/term"
1411
)
1512

1613
const envProgressFormat = "DATABRICKS_CLI_PROGRESS_FORMAT"
1714

1815
type progressLoggerFlag struct {
1916
flags.ProgressLogFormat
20-
21-
log *logFlags
22-
}
23-
24-
func (f *progressLoggerFlag) resolveModeDefault(format flags.ProgressLogFormat) flags.ProgressLogFormat {
25-
if (f.log.level.String() == "disabled" || f.log.file.String() != "stderr") &&
26-
term.IsTerminal(int(os.Stderr.Fd())) {
27-
return flags.ModeInplace
28-
}
29-
return flags.ModeAppend
3017
}
3118

3219
func (f *progressLoggerFlag) initializeContext(ctx context.Context) (context.Context, error) {
@@ -36,14 +23,9 @@ func (f *progressLoggerFlag) initializeContext(ctx context.Context) (context.Con
3623
return ctx, nil
3724
}
3825

39-
if f.log.level.String() != "disabled" && f.log.file.String() == "stderr" &&
40-
f.ProgressLogFormat == flags.ModeInplace {
41-
return nil, errors.New("inplace progress logging cannot be used when log-file is stderr")
42-
}
43-
4426
format := f.ProgressLogFormat
4527
if format == flags.ModeDefault {
46-
format = f.resolveModeDefault(format)
28+
format = flags.ModeAppend
4729
}
4830

4931
progressLogger := cmdio.NewLogger(format)
@@ -53,8 +35,6 @@ func (f *progressLoggerFlag) initializeContext(ctx context.Context) (context.Con
5335
func initProgressLoggerFlag(cmd *cobra.Command, logFlags *logFlags) *progressLoggerFlag {
5436
f := progressLoggerFlag{
5537
ProgressLogFormat: flags.NewProgressLogFormat(),
56-
57-
log: logFlags,
5838
}
5939

6040
// Configure defaults from environment, if applicable.
@@ -64,7 +44,7 @@ func initProgressLoggerFlag(cmd *cobra.Command, logFlags *logFlags) *progressLog
6444
}
6545

6646
flags := cmd.PersistentFlags()
67-
flags.Var(&f.ProgressLogFormat, "progress-format", "format for progress logs (append, inplace, json)")
47+
flags.Var(&f.ProgressLogFormat, "progress-format", "format for progress logs (append, json)")
6848
flags.MarkHidden("progress-format")
6949
cmd.RegisterFlagCompletionFunc("progress-format", f.Complete)
7050
return &f

cmd/root/progress_logger.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,17 @@ package root
22

33
import (
44
"context"
5-
"errors"
6-
"os"
75

86
"github.com/databricks/cli/libs/cmdio"
97
"github.com/databricks/cli/libs/env"
108
"github.com/databricks/cli/libs/flags"
119
"github.com/spf13/cobra"
12-
"golang.org/x/term"
1310
)
1411

1512
const envProgressFormat = "DATABRICKS_CLI_PROGRESS_FORMAT"
1613

1714
type progressLoggerFlag struct {
1815
flags.ProgressLogFormat
19-
20-
log *logFlags
21-
}
22-
23-
func (f *progressLoggerFlag) resolveModeDefault(format flags.ProgressLogFormat) flags.ProgressLogFormat {
24-
if (f.log.level.String() == "disabled" || f.log.file.String() != "stderr") &&
25-
term.IsTerminal(int(os.Stderr.Fd())) {
26-
return flags.ModeInplace
27-
}
28-
return flags.ModeAppend
2916
}
3017

3118
func (f *progressLoggerFlag) initializeContext(ctx context.Context) (context.Context, error) {
@@ -35,14 +22,9 @@ func (f *progressLoggerFlag) initializeContext(ctx context.Context) (context.Con
3522
return ctx, nil
3623
}
3724

38-
if f.log.level.String() != "disabled" && f.log.file.String() == "stderr" &&
39-
f.ProgressLogFormat == flags.ModeInplace {
40-
return nil, errors.New("inplace progress logging cannot be used when log-file is stderr")
41-
}
42-
4325
format := f.ProgressLogFormat
4426
if format == flags.ModeDefault {
45-
format = f.resolveModeDefault(format)
27+
format = flags.ModeAppend
4628
}
4729

4830
progressLogger := cmdio.NewLogger(format)
@@ -52,8 +34,6 @@ func (f *progressLoggerFlag) initializeContext(ctx context.Context) (context.Con
5234
func initProgressLoggerFlag(cmd *cobra.Command, logFlags *logFlags) *progressLoggerFlag {
5335
f := progressLoggerFlag{
5436
ProgressLogFormat: flags.NewProgressLogFormat(),
55-
56-
log: logFlags,
5737
}
5838

5939
// Configure defaults from environment, if applicable.
@@ -63,7 +43,7 @@ func initProgressLoggerFlag(cmd *cobra.Command, logFlags *logFlags) *progressLog
6343
}
6444

6545
flags := cmd.PersistentFlags()
66-
flags.Var(&f.ProgressLogFormat, "progress-format", "format for progress logs (append, inplace, json)")
46+
flags.Var(&f.ProgressLogFormat, "progress-format", "format for progress logs (append, json)")
6747
flags.MarkHidden("progress-format")
6848
cmd.RegisterFlagCompletionFunc("progress-format", f.Complete)
6949
return &f

cmd/root/progress_logger_test.go

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,18 @@ type progressLoggerTest struct {
1919

2020
func initializeProgressLoggerTest(t *testing.T) (
2121
*progressLoggerTest,
22-
*flags.LogLevelFlag,
23-
*flags.LogFileFlag,
2422
*flags.ProgressLogFormat,
2523
) {
2624
plt := &progressLoggerTest{
2725
Command: &cobra.Command{},
2826
}
2927
plt.logFlags = initLogFlags(plt.Command)
3028
plt.progressLoggerFlag = initProgressLoggerFlag(plt.Command, plt.logFlags)
31-
return plt, &plt.level, &plt.file, &plt.ProgressLogFormat
32-
}
33-
34-
func TestInitializeErrorOnIncompatibleConfig(t *testing.T) {
35-
plt, logLevel, logFile, progressFormat := initializeProgressLoggerTest(t)
36-
require.NoError(t, logLevel.Set("info"))
37-
require.NoError(t, logFile.Set("stderr"))
38-
require.NoError(t, progressFormat.Set("inplace"))
39-
_, err := plt.progressLoggerFlag.initializeContext(context.Background())
40-
assert.ErrorContains(t, err, "inplace progress logging cannot be used when log-file is stderr")
41-
}
42-
43-
func TestNoErrorOnDisabledLogLevel(t *testing.T) {
44-
plt, logLevel, logFile, progressFormat := initializeProgressLoggerTest(t)
45-
require.NoError(t, logLevel.Set("disabled"))
46-
require.NoError(t, logFile.Set("stderr"))
47-
require.NoError(t, progressFormat.Set("inplace"))
48-
_, err := plt.progressLoggerFlag.initializeContext(context.Background())
49-
assert.NoError(t, err)
50-
}
51-
52-
func TestNoErrorOnNonStderrLogFile(t *testing.T) {
53-
plt, logLevel, logFile, progressFormat := initializeProgressLoggerTest(t)
54-
require.NoError(t, logLevel.Set("info"))
55-
require.NoError(t, logFile.Set("stdout"))
56-
require.NoError(t, progressFormat.Set("inplace"))
57-
_, err := plt.progressLoggerFlag.initializeContext(context.Background())
58-
assert.NoError(t, err)
29+
return plt, &plt.ProgressLogFormat
5930
}
6031

6132
func TestDefaultLoggerModeResolution(t *testing.T) {
62-
plt, _, _, progressFormat := initializeProgressLoggerTest(t)
33+
plt, progressFormat := initializeProgressLoggerTest(t)
6334
require.Equal(t, *progressFormat, flags.ModeDefault)
6435
ctx, err := plt.progressLoggerFlag.initializeContext(context.Background())
6536
require.NoError(t, err)

libs/cmdio/error_event.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ type ErrorEvent struct {
77
func (event *ErrorEvent) String() string {
88
return "Error: " + event.Error
99
}
10-
11-
func (event *ErrorEvent) IsInplaceSupported() bool {
12-
return false
13-
}

0 commit comments

Comments
 (0)