Skip to content

Commit

Permalink
Merge branch 'master' into tqdm-to-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
de-code committed Aug 23, 2021
2 parents 2eadee2 + 140c948 commit 4bf1107
Show file tree
Hide file tree
Showing 27 changed files with 154 additions and 99 deletions.
3 changes: 2 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github: casperdcl
github: [casperdcl, tqdm]
tidelift: pypi/tqdm
custom: https://tqdm.github.io/merch
2 changes: 2 additions & 0 deletions .github/workflows/comment-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "eyes"})
github-token: ${{ secrets.GH_TOKEN }}
- name: Tag Commit
run: |
git clone https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} repo
Expand All @@ -48,3 +49,4 @@ jobs:
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "rocket"})
github-token: ${{ secrets.GH_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
os: [macos-latest, windows-latest]
name: py${{ matrix.python }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -77,6 +78,7 @@ jobs:
python: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
name: py${{ matrix.python }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -162,14 +164,14 @@ jobs:
echo ::set-output name=docker_tags::devel
echo ::set-output name=snap_channel::edge
fi
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
release_name: tqdm ${{ github.ref }} stable
name: tqdm ${{ steps.collect_assets.outputs.tag }} stable
body_path: _CHANGES.md
draft: true
files: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ __pycache__/

# Packages
/tqdm/_dist_ver.py
/.eggs/
/*.egg*/
/build/
/dist/
Expand Down
27 changes: 14 additions & 13 deletions .meta/.readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ iterable with ``tqdm(iterable)``, and you're done!
``tqdm(range(N))``.

|Screenshot|
|Video| |Slides|
|Video| |Slides| |Merch|

It can also be executed as a module with pipes:

Expand Down Expand Up @@ -588,9 +588,6 @@ Nested progress bars
for k in trange(50, desc='3rd loop', leave=False):
sleep(0.01)
On Windows `colorama <https://github.com/tartley/colorama>`__ will be used if
available to keep nested bars on their respective lines.

For manual control over positioning (e.g. for multi-processing use),
you may specify ``position=n`` where ``n=0`` for the outermost bar,
``n=1`` for the next, and so on.
Expand Down Expand Up @@ -1132,7 +1129,7 @@ Helper methods are available in ``tqdm.contrib.logging``. For example:
Monitoring thread, intervals and miniters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``tqdm`` implements a few tricks to to increase efficiency and reduce overhead.
``tqdm`` implements a few tricks to increase efficiency and reduce overhead.

- Avoid unnecessary frequent bar refreshing: ``mininterval`` defines how long
to wait between each refresh. ``tqdm`` always gets updated in the background,
Expand Down Expand Up @@ -1162,6 +1159,11 @@ The monitor thread may be disabled application-wide by setting
``tqdm.tqdm.monitor_interval = 0`` before instantiation of any ``tqdm`` bar.


Merch
-----

You can buy `tqdm branded merch <https://tqdm.github.io/merch>`__ now!

Contributions
-------------

Expand All @@ -1171,7 +1173,7 @@ All source code is hosted on `GitHub <https://github.com/tqdm/tqdm>`__.
Contributions are welcome.

See the
`CONTRIBUTING <https://raw.githubusercontent.com/tqdm/tqdm/master/CONTRIBUTING.md>`__
`CONTRIBUTING <https://github.com/tqdm/tqdm/blob/master/CONTRIBUTING.md>`__
file for more information.

Developers who have made significant contributions, ranked by *SLoC*
Expand All @@ -1182,18 +1184,15 @@ are:
==================== ======================================================== ==== ================================
Name ID SLoC Notes
==================== ======================================================== ==== ================================
Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~81% primary maintainer |Gift-Casper|
Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~78% primary maintainer |Gift-Casper|
Stephen Larroque `lrq3000 <https://github.com/lrq3000>`__ ~10% team member
Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~3%
Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~4%
Daniel Ecer `de-code <https://github.com/de-code>`__ ~2%
Richard Sheridan `richardsheridan <https://github.com/richardsheridan>`__ ~1%
Guangshuo Chen `chengs <https://github.com/chengs>`__ ~1%
Kyle Altendorf `altendky <https://github.com/altendky>`__ <1%
Matthew Stevens `mjstevens777 <https://github.com/mjstevens777>`__ <1%
Hadrien Mary `hadim <https://github.com/hadim>`__ <1% team member
Ivan Ivanov `obiwanus <https://github.com/obiwanus>`__ <1%
Daniel Panteleit `danielpanteleit <https://github.com/danielpanteleit>`__ <1%
Jonas Haag `jonashaag <https://github.com/jonashaag>`__ <1%
James E. King III `jeking3 <https://github.com/jeking3>`__ <1%
Noam Yorav-Raphael `noamraph <https://github.com/noamraph>`__ <1% original author
Mikhail Korobov `kmike <https://github.com/kmike>`__ <1% team member
==================== ======================================================== ==== ================================
Expand All @@ -1220,6 +1219,8 @@ Citation information: |DOI|
:target: https://tqdm.github.io/video
.. |Slides| image:: https://img.tqdm.ml/slides.jpg
:target: https://tqdm.github.io/PyData2019/slides.html
.. |Merch| image:: https://img.tqdm.ml/merch.jpg
:target: https://tqdm.github.io/merch
.. |Build-Status| image:: https://img.shields.io/github/workflow/status/tqdm/tqdm/Test/master?logo=GitHub
:target: https://github.com/tqdm/tqdm/actions?query=workflow%3ATest
.. |Coverage-Status| image:: https://img.shields.io/coveralls/github/tqdm/tqdm/master?logo=coveralls
Expand Down Expand Up @@ -1247,7 +1248,7 @@ Citation information: |DOI|
.. |GitHub-Updated| image:: https://img.shields.io/github/last-commit/tqdm/tqdm/master.svg?logo=github&logoColor=white&label=pushed
:target: https://github.com/tqdm/tqdm/pulse
.. |Gift-Casper| image:: https://img.shields.io/badge/dynamic/json.svg?color=ff69b4&label=gifts%20received&prefix=%C2%A3&query=%24..sum&url=https%3A%2F%2Fcaspersci.uk.to%2Fgifts.json
:target: https://www.cdcl.ml/sponsor
:target: https://cdcl.ml/sponsor
.. |Versions| image:: https://img.shields.io/pypi/v/tqdm.svg
:target: https://tqdm.github.io/releases
.. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/tqdm.svg?label=pypi%20downloads&logo=PyPI&logoColor=white
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:
- flake8-debugger
- flake8-string-format
- repo: https://github.com/PyCQA/isort
rev: 5.8.0
rev: 5.9.2
hooks:
- id: isort
- repo: https://github.com/kynan/nbstripout
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ interpreters errors - these are due to the local machine missing certain
versions of Python.)

Note: to install all versions of the Python interpreter that are specified
in [tox.ini](https://raw.githubusercontent.com/tqdm/tqdm/master/tox.ini),
in [tox.ini](https://github.com/tqdm/tqdm/blob/master/tox.ini),
you can use `MiniConda` to install a minimal setup. You must also make sure
that each distribution has an alias to call the Python interpreter:
`python27` for Python 2.7's interpreter, `python32` for Python 3.2's, etc.
Expand Down
9 changes: 3 additions & 6 deletions DEMO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"![Screenshot](https://img.tqdm.ml/tqdm.gif)|[![Video](https://img.tqdm.ml/video.jpg)](https://tqdm.github.io/video) [![Slides](https://img.tqdm.ml/slides.jpg)](https://tqdm.github.io/PyData2019/slides.html)\n",
"![Screenshot](https://img.tqdm.ml/tqdm.gif)|[![Video](https://img.tqdm.ml/video.jpg)](https://tqdm.github.io/video) [![Slides](https://img.tqdm.ml/slides.jpg)](https://tqdm.github.io/PyData2019/slides.html) [![Merch](https://img.tqdm.ml/merch.jpg)](https://tqdm.github.io/merch)\n",
"-|-\n",
"\n",
"It can also be executed as a module with pipes:"
Expand Down Expand Up @@ -273,7 +273,7 @@
"metadata": {},
"outputs": [],
"source": [
"! find . -name '*.py' -type f -exec cat \\{} \\; | tqdm --unit loc --unit_scale --total 4104300 >> /dev/null"
"! find . -name '*.py' -type f -exec cat \\{} \\; | tqdm --unit loc --unit-scale --total 4104300 --null"
]
},
{
Expand Down Expand Up @@ -472,9 +472,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"On Windows [colorama](https://github.com/tartley/colorama) will be used\n",
"if available to keep nested bars on their respective lines.\n",
"\n",
"For manual control over positioning (e.g. for multi-processing use),\n",
"you may specify `position=n` where `n=0` for the outermost bar, `n=1`\n",
"for the next, and so on. However, it's best to check if tqdm can work\n",
Expand Down Expand Up @@ -702,9 +699,9 @@
"\n",
"### Keras Integration\n",
"\n",
"```python\n",
"A `keras` callback is also available:\n",
"\n",
"```python\n",
"from tqdm.keras import TqdmCallback\n",
"\n",
"...\n",
Expand Down
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ iterable with ``tqdm(iterable)``, and you're done!
``tqdm(range(N))``.

|Screenshot|
|Video| |Slides|
|Video| |Slides| |Merch|

It can also be executed as a module with pipes:

Expand Down Expand Up @@ -807,9 +807,6 @@ Nested progress bars
for k in trange(50, desc='3rd loop', leave=False):
sleep(0.01)
On Windows `colorama <https://github.com/tartley/colorama>`__ will be used if
available to keep nested bars on their respective lines.

For manual control over positioning (e.g. for multi-processing use),
you may specify ``position=n`` where ``n=0`` for the outermost bar,
``n=1`` for the next, and so on.
Expand Down Expand Up @@ -1370,7 +1367,7 @@ To output the tqdm progress bar to ``logging``,
Monitoring thread, intervals and miniters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``tqdm`` implements a few tricks to to increase efficiency and reduce overhead.
``tqdm`` implements a few tricks to increase efficiency and reduce overhead.

- Avoid unnecessary frequent bar refreshing: ``mininterval`` defines how long
to wait between each refresh. ``tqdm`` always gets updated in the background,
Expand Down Expand Up @@ -1400,6 +1397,11 @@ The monitor thread may be disabled application-wide by setting
``tqdm.tqdm.monitor_interval = 0`` before instantiation of any ``tqdm`` bar.


Merch
-----

You can buy `tqdm branded merch <https://tqdm.github.io/merch>`__ now!

Contributions
-------------

Expand All @@ -1409,7 +1411,7 @@ All source code is hosted on `GitHub <https://github.com/tqdm/tqdm>`__.
Contributions are welcome.

See the
`CONTRIBUTING <https://raw.githubusercontent.com/tqdm/tqdm/master/CONTRIBUTING.md>`__
`CONTRIBUTING <https://github.com/tqdm/tqdm/blob/master/CONTRIBUTING.md>`__
file for more information.

Developers who have made significant contributions, ranked by *SLoC*
Expand All @@ -1420,18 +1422,15 @@ are:
==================== ======================================================== ==== ================================
Name ID SLoC Notes
==================== ======================================================== ==== ================================
Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~81% primary maintainer |Gift-Casper|
Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~78% primary maintainer |Gift-Casper|
Stephen Larroque `lrq3000 <https://github.com/lrq3000>`__ ~10% team member
Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~3%
Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~4%
Daniel Ecer `de-code <https://github.com/de-code>`__ ~2%
Richard Sheridan `richardsheridan <https://github.com/richardsheridan>`__ ~1%
Guangshuo Chen `chengs <https://github.com/chengs>`__ ~1%
Kyle Altendorf `altendky <https://github.com/altendky>`__ <1%
Matthew Stevens `mjstevens777 <https://github.com/mjstevens777>`__ <1%
Hadrien Mary `hadim <https://github.com/hadim>`__ <1% team member
Ivan Ivanov `obiwanus <https://github.com/obiwanus>`__ <1%
Daniel Panteleit `danielpanteleit <https://github.com/danielpanteleit>`__ <1%
Jonas Haag `jonashaag <https://github.com/jonashaag>`__ <1%
James E. King III `jeking3 <https://github.com/jeking3>`__ <1%
Noam Yorav-Raphael `noamraph <https://github.com/noamraph>`__ <1% original author
Mikhail Korobov `kmike <https://github.com/kmike>`__ <1% team member
==================== ======================================================== ==== ================================
Expand All @@ -1458,6 +1457,8 @@ Citation information: |DOI|
:target: https://tqdm.github.io/video
.. |Slides| image:: https://img.tqdm.ml/slides.jpg
:target: https://tqdm.github.io/PyData2019/slides.html
.. |Merch| image:: https://img.tqdm.ml/merch.jpg
:target: https://tqdm.github.io/merch
.. |Build-Status| image:: https://img.shields.io/github/workflow/status/tqdm/tqdm/Test/master?logo=GitHub
:target: https://github.com/tqdm/tqdm/actions?query=workflow%3ATest
.. |Coverage-Status| image:: https://img.shields.io/coveralls/github/tqdm/tqdm/master?logo=coveralls
Expand Down Expand Up @@ -1485,7 +1486,7 @@ Citation information: |DOI|
.. |GitHub-Updated| image:: https://img.shields.io/github/last-commit/tqdm/tqdm/master.svg?logo=github&logoColor=white&label=pushed
:target: https://github.com/tqdm/tqdm/pulse
.. |Gift-Casper| image:: https://img.shields.io/badge/dynamic/json.svg?color=ff69b4&label=gifts%20received&prefix=%C2%A3&query=%24..sum&url=https%3A%2F%2Fcaspersci.uk.to%2Fgifts.json
:target: https://www.cdcl.ml/sponsor
:target: https://cdcl.ml/sponsor
.. |Versions| image:: https://img.shields.io/pypi/v/tqdm.svg
:target: https://tqdm.github.io/releases
.. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/tqdm.svg?label=pypi%20downloads&logo=PyPI&logoColor=white
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ classifiers=
[options]
setup_requires=setuptools>=42; setuptools_scm[toml]>=3.4
python_requires=>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
install_requires=
colorama; platform_system == 'Windows'
tests_require=tox
include_package_data=True
packages=find:
Expand Down
2 changes: 1 addition & 1 deletion tests/py37_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def double(i):
@mark.asyncio
async def test_gather(capsys):
"""Test asyncio gather"""
res = await gather(list(map(double, range(30))))
res = await gather(*map(double, range(30)))
_, err = capsys.readouterr()
assert '30/30' in err
assert res == list(range(0, 30 * 2, 2))
26 changes: 9 additions & 17 deletions tests/tests_contrib_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from tqdm import tqdm
from tqdm.contrib.logging import LOGGER as DEFAULT_LOGGER
from tqdm.contrib.logging import _get_first_found_console_logging_formatter
from tqdm.contrib.logging import _get_first_found_console_logging_handler
from tqdm.contrib.logging import _TqdmLoggingHandler as TqdmLoggingHandler
from tqdm.contrib.logging import (
logging_redirect_tqdm, logging_tqdm, tqdm_logging_redirect)
Expand Down Expand Up @@ -76,33 +76,25 @@ def test_should_not_swallow_certain_exceptions(self, exception_class):
logger.info('test')


class TestGetFirstFoundConsoleLoggingFormatter:
class TestGetFirstFoundConsoleLoggingHandler:
def test_should_return_none_for_no_handlers(self):
assert _get_first_found_console_logging_formatter([]) is None
assert _get_first_found_console_logging_handler([]) is None

def test_should_return_none_without_stream_handler(self):
handler = logging.handlers.MemoryHandler(capacity=1)
handler.formatter = TEST_LOGGING_FORMATTER
assert _get_first_found_console_logging_formatter([handler]) is None
assert _get_first_found_console_logging_handler([handler]) is None

def test_should_return_none_for_stream_handler_not_stdout_or_stderr(self):
handler = logging.StreamHandler(StringIO())
handler.formatter = TEST_LOGGING_FORMATTER
assert _get_first_found_console_logging_formatter([handler]) is None
assert _get_first_found_console_logging_handler([handler]) is None

def test_should_return_stream_handler_formatter_if_stream_is_stdout(self):
def test_should_return_stream_handler_if_stream_is_stdout(self):
handler = logging.StreamHandler(sys.stdout)
handler.formatter = TEST_LOGGING_FORMATTER
assert _get_first_found_console_logging_formatter(
[handler]
) == TEST_LOGGING_FORMATTER
assert _get_first_found_console_logging_handler([handler]) == handler

def test_should_return_stream_handler_formatter_if_stream_is_stderr(self):
def test_should_return_stream_handler_if_stream_is_stderr(self):
handler = logging.StreamHandler(sys.stderr)
handler.formatter = TEST_LOGGING_FORMATTER
assert _get_first_found_console_logging_formatter(
[handler]
) == TEST_LOGGING_FORMATTER
assert _get_first_found_console_logging_handler([handler]) == handler


class TestRedirectLoggingToTqdm:
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ deps=
matplotlib
numpy
pandas
keras: keras
py27-keras: keras<2.5
!py27-keras: keras
py3{6,7,8,9}: rich
tf: tensorflow!=2.5.0
commands=
Expand Down
8 changes: 6 additions & 2 deletions tqdm/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
... ...
"""
import asyncio
from sys import version_info

from .std import tqdm as std_tqdm

Expand Down Expand Up @@ -60,11 +61,14 @@ def as_completed(cls, fs, *, loop=None, timeout=None, total=None, **tqdm_kwargs)
"""
if total is None:
total = len(fs)
yield from cls(asyncio.as_completed(fs, loop=loop, timeout=timeout),
kwargs = {}
if version_info[:2] < (3, 10):
kwargs['loop'] = loop
yield from cls(asyncio.as_completed(fs, timeout=timeout, **kwargs),
total=total, **tqdm_kwargs)

@classmethod
async def gather(cls, fs, *, loop=None, timeout=None, total=None, **tqdm_kwargs):
async def gather(cls, *fs, loop=None, timeout=None, total=None, **tqdm_kwargs):
"""
Wrapper for `asyncio.gather`.
"""
Expand Down
Loading

0 comments on commit 4bf1107

Please sign in to comment.