shuttle-hq / synth

The Declarative Data Generator
https://www.getsynth.com/
Apache License 2.0
1.39k stars 109 forks source link

Progress bar clearing removes a line of log #207

Open brokad opened 3 years ago

brokad commented 3 years ago

Describe the bug When running with, say RUST_LOG=debug, the call to indicatif::ProgressBar::finish_and_clear seems to be taking with it a line of logs and leave the remaining progress bar in its place.

To Reproduce Steps to reproduce the behavior:

RUST_LOG=debug cargo run --bin synth -- generate examples/bank/bank_db --size 10000 > /dev/null
hbina commented 3 years ago

It seems like the mess is caused by the logger of reqwest that comes in as the progress is happening. On that note:

  1. Why is it making a network request to github whenever it wants to generate something? This operation should be purely offline.
  2. Who is making this calls? AFAIK, the only place where its used is to check for latest version. But after some debugging, I am not sure why/where this log is made? Did it skip over my breakpoint somehow?

Oh wait, nevermind, the version check is done every single time regardless of the command but its done on a separate thread. So not sure how to "fix" this, perhaps lock the stdout before progress-bar finishes and then this other thread can come in.

christos-h commented 3 years ago

Hey @hbina

  1. This just checks for the latest version every time you run a command. This will hopefully lead to a batter UX as it will notify users and help them stay on the latest version. If you have a better idea which does not require an API call every time, please do let me know :)

I don't have any better ideas for the implementation save for delaying the network call until the very end of command execution - but then you don't get the benefits of concurrency.