mpb icon indicating copy to clipboard operation
mpb copied to clipboard

Repeated non-complete bars

Open Galzzly opened this issue 3 years ago • 2 comments

On doing some testing on a utility that I have been building, I have found that Bars are being repeatedly rendered, such as:

Downloading [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 6
Downloading [========================================================================>--------------------------------------------------------------------------------------------------------------------------------------------------] 2 / 6
Downloading [=============================================================================================================>-------------------------------------------------------------------------------------------------------------] 3 / 6
Downloading [=================================================================================================================================================>-------------------------------------------------------------------------] 4 / 6
Downloading [======================================================================================================================================================================================>------------------------------------] 5 / 6
Downloading  Done!
Extracting   Done!
Ingesting Intermediate  Done!
Ingesting Gold  Done!

I only render 4 bars for the tool in total - Downloading, Extracting, Ingesting Intermediate, and Ingesting Gold, only the totals are updated.

The bars are initialised as follows:

	p := mpb.New(mpb.PopCompletedMode())
	barDl := p.AddBar(
		int64(numFiles),
		mpb.BarFillerClearOnComplete(),
		mpb.PrependDecorators(
			decor.Name("Downloading", decor.WC{W: 11, C: decor.DidentRight}),
		),
		mpb.AppendDecorators(
			decor.OnComplete(decor.CountersNoUnit("%d / %d"), "Done!"),
		),
	)
	barExtract := p.AddBar(
		int64(numFiles),
		mpb.BarFillerClearOnComplete(),
		mpb.PrependDecorators(
			decor.Name("Extracting", decor.WC{W: 11, C: decor.DidentRight}),
		),
		mpb.AppendDecorators(
			decor.OnComplete(decor.CountersNoUnit("%d / %d"), "Done!"),
		),
	)
	barInter := p.AddBar(
		int64(numFiles),
		mpb.BarFillerClearOnComplete(),
		mpb.PrependDecorators(
			decor.Name("Ingesting Intermediate", decor.WC{W: 22, C: decor.DidentRight}),
		),
		mpb.AppendDecorators(
			decor.OnComplete(decor.CountersNoUnit("%d / %d"), "Done!"),
		),
	)
	barGold := p.AddBar(
		int64(5),
		mpb.BarFillerClearOnComplete(),
		mpb.PrependDecorators(
			decor.Name("Ingesting Gold", decor.WC{W: 14, C: decor.DidentRight}),
		),
		mpb.AppendDecorators(
			decor.OnComplete(decor.CountersNoUnit("%d / %d"), "Done!"),
		),
	)

When adding the bars to the container, I observe that there are the additional two 'Downloading' bars rendered, and additional ones added for unknown reasons as seen in the first example.

What I would like to see happen is the initial four bars rendered:

Downloading [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 6
Extracting  [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 6
Ingesting Intermediate [----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 6
Ingesting Gold [------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 5

The bars increment per the bar.Increment() method, and once complete remove bars and say Done!

Galzzly avatar Jul 05 '22 10:07 Galzzly

Could be linked to what has been described in #107

Galzzly avatar Jul 05 '22 10:07 Galzzly

Can you please check with head master? Should be fixed.

vbauerster avatar Jul 19 '22 14:07 vbauerster