Skip to content

Commit d69cc90

Browse files
authored
bump version, merge pull request #1491 from tqdm/envwrap
2 parents 87414bc + d434a3c commit d69cc90

16 files changed

Lines changed: 339 additions & 230 deletions

File tree

.github/workflows/check.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,25 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v3
19-
with:
20-
fetch-depth: 0
2119
- uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.x'
2222
- run: pip install -U tox
2323
- run: tox
2424
env:
2525
TOXENV: ${{ matrix.TOXENV }}
2626
asvfull:
27-
if: (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')) || github.event_name == 'schedule'
27+
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || github.event_name == 'schedule'
2828
name: Benchmark (Full)
2929
runs-on: ubuntu-latest
3030
steps:
3131
- uses: actions/checkout@v3
3232
with:
3333
fetch-depth: 0
34+
token: ${{ secrets.GH_TOKEN || github.token }}
3435
- uses: actions/setup-python@v4
36+
with:
37+
python-version: '3.x'
3538
- name: Install
3639
run: |
3740
pip install -U wheel
@@ -58,14 +61,16 @@ jobs:
5861
GIT_AUTHOR_NAME: ${{ github.actor }}
5962
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
6063
testasv:
61-
if: github.event.ref != 'refs/heads/master' && ! startsWith(github.event.ref, 'refs/tags')
64+
if: github.ref != 'refs/heads/master' && ! startsWith(github.ref, 'refs/tags')
6265
name: Benchmark (Branch)
6366
runs-on: ubuntu-latest
6467
steps:
6568
- uses: actions/checkout@v3
6669
with:
6770
fetch-depth: 0
6871
- uses: actions/setup-python@v4
72+
with:
73+
python-version: '3.x'
6974
- name: Install
7075
run: |
7176
pip install -U wheel
@@ -82,6 +87,6 @@ jobs:
8287
- name: Benchmark
8388
run: |
8489
asv continuous --interleave-processes --only-changed -f 1.25 master HEAD
85-
CHANGES="$(asv compare --only-changed -f 1.25 master HEAD)"
86-
echo "$CHANGES"
87-
[ -z "$CHANGES" ] || exit 1
90+
CHANGES=$(asv compare --only-changed -f 1.25 master HEAD)
91+
echo "$CHANGES" >> "$GITHUB_STEP_SUMMARY"
92+
test -z "$CHANGES" || exit 1

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ jobs:
153153
tag="${GITHUB_REF#refs/tags/}"
154154
gh release create --title "tqdm $tag stable" --draft --notes "$changelog" "$tag" dist/${{ steps.dist.outputs.whl }} dist/${{ steps.dist.outputs.whl_asc }}
155155
env:
156-
GH_TOKEN: ${{ github.token }}
156+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
157157
- uses: snapcore/action-build@v1
158158
id: snap_build
159159
- if: github.event_name == 'push' && steps.collect_assets.outputs.snap_channel

.meta/.readme.rst

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ This can be beautified further:
255255

256256
.. code:: sh
257257
258-
$ BYTES="$(du -sb docs/ | cut -f1)"
258+
$ BYTES=$(du -sb docs/ | cut -f1)
259259
$ tar -cf - docs/ \
260260
| tqdm --bytes --total "$BYTES" --desc Processing | gzip \
261261
| tqdm --bytes --total "$BYTES" --desc Compressed --position 1 \
@@ -332,6 +332,10 @@ of a neat one-line progress bar.
332332
buffering.
333333
- `No intermediate output in docker-compose <https://github.com/tqdm/tqdm/issues/771>`__:
334334
use ``docker-compose run`` instead of ``docker-compose up`` and ``tty: true``.
335+
- Overriding defaults via environment variables:
336+
e.g. in CI jobs, ``export TQDM_MININTERVAL=5`` to avoid log spam.
337+
This override logic is handled by the ``tqdm.utils.envwrap`` decorator
338+
(useful independent of ``tqdm``).
335339

336340
If you come across any other difficulties, browse and file |GitHub-Issues|.
337341

@@ -345,12 +349,14 @@ Documentation
345349
class tqdm():
346350
"""{DOC_tqdm}"""
347351
352+
@envwrap("TQDM_", is_method=True) # override defaults via env vars
348353
def __init__(self, iterable=None, desc=None, total=None, leave=True,
349354
file=None, ncols=None, mininterval=0.1,
350355
maxinterval=10.0, miniters=None, ascii=None, disable=False,
351356
unit='it', unit_scale=False, dynamic_ncols=False,
352357
smoothing=0.3, bar_format=None, initial=0, position=None,
353-
postfix=None, unit_divisor=1000):
358+
postfix=None, unit_divisor=1000, write_bytes=False,
359+
lock_args=None, nrows=None, colour=None, delay=0):
354360
355361
Parameters
356362
~~~~~~~~~~
@@ -1183,16 +1189,17 @@ are:
11831189
==================== ======================================================== ==== ================================
11841190
Name ID SLoC Notes
11851191
==================== ======================================================== ==== ================================
1186-
Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~78% primary maintainer |Gift-Casper|
1187-
Stephen Larroque `lrq3000 <https://github.com/lrq3000>`__ ~10% team member
1188-
Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~4%
1192+
Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~80% primary maintainer |Gift-Casper|
1193+
Stephen Larroque `lrq3000 <https://github.com/lrq3000>`__ ~9% team member
1194+
Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~3%
11891195
Daniel Ecer `de-code <https://github.com/de-code>`__ ~2%
11901196
Richard Sheridan `richardsheridan <https://github.com/richardsheridan>`__ ~1%
11911197
Guangshuo Chen `chengs <https://github.com/chengs>`__ ~1%
1198+
Helio Machado `0x2b3bfa0 <https://github.com/0x2b3bfa0>`__ ~1%
11921199
Kyle Altendorf `altendky <https://github.com/altendky>`__ <1%
1200+
Noam Yorav-Raphael `noamraph <https://github.com/noamraph>`__ <1% original author
11931201
Matthew Stevens `mjstevens777 <https://github.com/mjstevens777>`__ <1%
11941202
Hadrien Mary `hadim <https://github.com/hadim>`__ <1% team member
1195-
Noam Yorav-Raphael `noamraph <https://github.com/noamraph>`__ <1% original author
11961203
Mikhail Korobov `kmike <https://github.com/kmike>`__ <1% team member
11971204
==================== ======================================================== ==== ================================
11981205

@@ -1212,13 +1219,13 @@ Citation information: |DOI|
12121219

12131220
|README-Hits| (Since 19 May 2016)
12141221

1215-
.. |Logo| image:: https://img.tqdm.ml/logo.gif
1216-
.. |Screenshot| image:: https://img.tqdm.ml/tqdm.gif
1217-
.. |Video| image:: https://img.tqdm.ml/video.jpg
1222+
.. |Logo| image:: https://tqdm.github.io/img/logo.gif
1223+
.. |Screenshot| image:: https://tqdm.github.io/img/tqdm.gif
1224+
.. |Video| image:: https://tqdm.github.io/img/video.jpg
12181225
:target: https://tqdm.github.io/video
1219-
.. |Slides| image:: https://img.tqdm.ml/slides.jpg
1226+
.. |Slides| image:: https://tqdm.github.io/img/slides.jpg
12201227
:target: https://tqdm.github.io/PyData2019/slides.html
1221-
.. |Merch| image:: https://img.tqdm.ml/merch.jpg
1228+
.. |Merch| image:: https://tqdm.github.io/img/merch.jpg
12221229
:target: https://tqdm.github.io/merch
12231230
.. |Build-Status| image:: https://img.shields.io/github/actions/workflow/status/tqdm/tqdm/test.yml?branch=master&label=tqdm&logo=GitHub
12241231
:target: https://github.com/tqdm/tqdm/actions/workflows/test.yml
@@ -1274,8 +1281,8 @@ Citation information: |DOI|
12741281
:target: https://doi.org/10.5281/zenodo.595120
12751282
.. |binder-demo| image:: https://mybinder.org/badge_logo.svg
12761283
:target: https://mybinder.org/v2/gh/tqdm/tqdm/master?filepath=DEMO.ipynb
1277-
.. |Screenshot-Jupyter1| image:: https://img.tqdm.ml/jupyter-1.gif
1278-
.. |Screenshot-Jupyter2| image:: https://img.tqdm.ml/jupyter-2.gif
1279-
.. |Screenshot-Jupyter3| image:: https://img.tqdm.ml/jupyter-3.gif
1280-
.. |README-Hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&style=social&r=https://github.com/tqdm/tqdm&l=https://img.tqdm.ml/favicon.png&f=https://img.tqdm.ml/logo.gif
1281-
:target: https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&a=plot&r=https://github.com/tqdm/tqdm&l=https://img.tqdm.ml/favicon.png&f=https://img.tqdm.ml/logo.gif&style=social
1284+
.. |Screenshot-Jupyter1| image:: https://tqdm.github.io/img/jupyter-1.gif
1285+
.. |Screenshot-Jupyter2| image:: https://tqdm.github.io/img/jupyter-2.gif
1286+
.. |Screenshot-Jupyter3| image:: https://tqdm.github.io/img/jupyter-3.gif
1287+
.. |README-Hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&style=social&r=https://github.com/tqdm/tqdm&l=https://tqdm.github.io/img/favicon.png&f=https://tqdm.github.io/img/logo.gif
1288+
:target: https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&a=plot&r=https://github.com/tqdm/tqdm&l=https://tqdm.github.io/img/favicon.png&f=https://tqdm.github.io/img/logo.gif&style=social

.meta/mkcompletion.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
"""
44
import re
55
import sys
6-
from io import open as io_open
7-
from os import path
6+
from pathlib import Path
87

9-
sys.path.insert(0, path.dirname(path.dirname(__file__)))
8+
sys.path.insert(0, str(Path(__file__).parent.parent))
109
import tqdm # NOQA
1110
import tqdm.cli # NOQA
1211

@@ -27,13 +26,12 @@ def doc2opt(doc, user_input=True):
2726
# CLI options
2827
options = {'-h', '--help', '-v', '--version'}
2928
options_input = set()
30-
for doc in (tqdm.tqdm.__init__.__doc__, tqdm.cli.CLI_EXTRA_DOC):
29+
for doc in (tqdm.tqdm.__doc__, tqdm.cli.CLI_EXTRA_DOC):
3130
options.update(doc2opt(doc, user_input=False))
3231
options_input.update(doc2opt(doc, user_input=True))
3332
options.difference_update('--' + i for i in ('name',) + tqdm.cli.UNSUPPORTED_OPTS)
3433
options_input &= options
3534
options_input -= {"--log"} # manually dealt with
36-
src_dir = path.abspath(path.dirname(__file__))
3735
completion = u"""\
3836
#!/usr/bin/env bash
3937
_tqdm(){{
@@ -58,6 +56,5 @@ def doc2opt(doc, user_input=True):
5856
""".format(opts=' '.join(sorted(options)), opts_manual='|'.join(sorted(options_input)))
5957

6058
if __name__ == "__main__":
61-
fncompletion = path.join(path.dirname(src_dir), 'tqdm', 'completion.sh')
62-
with io_open(fncompletion, mode='w', encoding='utf-8') as fd:
63-
fd.write(completion)
59+
(Path(__file__).resolve().parent.parent / 'tqdm' / 'completion.sh').write_text(
60+
completion, encoding='utf-8')

.meta/mkdocs.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
Auto-generate README.rst from .meta/.readme.rst and docstrings.
33
"""
44
import sys
5-
from io import open as io_open
6-
from os import path
5+
from pathlib import Path
76
from textwrap import dedent
87

9-
sys.path.insert(0, path.dirname(path.dirname(__file__)))
8+
sys.path.insert(0, str(Path(__file__).parent.parent))
109
import tqdm # NOQA
1110
import tqdm.cli # NOQA
1211

@@ -42,13 +41,13 @@ def doc2rst(doc, arglist=True, raw=False):
4241
return doc
4342

4443

45-
src_dir = path.abspath(path.dirname(__file__))
46-
README_rst = path.join(src_dir, '.readme.rst')
47-
with io_open(README_rst, mode='r', encoding='utf-8') as fd:
48-
README_rst = fd.read()
49-
DOC_tqdm = doc2rst(tqdm.tqdm.__doc__, False).replace('\n', '\n ')
50-
DOC_tqdm_init = doc2rst(tqdm.tqdm.__init__.__doc__)
51-
DOC_tqdm_init_args = DOC_tqdm_init.partition(doc2rst(HEAD_ARGS))[-1].replace('\n ', '\n ')
44+
src_dir = Path(__file__).parent.resolve()
45+
README_rst = (src_dir / '.readme.rst').read_text("utf-8")
46+
class_doc, init_doc = tqdm.tqdm.__doc__.split('\n\n', 1)
47+
DOC_tqdm = doc2rst(class_doc + '\n', False).replace('\n', '\n ')
48+
DOC_tqdm_init = doc2rst('\n' + init_doc)
49+
DOC_tqdm_init_args = DOC_tqdm_init.partition(doc2rst(HEAD_ARGS))[-1].replace(
50+
'\n ', '\n ').replace('\n ', '\n ')
5251
DOC_tqdm_init_args, _, DOC_tqdm_init_rets = DOC_tqdm_init_args.partition(doc2rst(HEAD_RETS))
5352
DOC_cli = doc2rst(tqdm.cli.CLI_EXTRA_DOC).partition(doc2rst(HEAD_CLI))[-1]
5453
DOC_tqdm_tqdm = {}
@@ -70,6 +69,4 @@ def doc2rst(doc, arglist=True, raw=False):
7069
README_rst = README_rst.replace('{DOC_tqdm.tqdm.%s}' % k, v)
7170

7271
if __name__ == "__main__":
73-
fndoc = path.join(path.dirname(src_dir), 'README.rst')
74-
with io_open(fndoc, mode='w', encoding='utf-8') as fd:
75-
fd.write(README_rst)
72+
(src_dir.parent / 'README.rst').write_text(README_rst, encoding='utf-8')

.meta/mksnap.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
Auto-generate snapcraft.yaml.
44
"""
55
import sys
6-
from io import open as io_open
7-
from os import path
6+
from pathlib import Path
87
from subprocess import check_output # nosec
98

10-
sys.path.insert(1, path.dirname(path.dirname(__file__)))
9+
sys.path.insert(1, str(Path(__file__).parent.parent))
1110
import tqdm # NOQA
1211

13-
src_dir = path.abspath(path.dirname(__file__))
1412
snap_yml = r"""name: tqdm
1513
summary: A fast, extensible CLI progress bar
1614
description: |
@@ -65,9 +63,8 @@
6563
command: bin/tqdm
6664
completer: completion.sh
6765
""".format(version=tqdm.__version__, commit=check_output([
68-
'git', 'describe', '--always']).decode('U8').strip()) # nosec
69-
fname = path.join(path.dirname(src_dir), 'snapcraft.yaml')
66+
'git', 'describe', '--always']).decode('utf-8').strip()) # nosec
7067

7168
if __name__ == "__main__":
72-
with io_open(fname, mode='w', encoding='utf-8') as fd:
73-
fd.write(snap_yml.decode('U8') if hasattr(snap_yml, 'decode') else snap_yml)
69+
(Path(__file__).resolve().parent.parent / 'snapcraft.yaml').write_text(
70+
snap_yml.decode('utf-8') if hasattr(snap_yml, 'decode') else snap_yml, encoding='utf-8')

DEMO.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"metadata": {},
66
"source": [
77
"<h1 align=\"center\">tqdm</h1>\n",
8-
"<img src=\"https://img.tqdm.ml/logo.gif\" align=\"left\" />\n",
8+
"<img src=\"https://tqdm.github.io/img/logo.gif\" align=\"left\" />\n",
99
"\n",
1010
"[![Py-Versions](https://img.shields.io/pypi/pyversions/tqdm.svg?logo=python&logoColor=white)](https://pypi.org/project/tqdm)|[![Versions](https://img.shields.io/pypi/v/tqdm.svg)](https://tqdm.github.io/releases)|[![Conda-Forge-Status](https://img.shields.io/conda/v/conda-forge/tqdm.svg?label=conda-forge&logo=conda-forge)](https://anaconda.org/conda-forge/tqdm)|[![Docker](https://img.shields.io/badge/docker-pull-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/tqdm/tqdm)|[![Snapcraft](https://img.shields.io/badge/snap-install-82BEA0.svg?logo=snapcraft)](https://snapcraft.io/tqdm)\n",
1111
"-|-|-|-|-\n",
@@ -58,7 +58,7 @@
5858
"cell_type": "markdown",
5959
"metadata": {},
6060
"source": [
61-
"![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",
61+
"![Screenshot](https://tqdm.github.io/img/tqdm.gif)|[![Video](https://tqdm.github.io/img/video.jpg)](https://tqdm.github.io/video) [![Slides](https://tqdm.github.io/img/slides.jpg)](https://tqdm.github.io/PyData2019/slides.html) [![Merch](https://tqdm.github.io/img/merch.jpg)](https://tqdm.github.io/merch)\n",
6262
"-|-\n",
6363
"\n",
6464
"It can also be executed as a module with pipes:"
@@ -737,7 +737,7 @@
737737
"bars and colour hints (blue: normal, green: completed, red:\n",
738738
"error/interrupt, light blue: no ETA); as demonstrated below.\n",
739739
"\n",
740-
"![Screenshot-Jupyter3](https://img.tqdm.ml/jupyter-3.gif)\n",
740+
"![Screenshot-Jupyter3](https://tqdm.github.io/img/jupyter-3.gif)\n",
741741
"\n",
742742
"The `notebook` version supports percentage or pixels for overall width\n",
743743
"(e.g.: `ncols='100%'` or `ncols='480px'`).\n",
@@ -843,7 +843,7 @@
843843
"specify any file-like object using the `file` argument. For example,\n",
844844
"this can be used to redirect the messages writing to a log file or class.\n",
845845
"\n",
846-
"[![README-Hits](https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&style=social&r=https://github.com/tqdm/tqdm&l=https://img.tqdm.ml/favicon.png&f=https://img.tqdm.ml/logo.gif)](https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&a=plot&r=https://github.com/tqdm/tqdm&l=https://img.tqdm.ml/favicon.png&f=https://img.tqdm.ml/logo.gif&style=social)|(Since 19 May 2016)\n",
846+
"[![README-Hits](https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&style=social&r=https://github.com/tqdm/tqdm&l=https://tqdm.github.io/img/favicon.png&f=https://tqdm.github.io/img/logo.gif)](https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&a=plot&r=https://github.com/tqdm/tqdm&l=https://tqdm.github.io/img/favicon.png&f=https://tqdm.github.io/img/logo.gif&style=social)|(Since 19 May 2016)\n",
847847
"-|-"
848848
]
849849
},

0 commit comments

Comments
 (0)