Skip to main content

A nested progress with plotting options for fastai

Project description

fast_progress

A fast and simple progress bar for Jupyter Notebook and console. Created by Sylvain Gugger for fast.ai.

Copyright 2017 onwards, fast.ai. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. A copy of the License is provided in the LICENSE file in this repository.

Install

To install simply use

pip install fast_progress

Note that this requires python 3.6 or later.

Usage

Here is a simple example. Each bar takes a generator as a main argument, and we can specify the second bar is nested with the first by adding the argument parent=mb. We can then

  • add a comment in the first bar by changing the value of mb.first_bar.comment
  • add a comment in the first bar by changing the value of mb.child.comment
  • write a line between the two bars with mb.write('message')
from fast_progress import master_bar, progress_bar
from time import sleep
mb = master_bar(range(10))
for i in mb:
    for j in progress_bar(range(100), parent=mb):
        sleep(0.01)
        mb.child.comment = f'second bar stat'
    mb.first_bar.comment = f'first bar stat'
    mb.write(f'Finished loop {i}.')
    #mb.update_graph(graphs, x_bounds, y_bounds)

To add a graph that get plots as the training goes, just use the command mb.update_graphs. It will create the figure on its first use. Arguments are:

  • graphs: a list of graphs to be plotted (each of the form [x,y])
  • x_bounds: the min and max values of the x axis (if None, it will those given by the graphs)
  • y_bounds: the min and max values of the y axis (if None, it will those given by the graphs)

Note that it's best to specify x_bounds and _bounds otherwise the box will change as the loop progresses.

Additionally, we can give the label of each graph via the command mb.names (should have as many elements as the graphs argument).

import numpy as np
mb = master_bar(range(10))
mb.names = ['cos', 'sin']
for i in mb:
    for j in progress_bar(range(100), parent=mb):
        if j%10 == 0:
            k = 100 * i + j
            x = np.arange(0, 2*k*np.pi/1000, 0.01)
            y1, y2 = np.cos(x), np.sin(x)
            graphs = [[x,y1], [x,y2]]
            x_bounds = [0, 2*np.pi]
            y_bounds = [-1,1]
            mb.update_graph(graphs, x_bounds, y_bounds)
            mb.child.comment = f'second bar stat'
    mb.first_bar.comment = f'first bar stat'
    mb.write(f'Finished loop {i}.')

Here is the rendering in console:

If the script using this is executed with a redirect to a file, only the results of the .write method will be printed in that file.

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

fastprogress-0.1.5.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

fastprogress-0.1.5-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file fastprogress-0.1.5.tar.gz.

File metadata

  • Download URL: fastprogress-0.1.5.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for fastprogress-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a90644fb5a2a73f245d58e7e9bb60f252e2a578f2389cbc446661f26e920971a
MD5 473a02819cf5a94c6cc9e9a20a05f933
BLAKE2b-256 27a6386f68377fe23168f17ad86cd5e8231c5502aee6e3e6b2610e6f36090b7f

See more details on using hashes here.

File details

Details for the file fastprogress-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: fastprogress-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for fastprogress-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1a174526ef45c4bfd5d8dd6b31d674102da8e3990e1140ad821cf6ba578b14d3
MD5 a31a06c506b5c9387ed48c0e5f64f2d9
BLAKE2b-256 620809ced1bae24016d96a1ddad0e0516275f113d929adf1fbd4a30a88002d68

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