Skip to main content

An animated and smart Progress Bar for python.

Project description

PyPI version PyPI pyversions PyPI status

alive-progress :)

An animated and smart Progress Bar for python!

Ever found yourself in a remote ssh session, doing some lengthy operations, and every now and then you feel the need to hit [enter] just to ensure you didn't lose the connection? Ever wondered where your processing is in, and when will it finish? Ever needed to pause the progress bar for a while, return to the python REPL for a manual inspection or fixing an item, and then resume the process like it never happened? I did...

I've made this thinking about all that, the Alive-Progress bar! :)

asciicast

I like to think of it as a new kind of progress bar for python, as it has among other things:

  • a cool live spinner, which makes it clear the process did not hang and your terminal/connection is healthy;
  • a visual feedback of the current speed/throughput, as the spinner runs faster or slower according to the actual processing speed;
  • an efficient multi-threaded bar, which updates itself at a fraction of the actual speed (1,000,000 iterations per second equates to roughly 60fps refresh rate) to keep CPU usage low and avoid terminal spamming;
  • an expected time of arrival (eta), that shows the remaining processing time in a friendly way, not anything like eta: 1584s, it will nicely show eta: 0:26:24 as you would expect (but anything less than a minute is indeed eta: 42s;
  • a print() hook, which allows print statements in the midst of an alive-bar context, nicely cleaning the output of any garbage, and even enriching with the current count when it occurred;
  • after your processing has finished, a nice receipt is printed with the statistics of that run, including the elapsed time and observed throughput;
  • it tracks the actual count in regard of the expected count, so it will look different if you send in more or less than expected;
  • it automatically detects if there's really an allocated tty, and if there isn't, only the final receipt is printed, so you can safely include the alive-bar in all and any code and rest assure your log file won't get 60fps garbage;
  • you can pause the alive-bar! I think that's an unprecedented feature for a progress-bar, it's incredible to orchestrate operations that request manual interaction on some items;
  • it is customizable, with a growing smorgasbord of different bar and spinner styles, as well as several factories to easily generate yours!

Wondering what styles does it have bundled? It's showtime! ;)

asciicast

I've made these styles to test all combinations of parameters of the factories, but I think some of them ended up very very cool! Use them, or create your own.

Get it

Just install with pip:

$ pip install alive-progress

How to use

Use it in a with context manager like this:

from alive_progress import alive_bar
qs = <query or iterable>            # usually some queryset or iterable
with alive_bar(qs.count()) as bar:  # or `len(iterable)`: declare your expected total
    for item in qs:                 # iterate over your items
        # process an item
        bar()                       # call after consuming one item

The bar() call is what makes the bar go forward. You usually call it after consuming an item and in every iteration, but you can get creative! Call it only when you find something for example, depending on what you want to monitor. It returns the current count if you'd like to know where you are.

Messages

While in an alive progress bar context, you have two ways to output messages:

  • calling bar('message'), which besides incrementing the counter, also sets/overwrites an inline message within the bar line;
  • calling print('message'), which prints an enriched message that includes the current position of the alive bar, thus leaving behind a log and continuing the bar below it. Both methods always clear the line appropriately to remove any garbage of previous messages on screen.

asciicast

Customization

All of the components are individually customizable, both globally and per use! And you can mix and match them.

asciicast

Advanced

Make your own spinners and bars! There's builtin support for frames, scrolling, bouncing, delayed and compound spinners! Be creative!

asciicast

To do

  • create an unknown mode for bars (without a known total and eta)
  • implement a pausing mechanism
  • change spinner styles
  • change bar styles
  • include a global configuration system
  • create generators for scrolling, bouncing, delayed and compound spinners
  • create an exhibition of spinners and bars, to see them all in motion
  • include theme support in configuration
  • include colors in spinners and bars
  • try some adaptive algorithm for ETA, like moving average or exponential smoothing
  • any other ideas welcome!

Changelog highlights:

  • 1.0: first public release, already very complete and mature

License

This software is licensed under the MIT License. See the LICENSE file in the top distribution directory for the full license text.

Did you like it?

Thank you for your interest! I've put much ❤️ and effort into this. Hope you'll like it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alive-progress-1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

alive_progress-1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file alive-progress-1.0.tar.gz.

File metadata

  • Download URL: alive-progress-1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for alive-progress-1.0.tar.gz
Algorithm Hash digest
SHA256 96293023490bd1750d365e5e52108fe9d505b7c92ce7dbe5a0c72ed9927ddd15
MD5 9c6164f59fdc5e03d4a61160aeb5dc30
BLAKE2b-256 594a63ed275c8a8f4e473435d1b09ef188294356b07026b2bff9f501a88a3bb3

See more details on using hashes here.

File details

Details for the file alive_progress-1.0-py3-none-any.whl.

File metadata

  • Download URL: alive_progress-1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for alive_progress-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f711420255808e749776f4956ed3bf2240b8d1f223ff0996941901e68780efa2
MD5 a20d163bc56e94eaed582786d890cbca
BLAKE2b-256 75bf38e2628f0ed1461044756a75a7feb7424330ff23b9d0a7f6f01ff456f13a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page