Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next release v4.61.2 #1180

Merged
merged 12 commits into from Jul 6, 2021
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
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 @@ -164,12 +166,11 @@ jobs:
fi
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 ${{ github.ref }} stable
body_path: _CHANGES.md
draft: true
files: |
Expand Down
5 changes: 1 addition & 4 deletions .meta/.readme.rst
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 @@ -1254,7 +1251,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
9 changes: 3 additions & 6 deletions DEMO.ipynb
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
5 changes: 1 addition & 4 deletions README.rst
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 @@ -1473,7 +1470,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
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
6 changes: 5 additions & 1 deletion tqdm/asyncio.py
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,7 +61,10 @@ 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
Expand Down
18 changes: 18 additions & 0 deletions tqdm/contrib/telegram.py
Expand Up @@ -62,6 +62,17 @@ def write(self, s):
else:
return future

def delete(self):
"""Deletes internal `message_id`."""
try:
future = self.submit(
self.session.post, self.API + '%s/deleteMessage' % self.token,
data={'chat_id': self.chat_id, 'message_id': self.message_id})
except Exception as e:
tqdm_auto.write(str(e))
else:
return future


class tqdm_telegram(tqdm_auto):
"""
Expand Down Expand Up @@ -112,6 +123,13 @@ def clear(self, *args, **kwargs):
if not self.disable:
self.tgio.write("")

def close(self):
if self.disable:
return
super(tqdm_telegram, self).close()
if not (self.leave or (self.leave is None and self.pos == 0)):
self.tgio.delete()


def ttgrange(*args, **kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion tqdm/keras.py
Expand Up @@ -7,7 +7,7 @@

try:
import keras
except ImportError as e:
except (ImportError, AttributeError) as e:
try:
from tensorflow import keras
except ImportError:
Expand Down
4 changes: 2 additions & 2 deletions tqdm/rich.py
Expand Up @@ -113,10 +113,10 @@ def __init__(self, *args, **kwargs):
self._prog.__enter__()
self._task_id = self._prog.add_task(self.desc or "", **d)

def close(self, *args, **kwargs):
def close(self):
if self.disable:
return
super(tqdm_rich, self).close(*args, **kwargs)
super(tqdm_rich, self).close()
self._prog.__exit__(None, None, None)

def clear(self, *_, **__):
Expand Down
9 changes: 8 additions & 1 deletion tqdm/std.py
Expand Up @@ -336,6 +336,9 @@ def status_printer(file):
"""
fp = file
fp_flush = getattr(fp, 'flush', lambda: None) # pragma: no cover
if fp in (sys.stderr, sys.stdout):
sys.stderr.flush()
sys.stdout.flush()

def fp_write(s):
fp.write(_unicode(s))
Expand Down Expand Up @@ -790,8 +793,12 @@ def inner(df, func, *args, **kwargs):
" Use keyword arguments instead.",
fp_write=getattr(t.fp, 'write', sys.stderr.write))

try: # pandas>=1.3.0
from pandas.core.common import is_builtin_func
except ImportError:
is_builtin_func = df._is_builtin_func
try:
func = df._is_builtin_func(func)
func = is_builtin_func(func)
except TypeError:
pass

Expand Down