sjmikler / progress-table

Display progress as a pretty table in the command line.
MIT License
98 stars 3 forks source link

Version 2.X introduces new features and new interactive modes.

New features allow for previously impossible applications, see examples below.

Progress Table

PyPi version PyPI license

Lightweight utility to display the progress of your process as a pretty table in the command line.

Change this:

example

Into this:

example

Examples

example-training

example-download

example-brown2d

example-tictactoe

Quick start code

import random
import time

from progress_table import ProgressTable

# Create table object:
table = ProgressTable(num_decimal_places=1)

# You can (optionally) define the columns at the beginning
table.add_column("x", color="bold red")

for step in range(10):
    x = random.randint(0, 200)

    # You can add entries in a compact way
    table["x"] = x

    # Or you can use the update method
    table.update("x", value=x, weight=1.0)

    # Display the progress bar by wrapping an iterator or an integer
    for _ in table(10):  # -> Equivalent to `table(range(10))`
        # Set and get values from the table
        table["y"] = random.randint(0, 200)
        table["x-y"] = table["x"] - table["y"]
        table.update("average x-y", value=table["x-y"], weight=1.0, aggregate="mean")
        time.sleep(0.1)

    # Go to the next row when you're ready
    table.next_row()

# Close the table when it's finished
table.close()

Go to integrations page to see examples of integration with deep learning libraries.

Advanced usage

Go to advanced usage page for more information.

Troubleshooting

Exceesive output

Progress Table works correctly in most consoles, but there are some exceptions:

By default interactive=2. You can change the default interactive with an argument when creating the table object or by setting PTABLE_INTERACTIVE environment variable, e.g. PTABLE_INTERACTIVE=1.

Other problems

If you encounter different messy outputs or other unexpected behavior: please create an issue!

Installation

Install Progress Table easily with pip:

pip install progress-table

Links

Alternatives