Skip to content

Commit

Permalink
bump version, merge pull request #1075 from tqdm/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Nov 21, 2020
2 parents db86b89 + 04c567d commit 819f6e0
Show file tree
Hide file tree
Showing 27 changed files with 456 additions and 498 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,42 @@ on:
- cron: '36 1 * * SUN' # M H d m w (Sundays at 01:36)
jobs:
check:
name: '${{ matrix.TOXENV }}'
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
name: ${{ matrix.TOXENV }}
strategy:
matrix:
TOXENV:
- flake8,setup.py
- setup.py
- perf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install
run: pip install -U tox
- name: Test
run: tox
- run: pip install -U tox
- run: tox
env:
TOXENV: ${{ matrix.TOXENV }}
lint:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- uses: reviewdog/action-setup@v1
- run: pip install -U flake8
- name: flake8
run: |
set -o pipefail
flake8 -j8 --count --statistics . | \
reviewdog -f=pep8 -name=flake8 -tee -reporter=github-check -filter-mode nofilter
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
asvfull:
if: (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')) || github.event_name == 'schedule'
name: Benchmark (Full)
Expand Down
36 changes: 29 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ on:
- cron: '2 1 * * 6' # M H d m w (Saturdays at 1:02)
jobs:
check:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
name: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- run: pip install .
test-os:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
strategy:
matrix:
python: [2.7, 3.7]
Expand All @@ -23,27 +27,46 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- run: pip install -U tox
- name: install
shell: bash
run: |
pip install -U tox
mkdir -p "$HOME/bin"
curl -sfL https://coverage.codacy.com/get.sh > "$HOME/bin/codacy"
chmod +x "$HOME/bin/codacy"
echo "$HOME/bin" >> $GITHUB_PATH
- run: tox -e py${PYVER/./}
shell: bash
env:
PYVER: ${{ matrix.python }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
test:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
strategy:
matrix:
python: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
name: py${{ matrix.python }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- run: pip install -U tox
- name: install
run: |
pip install -U tox
mkdir -p "$HOME/bin"
curl -sfL https://coverage.codacy.com/get.sh > "$HOME/bin/codacy"
chmod +x "$HOME/bin/codacy"
echo "$HOME/bin" >> $GITHUB_PATH
- name: tox
run: |
if [[ "$PYVER" == py* ]]; then
Expand All @@ -66,6 +89,7 @@ jobs:
with:
parallel: true
finish:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
name: pytest cov
continue-on-error: ${{ github.event_name != 'push' }}
needs: [test, test-os]
Expand All @@ -76,18 +100,19 @@ jobs:
with:
parallel-finished: true
deploy:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
needs: [check, test, test-os]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install
run: |
sudo apt-get install -yqq pandoc
pip install setuptools_scm
git fetch --unshallow --tags
pip install .[dev]
make build .dockerignore snapcraft.yaml
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
Expand All @@ -98,7 +123,6 @@ jobs:
skip_existing: true
- id: collect_assets
name: Collect assets
shell: bash
run: |
echo "::set-output name=asset_path::$(ls dist/*.whl)"
echo "::set-output name=asset_name::$(basename dist/*.whl)"
Expand Down Expand Up @@ -148,7 +172,6 @@ jobs:
with:
use_lxd: true
- name: Snap build
shell: bash
run: |
export SNAPCRAFT_IMAGE_INFO='{"build_url": "https://github.com/tqdm/tqdm/actions/runs/'$GITHUB_RUN_ID'"}'
sg lxd -c 'snapcraft --use-lxd'
Expand All @@ -162,7 +185,6 @@ jobs:
snapcraft_token: ${{ secrets.SNAP_TOKEN }}
- if: github.event_name == 'push' && steps.collect_assets.outputs.snap_channel
name: Snap deploy
shell: bash
run: |
if [ -n "$(ls tqdm*.snap 2>/dev/null)" ]; then
sudo snapcraft upload tqdm*.snap --release $CHANNEL
Expand Down
14 changes: 8 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
*.so

# Packages
tqdm.egg-info
build/
dist/
snapcraft.yaml
tqdm_*_amd64.snap
.dockerignore
/tqdm/_dist_ver.py
/.eggs/
/tqdm.egg-info
/build/
/dist/
/snapcraft.yaml
/tqdm_*_amd64.snap
/.dockerignore

# Unit test / coverage reports
.tox/
Expand Down
51 changes: 48 additions & 3 deletions .meta/.readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ There are 3 channels to choose from:
snap install tqdm --candidate # master branch
snap install tqdm --edge # devel branch
Note than ``snap`` binaries are purely for CLI use (not ``import``-able), and
Note that ``snap`` binaries are purely for CLI use (not ``import``-able), and
automatically set up ``bash`` tab-completion.

Latest Docker release
Expand Down Expand Up @@ -577,7 +577,8 @@ 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.
However, it's best to check if `tqdm` can work without manual `position` first.
However, it's best to check if ``tqdm`` can work without manual ``position``
first.

.. code:: python
Expand Down Expand Up @@ -744,6 +745,31 @@ custom callback take advantage of this, simply use the return value of
external_callback(**self.format_dict)
return displayed
``asyncio``
~~~~~~~~~~~

Note that ``break`` isn't currently caught by asynchronous iterators.
This means that ``tqdm`` cannot clean up after itself in this case:

.. code:: python
from tqdm.asyncio import tqdm
async for i in tqdm(range(9)):
if i == 2:
break
Instead, either call ``pbar.close()`` manually or use the context manager syntax:

.. code:: python
from tqdm.asyncio import tqdm
with tqdm(range(9)) as pbar:
async for i in pbar:
if i == 2:
break
Pandas Integration
~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -893,7 +919,9 @@ For further customisation,
(e.g. GUIs such as notebook or plotting packages). In the latter case:

1. ``def __init__()`` to call ``super().__init__(..., gui=True)`` to disable
terminal ``status_printer`` creation.
terminal ``status_printer`` creation. Otherwise (if terminal is required),
``def __new__()`` to call ``cls.get_new()`` (see below) to ensure correct
nested positioning.
2. Redefine: ``close()``, ``clear()``, ``display()``.

Consider overloading ``display()`` to use e.g.
Expand All @@ -907,6 +935,23 @@ above recommendation:
- `tqdm/contrib/telegram.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/telegram.py>`__
- `tqdm/contrib/discord.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/discord.py>`__

Note that multiple different ``tqdm`` subclasses which all write to the terminal
(``gui=False``) can cause positioning issues when used simultaneously (in nested
mode). To fix this, custom subclasses which expect to write to the terminal
should define a ``__new__()`` method as follows:

.. code:: python
from tqdm import tqdm as std_tqdm
class TqdmExt(std_tqdm):
def __new__(cls, *args, **kwargs):
return cls.get_new(super(TqdmExt, cls), std_tqdm, *args, **kwargs)
This approach is used ``tqdm.asyncio`` and ``tqdm.contrib.telegram/discord``.
However it is not necessary for ``tqdm.notebook/gui`` since they don't use the
terminal.

Dynamic Monitor/Meter
~~~~~~~~~~~~~~~~~~~~~

Expand Down
34 changes: 28 additions & 6 deletions .meta/.snapcraft.yml → .meta/mksnap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
name: tqdm
# -*- encoding: utf-8 -*-
"""
Auto-generate snapcraft.yaml.
"""
from io import open as io_open
from os import path
from subprocess import check_output
import sys

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

src_dir = path.abspath(path.dirname(__file__))
snap_yml = r"""name: tqdm
summary: A fast, extensible CLI progress bar
description: |
https://tqdm.github.io
Expand Down Expand Up @@ -31,23 +44,32 @@
`tqdm` does not require any dependencies, just
an environment supporting `carriage return \r` and
`line feed \n` control characters.
adopt-info: tqdm
grade: stable
confinement: strict
base: core18
icon: {icon}
icon: logo.png
version: '{version}'
license: MPL-2.0
parts:
tqdm:
plugin: python
python-version: python3
source: {source}
python-packages: [disco-py]
source: .
source-commit: '{commit}'
parse-info: [setup.py]
build-packages: [git]
override-build: |
snapcraftctl build
cp $SNAPCRAFT_PART_BUILD/tqdm/completion.sh $SNAPCRAFT_PART_INSTALL/
apps:
tqdm:
command: bin/tqdm
completer: completion.sh
""".format(
version=tqdm.__version__,
commit=check_output(['git', 'describe', '--always']).decode('U8').strip())
fname = path.join(path.dirname(src_dir), 'snapcraft.yaml')

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)

0 comments on commit 819f6e0

Please sign in to comment.