FX31337 / FX-BT-Scripts

:page_facing_up: Useful scripts for backtesting.
MIT License
34 stars 39 forks source link

Add a nice spinning bar #49

Closed LemonBoy closed 8 years ago

LemonBoy commented 8 years ago

44

Less is more (?)

kenorb commented 8 years ago

It's possible to make it compatible with CI output (doesn't need to show progress there, but at least it won't generate thousands of one-char lines)? Using pv works fine for CI.

It also fails with:

The log length has exceeded the limit of 4 MB (this usually means that the test suite is raising the same exception over and over).

LemonBoy commented 8 years ago

Travis's terminal doesn't interpret any escape sequence nor a simple \b so I guess the only solution is to make the bar spin at a lower rate, maybe after 10000 ticks or so

kenorb commented 8 years ago

Please check test branch, using pv seems to work.

Tested by: cat /dev/urandom | pv -N 'Progress' > /dev/null.

Travis CI:

screen shot 2016-03-29 at 10 09 03

Local (same branch test, just run make):

screen shot 2016-03-29 at 10 09 55

We don't need progress in CI, just on local. It seems CI somehow detects the progress bar and it doesn't printing it in each line.

LemonBoy commented 8 years ago

Better ?

kenorb commented 8 years ago

I think the point is to print anything, so Travis won't time out because lack of any output for longer than 10 minutes.

In branch test I've run:

cat /dev/urandom | pv -N 'Progress' > /dev/null

which shows the progress locally and it seems it was showing on Travis as well, but not in real time, just after finish:

cat /dev/urandom | pv -N 'Progress' > /dev/null
 Progress: 40.1GB 0:48:17 [14.6MB/s] [  <=>  

But at least it didn't stopped, because of no output was received for longer than 10 minutes.

See: #119190362

LemonBoy commented 8 years ago

Some text is already printed in between timeframes conversion so the problem here is to let travis know the script isn't dead during the conversion phase, the performance fixes might help here since it takes less than 10m to convert a single set, otherwise the only other option I see is to rate-limit the progressbar

LemonBoy commented 8 years ago

Also, see https://docs.travis-ci.com/user/common-build-problems/ about travis_wait

kenorb commented 8 years ago

Text between timeframes is not enough, since M1 is taking the longest time, probably more than 30 minutes.

LemonBoy commented 8 years ago

Ayy, is this ok ?

LemonBoy commented 8 years ago

Green :green_apple:

kenorb commented 8 years ago

The previous version was better, with the progress bar. I'm investigating currently if the progress bar is possible with CI.

LemonBoy commented 8 years ago

Nope, most projects just disable the bars alltogether when the 'CI' env variable is detected since Travis doesn't support any kind of escape sequence

kenorb commented 8 years ago

I did simple test in Python and it seems it works fine.

ci build

Build: 119308690 File: progress-bar.py Code: http://stackoverflow.com/a/3160819/55075 Repo: travis-test (you can fork it and test CI on your side)

I think you just need to send return of the line (\b) and flush the stdout.

LemonBoy commented 8 years ago

ehh, the original version had no such luck, is a spinning bar ok ?

kenorb commented 8 years ago

The spinning is fine (e.g. every 1% as per issue description), but it shouldn't generate thousands of lines (just one line with any progress bar). If we know the total of ticks, we can print how many ticks are of total.

LemonBoy commented 8 years ago

You can't know the number of ticks since the Input iterator is lazy and you'd end up reading the whole dataset twice (once for len() and once for the actual elaboration), so the best you could have is the crazy spinning bar :)

kenorb commented 8 years ago

Ok, spinning bar is fine or e.g. elapsed time, or just how many ticks were already proceed.

LemonBoy commented 8 years ago

It looks like travis doesn't like multiple \b

kenorb commented 8 years ago

Probably because there are too many characters printed (>4MB). Can you do it each 2 seconds or every 100k or 1mln ticks? If you're printing it on each tick, the whole year could have 17mln of ticks.

kenorb commented 8 years ago

Almost.

ci build

Sometimes it's replacing some previous characters, sometimes it's not.

But it's saying:

The log length has exceeded the limit of 4 MB (this usually means that the test suite is raising the same exception over and over).

Probably too many bars in short amount of time.

LemonBoy commented 8 years ago

Slightly better

kenorb commented 8 years ago

If this can't be done in a better way, pity. At least it works in terms of outputting something.