Giter Club home page Giter Club logo

Comments (7)

piotrmurach avatar piotrmurach commented on May 27, 2024 1

I feel the title of this issue is a bit misleading. The log method is only part of the TTY::ProgressBar API and doesn't mention any support for multi-level progress bar logging. I think it would be better to rename it as a feature request?

I haven't thought about how the log method could work for TTY::Progress::Multi. It seems that one alternative approach to making this work could be to make the individual progress bar log method aware of multibar context. Since the current bar knows its position within the multi progressbar, you have a reliable way to print above all the bars the same way move_to_row does it. Then the log implementation on the Multi would mean delegating logging via all progress bars or picking an individual bar. This could work? Please submit PR if you have anything working as it's much easier for me to see where potential issues are.

from tty-progressbar.

bbugh avatar bbugh commented on May 27, 2024

If it's easier, TTY::ProgressBar::Multi could have a log method rather than each individual bar logging, which would be fine too.

from tty-progressbar.

bbugh avatar bbugh commented on May 27, 2024

Sorry, this seems to be an issue with using Parallel more than this gem. It looks like Parallel would have to integrate with this for it to be successful.

from tty-progressbar.

piotrmurach avatar piotrmurach commented on May 27, 2024

Hi Brian 👋

Thanks for using tty-progressbar.

Currently, the TTY::ProgressBar::Multi API doesn't have log support. I'd consider adding it if you have time to send a pull request. The behaviour should be similar to TTY::ProgressBar#log in so far as the logging would be printed above all registered bars.

Not sure if this helps but you can update an individual bar display with custom tokens using the advance method like so:

Parallel.each(examples) do 
  bars[Parallel.worker_number].advance(X, name: "Something")
end

from tty-progressbar.

bbugh avatar bbugh commented on May 27, 2024

Hey there, I'm having a crack at this again because I have another case where I need multiple processes and need to log from them. I've tried lots of different things to add log to ProgressBar::Multi and they all seem to have an edge case. I tried using TTY::Cursor.up and TTY::Cursor.down to reposition, along with flushing the output, NEXTLINE, etc. The best I can come up with is overwriting the top line.

I think one of the root problems is that since the current row is determined in the bar when it prints, it seems like there's not a reliable way to use up and down from the multi bar. Another is that move_to_row overrides anything that might be going on in the multi progress bar if writing via a bar.

Do you have any hints for how I could make this work?

from tty-progressbar.

bbugh avatar bbugh commented on May 27, 2024

I fixed the title, thanks for catching that.

I tried for a while to log via top_bar and that was the closest to success I had, but I couldn't get it to log a line, and then go to the next line, and then start drawing the bars again. It would draw over the top line instead.

I will make a draft PR tonight and go from there. Thanks!

from tty-progressbar.

bbugh avatar bbugh commented on May 27, 2024

I created #52 that has WIP code for this. Two examples of getting close but not quite.

There's a multi_test.rb in the root folder that you can run to quickly test, if you want. (I will of course delete this and write real tests once it's figured out)

Thanks for taking a look.

from tty-progressbar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.