Skip to content

Retry Fix printing of multiline values, and allow colors in showed values#345

Open
MasonProtter wants to merge 8 commits into
timholy:masterfrom
MasonProtter:patch-1
Open

Retry Fix printing of multiline values, and allow colors in showed values#345
MasonProtter wants to merge 8 commits into
timholy:masterfrom
MasonProtter:patch-1

Conversation

@MasonProtter

Copy link
Copy Markdown
Contributor

This is a continuation of #341 after it was reverted because it errored when encountering an AnnotatedString.

Seems to be working with AnnotatedString.

julia> let n = 20
           xs = Float64[]
           p = Progress(n)
           for iter = 1:n
               append!(xs, rand())
               sleep(0.5)
               plt = lineplot(xs)
               str = Base.AnnotatedString(" julia", [(2:6, :face, rand((:magenta, :red, :blue, :green)))])
               ProgressMeter.next!(p; showvalues = [(:UnicodePlot, plt), ("An annoted string", str2)])
           end
       end
Screencast_20250405_002203.webm

The downside is that styled strings will get a " wrapped around them as you can see in the video, so if anyone has any better suggestions for how to deal with this generically, I'd be open to input. cc @MilesCranmer

@codecov

codecov Bot commented Apr 4, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.45%. Comparing base (807496a) to head (f452210).
⚠️ Report is 30 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #345      +/-   ##
==========================================
+ Coverage   93.48%   96.45%   +2.97%     
==========================================
  Files           1        1              
  Lines         399      564     +165     
==========================================
+ Hits          373      544     +171     
+ Misses         26       20       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MilesCranmer

Copy link
Copy Markdown

Probably worth adding some tests; also see the code coverage

Comment thread src/ProgressMeter.jl
Comment on lines 595 to 596
# I don't understand why the minus 1 is necessary here, but empircally
# it is needed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this "empirically it is needed" change at all with this modified calculation? Is there a test for this that verifies it is/is not needed?

@MasonProtter MasonProtter Apr 4, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an old comment from before my PR. I did try some tests to change that value, and it causes the number of printed lines to shrink or expand each iteration if you change it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I assumed it was old, I was just wondering if it was no longer relevant since it’s now a different method for counting lines

Comment thread src/ProgressMeter.jl
string_value = "\e[0m" * if value isa Union{String, SubString{String}}
value
else
repr("text/plain", value; context=IOContext(PipeBuffer(), :color => true))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this repr the cause of the explicit quotes showing up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Trying to show it like in the previous commit causes it to show up as AnnotatedString(" julia", ...)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MasonProtter

Copy link
Copy Markdown
Contributor Author

Yeah I'll throw some tests together soon, I just wanted to put the PR up for now to see if people have suggestions for how to deal with these annotated strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants