fastprogress
Advanced tools
| fastcore>=1.10.0 | ||
| python-fasthtml>=0.12.34 |
| Metadata-Version: 2.4 | ||
| Name: fastprogress | ||
| Version: 1.0.5 | ||
| Version: 1.1.0 | ||
| Summary: A nested progress with plotting options for fastai | ||
| Home-page: https://github.com/answerdotai/fastprogress | ||
| Author: Sylvain Gugger | ||
| Author: Sylvain Gugger and Jeremy Howard | ||
| Author-email: info@fast.ai | ||
@@ -14,10 +14,8 @@ License: Apache Software License 2.0 | ||
| Classifier: Natural Language :: English | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3.9 | ||
| Classifier: Programming Language :: Python :: 3.10 | ||
| Requires-Python: >=3.6 | ||
| Requires-Python: >=3.10 | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| Requires-Dist: fastcore>=1.10.0 | ||
| Requires-Dist: python-fasthtml>=0.12.34 | ||
| Dynamic: author | ||
@@ -32,2 +30,3 @@ Dynamic: author-email | ||
| Dynamic: license-file | ||
| Dynamic: requires-dist | ||
| Dynamic: requires-python | ||
@@ -38,3 +37,3 @@ Dynamic: summary | ||
| A fast and simple progress bar for Jupyter Notebook and console. Created by Sylvain Gugger for fast.ai. | ||
| A fast and simple progress bar for Jupyter Notebook and console. | ||
@@ -49,7 +48,2 @@ <img src="https://github.com/fastai/fastprogress/raw/master/images/cifar_train.gif" width="600"> | ||
| ``` | ||
| or: | ||
| ``` | ||
| conda install -c fastai fastprogress | ||
| ``` | ||
| Note that this requires python 3.6 or later. | ||
@@ -66,7 +60,7 @@ ## Usage | ||
| ``` python | ||
| from fastprogress.fastprogress import master_bar, progress_bar | ||
| from fastprogress.fastprogress import * | ||
| from time import sleep | ||
| mb = master_bar(range(10)) | ||
| for i in mb: | ||
| for j in progress_bar(range(100), parent=mb): | ||
| for i in (mb:=master_bar(range(10))): | ||
| for j in mb.progress(range(100)): | ||
| sleep(0.01) | ||
@@ -76,3 +70,2 @@ mb.child.comment = f'second bar stat' | ||
| mb.write(f'Finished loop {i}.') | ||
| #mb.update_graph(graphs, x_bounds, y_bounds) | ||
| ``` | ||
@@ -95,6 +88,4 @@ | ||
| 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): | ||
| for i in mb:=master_bar(range(10), names=['cos', 'sin']): | ||
| for j in mb.progress(range(100)): | ||
| if j%10 == 0: | ||
@@ -144,13 +135,7 @@ k = 100 * i + j | ||
| ``` | ||
| from fastprogress.fastprogress import master_bar, progress_bar | ||
| from time import sleep | ||
| import numpy as np | ||
| import random | ||
| epochs = 5 | ||
| mb = master_bar(range(1, epochs+1)) | ||
| # optional: graph legend: if not set, the default is 'train'/'valid' | ||
| # mb.names = ['first', 'second'] | ||
| train_loss, valid_loss = [], [] | ||
| for epoch in mb: | ||
| for epoch in (mb:=master_bar(range(1, epochs+1))): | ||
| # emulate train sub-loop | ||
@@ -173,2 +158,3 @@ for batch in progress_bar(range(2), parent=mb): sleep(0.2) | ||
| 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. | ||
| Copyright 2017 onwards, fast.ai. | ||
@@ -19,2 +19,3 @@ CONTRIBUTING.md | ||
| fastprogress.egg-info/not-zip-safe | ||
| fastprogress.egg-info/requires.txt | ||
| fastprogress.egg-info/top_level.txt |
@@ -1,2 +0,2 @@ | ||
| __version__ = "1.0.5" | ||
| __version__ = "1.1.0" | ||
| from .fastprogress import master_bar, progress_bar, force_console_behavior |
@@ -51,2 +51,4 @@ # Autogenerated by nbdev | ||
| 'fastprogress/fastprogress.py'), | ||
| 'fastprogress.fastprogress.MasterBar.progress': ( 'fastprogress.html#masterbar.progress', | ||
| 'fastprogress/fastprogress.py'), | ||
| 'fastprogress.fastprogress.MasterBar.update': ( 'fastprogress.html#masterbar.update', | ||
@@ -108,6 +110,12 @@ 'fastprogress/fastprogress.py'), | ||
| 'fastprogress/fastprogress.py'), | ||
| 'fastprogress.fastprogress.format_time': ( 'fastprogress.html#format_time', | ||
| 'fastprogress/fastprogress.py'), | ||
| 'fastprogress.fastprogress.html_progress_bar': ( 'fastprogress.html#html_progress_bar', | ||
| 'fastprogress/fastprogress.py'), | ||
| 'fastprogress.fastprogress.print_and_maybe_save': ( 'fastprogress.html#print_and_maybe_save', | ||
| 'fastprogress/fastprogress.py'), | ||
| 'fastprogress.fastprogress.printing': ( 'fastprogress.html#printing', | ||
| 'fastprogress/fastprogress.py')}, | ||
| 'fastprogress/fastprogress.py'), | ||
| 'fastprogress.fastprogress.text2html_table': ( 'fastprogress.html#text2html_table', | ||
| 'fastprogress/fastprogress.py')}, | ||
| 'fastprogress.version': {}}} |
+183
-136
| # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_fastprogress.ipynb. | ||
| # %% auto 0 | ||
| __all__ = ['NO_BAR', 'WRITER_FN', 'FLUSH', 'SAVE_PATH', 'SAVE_APPEND', 'MAX_COLS', 'ProgressBar', 'MasterBar', 'NBProgressBar', | ||
| 'NBMasterBar', 'printing', 'ConsoleProgressBar', 'print_and_maybe_save', 'ConsoleMasterBar', | ||
| 'force_console_behavior', 'master_bar', 'progress_bar'] | ||
| __all__ = ['html_styles', 'NO_BAR', 'WRITER_FN', 'FLUSH', 'SAVE_PATH', 'SAVE_APPEND', 'MAX_COLS', 'format_time', | ||
| 'html_progress_bar', 'text2html_table', 'ProgressBar', 'MasterBar', 'NBProgressBar', 'NBMasterBar', | ||
| 'printing', 'ConsoleProgressBar', 'print_and_maybe_save', 'ConsoleMasterBar', 'force_console_behavior', | ||
| 'master_bar', 'progress_bar'] | ||
| # %% ../nbs/01_fastprogress.ipynb 1 | ||
| import time,os,shutil | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| import time,shutil | ||
| from sys import stdout | ||
| from warnings import warn | ||
| from .core import * | ||
| # %% ../nbs/01_fastprogress.ipynb 3 | ||
| class ProgressBar(): | ||
| from fastcore.utils import * | ||
| from fasthtml.common import * | ||
| from IPython.display import display,HTML | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| def format_time(t): | ||
| "Format `t` (in seconds) to (h):mm:ss" | ||
| t = int(t) | ||
| h,m,s = t//3600, (t//60)%60, t%60 | ||
| if h!= 0: return f'{h}:{m:02d}:{s:02d}' | ||
| else: return f'{m:02d}:{s:02d}' | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| html_styles = """ | ||
| <style> | ||
| progress { appearance: none; border: none; border-radius: 4px; width: 300px; | ||
| height: 20px; vertical-align: middle; background: #e0e0e0; } | ||
| progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 4px; } | ||
| progress::-webkit-progress-value { background: #2196F3; border-radius: 4px; } | ||
| progress::-moz-progress-bar { background: #2196F3; border-radius: 4px; } | ||
| progress:not([value]) { | ||
| background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px); } | ||
| progress.progress-bar-interrupted::-webkit-progress-value { background: #F44336; } | ||
| progress.progress-bar-interrupted::-moz-progress-value { background: #F44336; } | ||
| progress.progress-bar-interrupted::-webkit-progress-bar { background: #F44336; } | ||
| progress.progress-bar-interrupted::-moz-progress-bar { background: #F44336; } | ||
| progress.progress-bar-interrupted { background: #F44336; } | ||
| table.fastprogress { border-collapse: collapse; margin: 1em 0; font-size: 0.9em; } | ||
| table.fastprogress th, table.fastprogress td { padding: 8px 12px; border: 1px solid #ddd; text-align: left; } | ||
| table.fastprogress thead tr { background: #f8f9fa; font-weight: bold; } | ||
| table.fastprogress tbody tr:nth-of-type(even) { background: #f8f9fa; } | ||
| </style> | ||
| """ | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| def html_progress_bar(value, total, label, interrupted=False): | ||
| "Html code for a progress bar `value`/`total` with `label`" | ||
| cls = 'progress-bar-interrupted' if interrupted else None | ||
| attrs = dict(max=total, cls=cls) | ||
| if total is not None: attrs['value'] = value | ||
| return Div(Progress(**attrs), ' ', label) | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| def text2html_table(items): | ||
| "Put the texts in `items` in an HTML table." | ||
| hdr = Tr(map(Th, items[0])) | ||
| rows = [Tr(map(Td, line)) for line in items[1:]] | ||
| return Table(Thead(hdr), Tbody(*rows), cls='fastprogress') | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| class ProgressBar: | ||
| update_every,first_its,lt = 0.2,5,'<' | ||
| def __init__(self, gen, total=None, display=True, leave=True, parent=None, master=None, comment=''): | ||
| self.gen,self.parent,self.master,self.comment = gen,parent,master,comment | ||
| store_attr() | ||
| self.total = None if total=='noinfer' else len(gen) if total is None else total | ||
| self.last_v = 0 | ||
| if parent is None: self.leave,self.display = leave,display | ||
| else: | ||
| self.leave,self.display=False,False | ||
| self.leave,self.display = False,False | ||
| parent.add_child(self) | ||
| self.last_v = None | ||
| def on_iter_begin(self): | ||
| if self.master is not None: self.master.on_iter_begin() | ||
| def on_interrupt(self): | ||
| if self.master is not None: self.master.on_interrupt() | ||
| def on_iter_end(self): | ||
| if self.master is not None: self.master.on_iter_end() | ||
| def on_update(self, val, text): pass | ||
| def __iter__(self): | ||
| if self.total != 0: self.update(0) | ||
| try: | ||
| for i,o in enumerate(self.gen): | ||
| if self.total and i >= self.total: break | ||
| yield o | ||
| self.update(i+1) | ||
| if self.total is None and self.last_v is not None: | ||
| self.total = i+1 | ||
| self.update(self.total) | ||
| except Exception as e: | ||
| self.on_interrupt() | ||
| raise e | ||
| def update(self, val): | ||
| if self.last_v is None: | ||
| self.on_iter_begin() | ||
| self.last_v = 0 | ||
| if val == 0: | ||
| self.start_t = self.last_t = time.time() | ||
| self.pred_t,self.last_v,self.wait_for = None,0,1 | ||
| self.update_bar(0) | ||
| elif val <= self.first_its or val >= self.last_v + self.wait_for or (self.total and val >= self.total): | ||
| cur_t = time.time() | ||
| avg_t = (cur_t - self.start_t) / val | ||
| self.wait_for = max(int(self.update_every / (avg_t+1e-8)),1) | ||
| self.pred_t = None if self.total is None else avg_t * self.total | ||
| self.last_v,self.last_t = val,cur_t | ||
| self.update_bar(val) | ||
| if self.total is not None and val >= self.total: | ||
| self.on_iter_end() | ||
| self.last_v = None | ||
| def update_bar(self, val): | ||
@@ -81,10 +91,57 @@ if self.total == 0: | ||
| elapsed_t = format_time(elapsed_t) | ||
| end = '' if len(self.comment) == 0 else f' {self.comment}' | ||
| end = f'... {self.comment}' if self.comment else '' | ||
| self.on_update(val, f'{pct}[{val}/{tot} {elapsed_t}{self.lt}{remaining_t}{end}]') | ||
| # %% ../nbs/01_fastprogress.ipynb 8 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| @patch | ||
| def update(self:ProgressBar, val): | ||
| if self.last_v is None: | ||
| self.on_iter_begin() | ||
| self.last_v = 0 | ||
| if val == 0: | ||
| self.start_t = self.last_t = time.time() | ||
| self.pred_t,self.last_v,self.wait_for = None,0,1 | ||
| self.update_bar(0) | ||
| elif val<=self.first_its or val>=self.last_v+self.wait_for or (self.total and val>=self.total): | ||
| cur_t = time.time() | ||
| avg_t = (cur_t-self.start_t) / val | ||
| self.wait_for = max(int(self.update_every/(avg_t+1e-8)),1) | ||
| self.pred_t = None if self.total is None else avg_t * self.total | ||
| self.last_v,self.last_t = val,cur_t | ||
| self.update_bar(val) | ||
| if self.total is not None and val >= self.total: | ||
| self.on_iter_end() | ||
| self.last_v = None | ||
| @patch | ||
| def on_iter_begin(self:ProgressBar): | ||
| if self.master is not None: self.master.on_iter_begin() | ||
| @patch | ||
| def on_interrupt(self:ProgressBar): | ||
| if self.master is not None: self.master.on_interrupt() | ||
| @patch | ||
| def on_iter_end(self:ProgressBar): | ||
| if self.master is not None: self.master.on_iter_end() | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| @patch | ||
| def __iter__(self:ProgressBar): | ||
| if self.total != 0: self.update(0) | ||
| try: | ||
| for i,o in enumerate(self.gen): | ||
| if self.total and i >= self.total: break | ||
| yield o | ||
| self.update(i+1) | ||
| if self.total is None and self.last_v is not None: | ||
| self.total = i+1 | ||
| self.update(self.total) | ||
| except Exception as e: | ||
| self.on_interrupt() | ||
| raise e | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| class MasterBar(ProgressBar): | ||
| def __init__(self, gen, cls, total=None): | ||
| self.main_bar = cls(gen, total=total, display=False, master=self) | ||
| def __init__(self, gen, cls, total=None): self.main_bar = cls(gen, total=total, display=False, master=self) | ||
| def on_iter_begin(self): pass | ||
@@ -96,10 +153,7 @@ def on_interrupt(self): pass | ||
| def update_graph(self, graphs, x_bounds, y_bounds): pass | ||
| def __iter__(self): | ||
| for o in self.main_bar: | ||
| yield o | ||
| def __iter__(self): yield from self.main_bar | ||
| def update(self, val): self.main_bar.update(val) | ||
| def progress(self, *args, **kwargs): return self.pcls(*args, parent=self, **kwargs) | ||
| # %% ../nbs/01_fastprogress.ipynb 13 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| if IN_NOTEBOOK: | ||
@@ -110,8 +164,7 @@ try: | ||
| except: | ||
| warn("Couldn't import ipywidgets properly, progress bar will use console behavior") | ||
| warn("Couldn't import ipython display functions, progress bar will use console behavior") | ||
| IN_NOTEBOOK = False | ||
| # %% ../nbs/01_fastprogress.ipynb 14 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| class NBProgressBar(ProgressBar): | ||
| lt = '<' | ||
| def on_iter_begin(self): | ||
@@ -121,4 +174,4 @@ super().on_iter_begin() | ||
| if self.display: | ||
| display(HTML(html_progress_bar_styles)) | ||
| self.out = display(HTML(self.progress), display_id=True) | ||
| display(HTML(html_styles)) | ||
| self.out = display(self.progress, display_id=True) | ||
| self.is_active=True | ||
@@ -138,20 +191,20 @@ | ||
| self.progress = html_progress_bar(val, self.total, text, interrupted) | ||
| if self.display: self.out.update(HTML(self.progress)) | ||
| if self.display: self.out.update(self.progress) | ||
| elif self.parent is not None: self.parent.show() | ||
| elif hasattr(self, '_parent_show'): self._parent_show() | ||
| # %% ../nbs/01_fastprogress.ipynb 19 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| class NBMasterBar(MasterBar): | ||
| names = ['train', 'valid'] | ||
| def __init__(self, gen, total=None, hide_graph=False, order=None, clean_on_interrupt=False, total_time=False): | ||
| pcls = NBProgressBar | ||
| def __init__(self, gen, total=None, hide_graph=False, order=None, clean_on_interrupt=False, total_time=False, names = ('train', 'valid')): | ||
| super().__init__(gen, NBProgressBar, total) | ||
| if order is None: order = ['pb1', 'text', 'pb2'] | ||
| self.hide_graph,self.order = hide_graph,order | ||
| self.report,self.clean_on_interrupt,self.total_time = [],clean_on_interrupt,total_time | ||
| self.inner_dict = {'pb1':self.main_bar, 'text':""} | ||
| self.text,self.lines = "",[] | ||
| store_attr('hide_graph,order,clean_on_interrupt,total_time,names') | ||
| self.report,self.lines,self.text_parts = [],[],[] | ||
| self.inner_dict = dict(pb1=self.main_bar) | ||
| def on_iter_begin(self): | ||
| self.html_code = '\n'.join([html_progress_bar(0, self.main_bar.total, ""), ""]) | ||
| display(HTML(html_progress_bar_styles)) | ||
| self.out = display(HTML(self.html_code), display_id=True) | ||
| display(HTML(html_styles)) | ||
| self.out = display(Div(html_progress_bar(0, self.main_bar.total, "")), display_id=True) | ||
| self.main_bar._parent_show = self.show | ||
@@ -162,13 +215,6 @@ def on_interrupt(self): | ||
| def on_iter_end(self): | ||
| if hasattr(self, 'imgs_fig'): | ||
| plt.close() | ||
| self.imgs_out.update(self.imgs_fig) | ||
| if hasattr(self, 'graph_fig'): | ||
| plt.close() | ||
| self.graph_out.update(self.graph_fig) | ||
| if self.text.endswith('<p>'): self.text = self.text[:-3] | ||
| if self.total_time: | ||
| total_time = format_time(time.time() - self.main_bar.start_t) | ||
| self.text = f'Total time: {total_time} <p>' + self.text | ||
| if hasattr(self, 'out'): self.out.update(HTML(self.text)) | ||
| if hasattr(self, 'imgs_fig'): plt.close(); self.imgs_out.update(self.imgs_fig) | ||
| if hasattr(self, 'graph_fig'): plt.close(); self.graph_out.update(self.graph_fig) | ||
| hdr = [P(f'Total time: {format_time(time.time() - self.main_bar.start_t)}')] if self.total_time else [] | ||
| if hasattr(self, 'out'): self.out.update(Div(*hdr, *self.text_parts)) | ||
@@ -178,42 +224,44 @@ def add_child(self, child): | ||
| self.inner_dict['pb2'] = self.child | ||
| #self.show() | ||
| def show(self): | ||
| self.inner_dict['text'] = self.text | ||
| to_show = [name for name in self.order if name in self.inner_dict.keys()] | ||
| self.html_code = '\n'.join([getattr(self.inner_dict[n], 'progress', self.inner_dict[n]) for n in to_show]) | ||
| self.out.update(HTML(self.html_code)) | ||
| self.inner_dict['text'] = Div(*self.text_parts) | ||
| children = [item.progress if item.progress is not None else item for n in self.order | ||
| if (item := self.inner_dict.get(n))] | ||
| self.out.update(Div(*children)) | ||
| def write(self, line, table=False): | ||
| if not table: self.text += line + "<p>" | ||
| else: | ||
| self.lines.append(line) | ||
| self.text = text2html_table(self.lines) | ||
| if table: self.lines.append(line); self.text_parts = [text2html_table(self.lines)] | ||
| else: self.text_parts.append(P(line)) | ||
| self.show() | ||
| def show_imgs(self, imgs, titles=None, cols=4, imgsize=4, figsize=None): | ||
| if self.hide_graph: return | ||
| rows = len(imgs)//cols if len(imgs)%cols == 0 else len(imgs)//cols + 1 | ||
| plt.close() | ||
| if figsize is None: figsize = (imgsize*cols, imgsize*rows) | ||
| self.imgs_fig, imgs_axs = plt.subplots(rows, cols, figsize=figsize) | ||
| if titles is None: titles = [None] * len(imgs) | ||
| for img, ax, title in zip(imgs, imgs_axs.flatten(), titles): img.show(ax=ax, title=title) | ||
| for ax in imgs_axs.flatten()[len(imgs):]: ax.axis('off') | ||
| if not hasattr(self, 'imgs_out'): self.imgs_out = display(self.imgs_fig, display_id=True) | ||
| else: self.imgs_out.update(self.imgs_fig) | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| @patch | ||
| def show_imgs(self:NBMasterBar, imgs, titles=None, cols=4, imgsize=4, figsize=None): | ||
| if self.hide_graph: return | ||
| rows = len(imgs)//cols if len(imgs)%cols == 0 else len(imgs)//cols + 1 | ||
| if figsize is None: figsize = (imgsize*cols, imgsize*rows) | ||
| self.imgs_fig, imgs_axs = plt.subplots(rows, cols, figsize=figsize) | ||
| if titles is None: titles = [None] * len(imgs) | ||
| for img, ax, title in zip(imgs, imgs_axs.flatten(), titles): img.show(ax=ax, title=title) | ||
| for ax in imgs_axs.flatten()[len(imgs):]: ax.axis('off') | ||
| if not hasattr(self, 'imgs_out'): self.imgs_out = display(self.imgs_fig, display_id=True) | ||
| else: self.imgs_out.update(self.imgs_fig) | ||
| plt.close(self.imgs_fig) | ||
| def update_graph(self, graphs, x_bounds=None, y_bounds=None, figsize=(6,4)): | ||
| if self.hide_graph: return | ||
| if not hasattr(self, 'graph_fig'): | ||
| self.graph_fig, self.graph_ax = plt.subplots(1, figsize=figsize) | ||
| self.graph_out = display(self.graph_ax.figure, display_id=True) | ||
| self.graph_ax.clear() | ||
| if len(self.names) < len(graphs): self.names += [''] * (len(graphs) - len(self.names)) | ||
| for g,n in zip(graphs,self.names): self.graph_ax.plot(*g, label=n) | ||
| self.graph_ax.legend(loc='upper right') | ||
| if x_bounds is not None: self.graph_ax.set_xlim(*x_bounds) | ||
| if y_bounds is not None: self.graph_ax.set_ylim(*y_bounds) | ||
| self.graph_out.update(self.graph_ax.figure) | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| @patch | ||
| def update_graph(self:NBMasterBar, graphs, x_bounds=None, y_bounds=None, figsize=(6,4)): | ||
| if self.hide_graph: return | ||
| if not hasattr(self, 'graph_fig'): | ||
| self.graph_fig, self.graph_ax = plt.subplots(1, figsize=figsize) | ||
| self.graph_out = display(self.graph_ax.figure, display_id=True) | ||
| self.graph_ax.clear() | ||
| if len(self.names) < len(graphs): self.names += [''] * (len(graphs) - len(self.names)) | ||
| for g,n in zip(graphs,self.names): self.graph_ax.plot(*g, label=n) | ||
| self.graph_ax.legend(loc='upper right') | ||
| if x_bounds is not None: self.graph_ax.set_xlim(*x_bounds) | ||
| if y_bounds is not None: self.graph_ax.set_ylim(*y_bounds) | ||
| self.graph_out.update(self.graph_ax.figure) | ||
| # %% ../nbs/01_fastprogress.ipynb 23 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| NO_BAR = False | ||
@@ -226,3 +274,3 @@ WRITER_FN = print | ||
| # %% ../nbs/01_fastprogress.ipynb 24 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| def printing(): | ||
@@ -233,3 +281,3 @@ "`True` if we want to print progress" | ||
| # %% ../nbs/01_fastprogress.ipynb 25 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| class ConsoleProgressBar(ProgressBar): | ||
@@ -270,3 +318,3 @@ fill:str='█' | ||
| # %% ../nbs/01_fastprogress.ipynb 29 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| def print_and_maybe_save(line): | ||
@@ -278,4 +326,5 @@ WRITER_FN(line) | ||
| # %% ../nbs/01_fastprogress.ipynb 30 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| class ConsoleMasterBar(MasterBar): | ||
| pcls = ConsoleProgressBar | ||
| def __init__(self, gen, total=None, hide_graph=False, order=None, clean_on_interrupt=False, total_time=False): | ||
@@ -313,14 +362,12 @@ super().__init__(gen, ConsoleProgressBar, total) | ||
| # %% ../nbs/01_fastprogress.ipynb 33 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| if IN_NOTEBOOK: master_bar, progress_bar = NBMasterBar, NBProgressBar | ||
| else: master_bar, progress_bar = ConsoleMasterBar, ConsoleProgressBar | ||
| # %% ../nbs/01_fastprogress.ipynb 34 | ||
| _all_ = ['master_bar', 'progress_bar'] | ||
| # %% ../nbs/01_fastprogress.ipynb 35 | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| def force_console_behavior(): | ||
| "Return the console progress bars" | ||
| global IN_NOTEBOOK | ||
| IN_NOTEBOOK = False | ||
| return ConsoleMasterBar, ConsoleProgressBar | ||
| # %% ../nbs/01_fastprogress.ipynb | ||
| _all_ = ['master_bar', 'progress_bar'] |
+16
-30
| Metadata-Version: 2.4 | ||
| Name: fastprogress | ||
| Version: 1.0.5 | ||
| Version: 1.1.0 | ||
| Summary: A nested progress with plotting options for fastai | ||
| Home-page: https://github.com/answerdotai/fastprogress | ||
| Author: Sylvain Gugger | ||
| Author: Sylvain Gugger and Jeremy Howard | ||
| Author-email: info@fast.ai | ||
@@ -14,10 +14,8 @@ License: Apache Software License 2.0 | ||
| Classifier: Natural Language :: English | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3.9 | ||
| Classifier: Programming Language :: Python :: 3.10 | ||
| Requires-Python: >=3.6 | ||
| Requires-Python: >=3.10 | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| Requires-Dist: fastcore>=1.10.0 | ||
| Requires-Dist: python-fasthtml>=0.12.34 | ||
| Dynamic: author | ||
@@ -32,2 +30,3 @@ Dynamic: author-email | ||
| Dynamic: license-file | ||
| Dynamic: requires-dist | ||
| Dynamic: requires-python | ||
@@ -38,3 +37,3 @@ Dynamic: summary | ||
| A fast and simple progress bar for Jupyter Notebook and console. Created by Sylvain Gugger for fast.ai. | ||
| A fast and simple progress bar for Jupyter Notebook and console. | ||
@@ -49,7 +48,2 @@ <img src="https://github.com/fastai/fastprogress/raw/master/images/cifar_train.gif" width="600"> | ||
| ``` | ||
| or: | ||
| ``` | ||
| conda install -c fastai fastprogress | ||
| ``` | ||
| Note that this requires python 3.6 or later. | ||
@@ -66,7 +60,7 @@ ## Usage | ||
| ``` python | ||
| from fastprogress.fastprogress import master_bar, progress_bar | ||
| from fastprogress.fastprogress import * | ||
| from time import sleep | ||
| mb = master_bar(range(10)) | ||
| for i in mb: | ||
| for j in progress_bar(range(100), parent=mb): | ||
| for i in (mb:=master_bar(range(10))): | ||
| for j in mb.progress(range(100)): | ||
| sleep(0.01) | ||
@@ -76,3 +70,2 @@ mb.child.comment = f'second bar stat' | ||
| mb.write(f'Finished loop {i}.') | ||
| #mb.update_graph(graphs, x_bounds, y_bounds) | ||
| ``` | ||
@@ -95,6 +88,4 @@ | ||
| 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): | ||
| for i in mb:=master_bar(range(10), names=['cos', 'sin']): | ||
| for j in mb.progress(range(100)): | ||
| if j%10 == 0: | ||
@@ -144,13 +135,7 @@ k = 100 * i + j | ||
| ``` | ||
| from fastprogress.fastprogress import master_bar, progress_bar | ||
| from time import sleep | ||
| import numpy as np | ||
| import random | ||
| epochs = 5 | ||
| mb = master_bar(range(1, epochs+1)) | ||
| # optional: graph legend: if not set, the default is 'train'/'valid' | ||
| # mb.names = ['first', 'second'] | ||
| train_loss, valid_loss = [], [] | ||
| for epoch in mb: | ||
| for epoch in (mb:=master_bar(range(1, epochs+1))): | ||
| # emulate train sub-loop | ||
@@ -173,2 +158,3 @@ for batch in progress_bar(range(2), parent=mb): sleep(0.2) | ||
| 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. | ||
| Copyright 2017 onwards, fast.ai. | ||
+1
-1
@@ -7,3 +7,3 @@ [build-system] | ||
| name="fastprogress" | ||
| requires-python=">=3.6" | ||
| requires-python=">=3.10" | ||
| dynamic = [ "keywords", "description", "version", "dependencies", "optional-dependencies", "readme", "license", "authors", "classifiers", "entry-points", "scripts", "urls"] | ||
@@ -10,0 +10,0 @@ |
+10
-23
| # fastprogress | ||
| A fast and simple progress bar for Jupyter Notebook and console. Created by Sylvain Gugger for fast.ai. | ||
| A fast and simple progress bar for Jupyter Notebook and console. | ||
@@ -13,7 +13,2 @@ <img src="https://github.com/fastai/fastprogress/raw/master/images/cifar_train.gif" width="600"> | ||
| ``` | ||
| or: | ||
| ``` | ||
| conda install -c fastai fastprogress | ||
| ``` | ||
| Note that this requires python 3.6 or later. | ||
@@ -30,7 +25,7 @@ ## Usage | ||
| ``` python | ||
| from fastprogress.fastprogress import master_bar, progress_bar | ||
| from fastprogress.fastprogress import * | ||
| from time import sleep | ||
| mb = master_bar(range(10)) | ||
| for i in mb: | ||
| for j in progress_bar(range(100), parent=mb): | ||
| for i in (mb:=master_bar(range(10))): | ||
| for j in mb.progress(range(100)): | ||
| sleep(0.01) | ||
@@ -40,3 +35,2 @@ mb.child.comment = f'second bar stat' | ||
| mb.write(f'Finished loop {i}.') | ||
| #mb.update_graph(graphs, x_bounds, y_bounds) | ||
| ``` | ||
@@ -59,6 +53,4 @@ | ||
| 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): | ||
| for i in mb:=master_bar(range(10), names=['cos', 'sin']): | ||
| for j in mb.progress(range(100)): | ||
| if j%10 == 0: | ||
@@ -108,13 +100,7 @@ k = 100 * i + j | ||
| ``` | ||
| from fastprogress.fastprogress import master_bar, progress_bar | ||
| from time import sleep | ||
| import numpy as np | ||
| import random | ||
| epochs = 5 | ||
| mb = master_bar(range(1, epochs+1)) | ||
| # optional: graph legend: if not set, the default is 'train'/'valid' | ||
| # mb.names = ['first', 'second'] | ||
| train_loss, valid_loss = [], [] | ||
| for epoch in mb: | ||
| for epoch in (mb:=master_bar(range(1, epochs+1))): | ||
| # emulate train sub-loop | ||
@@ -137,2 +123,3 @@ for batch in progress_bar(range(2), parent=mb): sleep(0.2) | ||
| 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. | ||
| Copyright 2017 onwards, fast.ai. | ||
+6
-4
@@ -6,6 +6,6 @@ [DEFAULT] | ||
| branch = master | ||
| version = 1.0.5 | ||
| version = 1.1.0 | ||
| description = A nested progress with plotting options for fastai | ||
| keywords = jupyter notebook progressbar | ||
| author = Sylvain Gugger | ||
| author = Sylvain Gugger and Jeremy Howard | ||
| author_email = info@fast.ai | ||
@@ -15,3 +15,5 @@ license = apache2 | ||
| status = 4 | ||
| min_python = 3.6 | ||
| min_python = 3.10 | ||
| requirements = fastcore>=1.10.0 python-fasthtml>=0.12.34 | ||
| dev_requirements = numpy | ||
| audience = Developers | ||
@@ -37,3 +39,3 @@ language = English | ||
| clear_all = False | ||
| cell_number = True | ||
| cell_number = False | ||
| put_version_in_init = True | ||
@@ -40,0 +42,0 @@ update_pyproject = True |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
63409
1.68%21
5%580
9.23%