Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified: src/progress.jl #257

Merged
merged 1 commit into from
Jan 16, 2025
Merged

Conversation

abcdvvvv
Copy link
Contributor

@abcdvvvv abcdvvvv commented Jan 8, 2025

Fixed an issue where length(pbar.extra_info) reported an error when extra_info = nothing. Now extra_info is initialized to an empty dictionary Dict{String,Any}(). Here's another simple example of how to use extra_info:

using Term.Progress, Dates
a = 10
iteration_time = NaN
extra_info = Dict("Speed" => "$iteration_time s/it", "Start time" => now(), "a" => a)
pbar = ProgressBar(; extra_info)
job = addjob!(pbar; N = 5)
start!(pbar)
for i in 1:5
    iteration_time = @elapsed begin
        a = 10 - i
        println("Epoch $i")
        pbar.extra_info["Speed"] = "$iteration_time s/it"
        update!(job)
        render(pbar)
        sleep(1)
    end
end
stop!(pbar)

And the output will be:

Epoch 1
Epoch 2...
──────────────────────────── progress ─────────────────────────────     
Running... ● ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ● 5/5 100%     
Start time : 2025-01-08T12:57:06.673
Speed      : 1.0087561 s/it
a          : 5

@abcdvvvv
Copy link
Contributor Author

abcdvvvv commented Jan 8, 2025

I have no idea how to fix the CI / Julia nightly - ubuntu-latest - x64 - pull_request (pull_request).

@t-bltg t-bltg merged commit 2d5d67e into FedeClaudi:master Jan 16, 2025
8 of 9 checks passed
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.

2 participants