Skip to content

Commit

Permalink
bump version, merge pull request #1491 from tqdm/envwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Aug 9, 2023
2 parents 87414bc + d434a3c commit d69cc90
Show file tree
Hide file tree
Showing 16 changed files with 339 additions and 230 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/check.yml
Expand Up @@ -16,22 +16,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: pip install -U tox
- run: tox
env:
TOXENV: ${{ matrix.TOXENV }}
asvfull:
if: (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')) || github.event_name == 'schedule'
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || github.event_name == 'schedule'
name: Benchmark (Full)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN || github.token }}
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install
run: |
pip install -U wheel
Expand All @@ -58,14 +61,16 @@ jobs:
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
testasv:
if: github.event.ref != 'refs/heads/master' && ! startsWith(github.event.ref, 'refs/tags')
if: github.ref != 'refs/heads/master' && ! startsWith(github.ref, 'refs/tags')
name: Benchmark (Branch)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install
run: |
pip install -U wheel
Expand All @@ -82,6 +87,6 @@ jobs:
- name: Benchmark
run: |
asv continuous --interleave-processes --only-changed -f 1.25 master HEAD
CHANGES="$(asv compare --only-changed -f 1.25 master HEAD)"
echo "$CHANGES"
[ -z "$CHANGES" ] || exit 1
CHANGES=$(asv compare --only-changed -f 1.25 master HEAD)
echo "$CHANGES" >> "$GITHUB_STEP_SUMMARY"
test -z "$CHANGES" || exit 1
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -153,7 +153,7 @@ jobs:
tag="${GITHUB_REF#refs/tags/}"
gh release create --title "tqdm $tag stable" --draft --notes "$changelog" "$tag" dist/${{ steps.dist.outputs.whl }} dist/${{ steps.dist.outputs.whl_asc }}
env:
GH_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- uses: snapcore/action-build@v1
id: snap_build
- if: github.event_name == 'push' && steps.collect_assets.outputs.snap_channel
Expand Down
39 changes: 23 additions & 16 deletions .meta/.readme.rst
Expand Up @@ -255,7 +255,7 @@ This can be beautified further:

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

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

Expand All @@ -345,12 +349,14 @@ Documentation
class tqdm():
"""{DOC_tqdm}"""
@envwrap("TQDM_", is_method=True) # override defaults via env vars
def __init__(self, iterable=None, desc=None, total=None, leave=True,
file=None, ncols=None, mininterval=0.1,
maxinterval=10.0, miniters=None, ascii=None, disable=False,
unit='it', unit_scale=False, dynamic_ncols=False,
smoothing=0.3, bar_format=None, initial=0, position=None,
postfix=None, unit_divisor=1000):
postfix=None, unit_divisor=1000, write_bytes=False,
lock_args=None, nrows=None, colour=None, delay=0):
Parameters
~~~~~~~~~~
Expand Down Expand Up @@ -1183,16 +1189,17 @@ are:
==================== ======================================================== ==== ================================
Name ID SLoC Notes
==================== ======================================================== ==== ================================
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>`__ ~4%
Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~80% primary maintainer |Gift-Casper|
Stephen Larroque `lrq3000 <https://github.com/lrq3000>`__ ~9% team member
Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~3%
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%
Helio Machado `0x2b3bfa0 <https://github.com/0x2b3bfa0>`__ ~1%
Kyle Altendorf `altendky <https://github.com/altendky>`__ <1%
Noam Yorav-Raphael `noamraph <https://github.com/noamraph>`__ <1% original author
Matthew Stevens `mjstevens777 <https://github.com/mjstevens777>`__ <1%
Hadrien Mary `hadim <https://github.com/hadim>`__ <1% team member
Noam Yorav-Raphael `noamraph <https://github.com/noamraph>`__ <1% original author
Mikhail Korobov `kmike <https://github.com/kmike>`__ <1% team member
==================== ======================================================== ==== ================================

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

|README-Hits| (Since 19 May 2016)

.. |Logo| image:: https://img.tqdm.ml/logo.gif
.. |Screenshot| image:: https://img.tqdm.ml/tqdm.gif
.. |Video| image:: https://img.tqdm.ml/video.jpg
.. |Logo| image:: https://tqdm.github.io/img/logo.gif
.. |Screenshot| image:: https://tqdm.github.io/img/tqdm.gif
.. |Video| image:: https://tqdm.github.io/img/video.jpg
:target: https://tqdm.github.io/video
.. |Slides| image:: https://img.tqdm.ml/slides.jpg
.. |Slides| image:: https://tqdm.github.io/img/slides.jpg
:target: https://tqdm.github.io/PyData2019/slides.html
.. |Merch| image:: https://img.tqdm.ml/merch.jpg
.. |Merch| image:: https://tqdm.github.io/img/merch.jpg
:target: https://tqdm.github.io/merch
.. |Build-Status| image:: https://img.shields.io/github/actions/workflow/status/tqdm/tqdm/test.yml?branch=master&label=tqdm&logo=GitHub
:target: https://github.com/tqdm/tqdm/actions/workflows/test.yml
Expand Down Expand Up @@ -1274,8 +1281,8 @@ Citation information: |DOI|
:target: https://doi.org/10.5281/zenodo.595120
.. |binder-demo| image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/tqdm/tqdm/master?filepath=DEMO.ipynb
.. |Screenshot-Jupyter1| image:: https://img.tqdm.ml/jupyter-1.gif
.. |Screenshot-Jupyter2| image:: https://img.tqdm.ml/jupyter-2.gif
.. |Screenshot-Jupyter3| image:: https://img.tqdm.ml/jupyter-3.gif
.. |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
: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
.. |Screenshot-Jupyter1| image:: https://tqdm.github.io/img/jupyter-1.gif
.. |Screenshot-Jupyter2| image:: https://tqdm.github.io/img/jupyter-2.gif
.. |Screenshot-Jupyter3| image:: https://tqdm.github.io/img/jupyter-3.gif
.. |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
: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
13 changes: 5 additions & 8 deletions .meta/mkcompletion.py
Expand Up @@ -3,10 +3,9 @@
"""
import re
import sys
from io import open as io_open
from os import path
from pathlib import Path

sys.path.insert(0, path.dirname(path.dirname(__file__)))
sys.path.insert(0, str(Path(__file__).parent.parent))
import tqdm # NOQA
import tqdm.cli # NOQA

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

if __name__ == "__main__":
fncompletion = path.join(path.dirname(src_dir), 'tqdm', 'completion.sh')
with io_open(fncompletion, mode='w', encoding='utf-8') as fd:
fd.write(completion)
(Path(__file__).resolve().parent.parent / 'tqdm' / 'completion.sh').write_text(
completion, encoding='utf-8')
23 changes: 10 additions & 13 deletions .meta/mkdocs.py
Expand Up @@ -2,11 +2,10 @@
Auto-generate README.rst from .meta/.readme.rst and docstrings.
"""
import sys
from io import open as io_open
from os import path
from pathlib import Path
from textwrap import dedent

sys.path.insert(0, path.dirname(path.dirname(__file__)))
sys.path.insert(0, str(Path(__file__).parent.parent))
import tqdm # NOQA
import tqdm.cli # NOQA

Expand Down Expand Up @@ -42,13 +41,13 @@ def doc2rst(doc, arglist=True, raw=False):
return doc


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

if __name__ == "__main__":
fndoc = path.join(path.dirname(src_dir), 'README.rst')
with io_open(fndoc, mode='w', encoding='utf-8') as fd:
fd.write(README_rst)
(src_dir.parent / 'README.rst').write_text(README_rst, encoding='utf-8')
13 changes: 5 additions & 8 deletions .meta/mksnap.py
Expand Up @@ -3,14 +3,12 @@
Auto-generate snapcraft.yaml.
"""
import sys
from io import open as io_open
from os import path
from pathlib import Path
from subprocess import check_output # nosec

sys.path.insert(1, path.dirname(path.dirname(__file__)))
sys.path.insert(1, str(Path(__file__).parent.parent))
import tqdm # NOQA

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

if __name__ == "__main__":
with io_open(fname, mode='w', encoding='utf-8') as fd:
fd.write(snap_yml.decode('U8') if hasattr(snap_yml, 'decode') else snap_yml)
(Path(__file__).resolve().parent.parent / 'snapcraft.yaml').write_text(
snap_yml.decode('utf-8') if hasattr(snap_yml, 'decode') else snap_yml, encoding='utf-8')
8 changes: 4 additions & 4 deletions DEMO.ipynb
Expand Up @@ -5,7 +5,7 @@
"metadata": {},
"source": [
"<h1 align=\"center\">tqdm</h1>\n",
"<img src=\"https://img.tqdm.ml/logo.gif\" align=\"left\" />\n",
"<img src=\"https://tqdm.github.io/img/logo.gif\" align=\"left\" />\n",
"\n",
"[![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",
"-|-|-|-|-\n",
Expand Down 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) [![Merch](https://img.tqdm.ml/merch.jpg)](https://tqdm.github.io/merch)\n",
"![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",
"-|-\n",
"\n",
"It can also be executed as a module with pipes:"
Expand Down Expand Up @@ -737,7 +737,7 @@
"bars and colour hints (blue: normal, green: completed, red:\n",
"error/interrupt, light blue: no ETA); as demonstrated below.\n",
"\n",
"![Screenshot-Jupyter3](https://img.tqdm.ml/jupyter-3.gif)\n",
"![Screenshot-Jupyter3](https://tqdm.github.io/img/jupyter-3.gif)\n",
"\n",
"The `notebook` version supports percentage or pixels for overall width\n",
"(e.g.: `ncols='100%'` or `ncols='480px'`).\n",
Expand Down Expand Up @@ -843,7 +843,7 @@
"specify any file-like object using the `file` argument. For example,\n",
"this can be used to redirect the messages writing to a log file or class.\n",
"\n",
"[![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",
"[![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",
"-|-"
]
},
Expand Down

0 comments on commit d69cc90

Please sign in to comment.