mirror of https://github.com/tqdm/tqdm.git
bump version, merge pull request #1085 from tqdm/devel
This commit is contained in:
commit
668fa0ea9c
|
@ -35,7 +35,8 @@ jobs:
|
|||
python-version: '3.x'
|
||||
- uses: reviewdog/action-setup@v1
|
||||
- run: pip install -U flake8
|
||||
- name: flake8
|
||||
- if: github.event_name != 'schedule'
|
||||
name: flake8
|
||||
run: |
|
||||
set -o pipefail
|
||||
flake8 -j8 --count --statistics . | \
|
||||
|
@ -57,9 +58,8 @@ jobs:
|
|||
run: |
|
||||
pip install -U wheel
|
||||
pip install -U virtualenv asv
|
||||
git checkout master && git checkout -
|
||||
asv machine --machine github-actions --yes
|
||||
git fetch --tags
|
||||
git fetch origin master:master
|
||||
- name: Restore previous results
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
|
@ -85,6 +85,8 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
@ -92,9 +94,8 @@ jobs:
|
|||
run: |
|
||||
pip install -U wheel
|
||||
pip install -U virtualenv asv
|
||||
git checkout master && git checkout -
|
||||
asv machine --machine github-actions --yes
|
||||
git fetch --tags
|
||||
git fetch origin master:master
|
||||
- name: Restore previous results
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
name: Comment Bot
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created, edited]
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created, edited]
|
||||
|
||||
types: [created]
|
||||
jobs:
|
||||
tag: # /tag <tagname> <commit>
|
||||
if: startsWith(github.event.comment.body, '/tag ')
|
||||
|
@ -21,7 +20,6 @@ jobs:
|
|||
post = (context.eventName == "issue_comment"
|
||||
? github.reactions.createForIssueComment
|
||||
: github.reactions.createForPullRequestReviewComment)
|
||||
|
||||
if (!["admin", "write"].includes(perm.data.permission)){
|
||||
post({
|
||||
owner: context.repo.owner, repo: context.repo.repo,
|
||||
|
@ -50,7 +48,3 @@ jobs:
|
|||
post({
|
||||
owner: context.repo.owner, repo: context.repo.repo,
|
||||
comment_id: context.payload.comment.id, content: "rocket"})
|
||||
always:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo prevent failure when other jobs are skipped
|
||||
|
|
|
@ -919,9 +919,7 @@ 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. Otherwise (if terminal is required),
|
||||
``def __new__()`` to call ``cls.get_new()`` (see below) to ensure correct
|
||||
nested positioning.
|
||||
terminal ``status_printer`` creation.
|
||||
2. Redefine: ``close()``, ``clear()``, ``display()``.
|
||||
|
||||
Consider overloading ``display()`` to use e.g.
|
||||
|
@ -935,23 +933,6 @@ 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
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
21
README.rst
21
README.rst
|
@ -1136,9 +1136,7 @@ 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. Otherwise (if terminal is required),
|
||||
``def __new__()`` to call ``cls.get_new()`` (see below) to ensure correct
|
||||
nested positioning.
|
||||
terminal ``status_printer`` creation.
|
||||
2. Redefine: ``close()``, ``clear()``, ``display()``.
|
||||
|
||||
Consider overloading ``display()`` to use e.g.
|
||||
|
@ -1152,23 +1150,6 @@ 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
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -62,9 +62,6 @@ class tqdm_asyncio(std_tqdm):
|
|||
yield from cls(asyncio.as_completed(fs, loop=loop, timeout=timeout),
|
||||
total=total, **tqdm_kwargs)
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
return cls.get_new(super(tqdm_asyncio, cls), std_tqdm, *args, **kwargs)
|
||||
|
||||
|
||||
def tarange(*args, **kwargs):
|
||||
"""
|
||||
|
|
|
@ -102,9 +102,6 @@ class tqdm_discord(tqdm_auto):
|
|||
fmt['bar_format'] = '{l_bar}{bar:10u}{r_bar}'
|
||||
self.dio.write(self.format_meter(**fmt))
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
return cls.get_new(super(tqdm_discord, cls), tqdm_auto, *args, **kwargs)
|
||||
|
||||
|
||||
def tdrange(*args, **kwargs):
|
||||
"""
|
||||
|
|
|
@ -106,10 +106,6 @@ class tqdm_telegram(tqdm_auto):
|
|||
fmt['bar_format'] = '{l_bar}{bar:10u}{r_bar}'
|
||||
self.tgio.write(self.format_meter(**fmt))
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
return cls.get_new(
|
||||
super(tqdm_telegram, cls), tqdm_auto, *args, **kwargs)
|
||||
|
||||
|
||||
def ttgrange(*args, **kwargs):
|
||||
"""
|
||||
|
|
32
tqdm/std.py
32
tqdm/std.py
|
@ -225,6 +225,7 @@ class tqdm(Comparable):
|
|||
|
||||
monitor_interval = 10 # set to 0 to disable the thread
|
||||
monitor = None
|
||||
_instances = WeakSet()
|
||||
|
||||
@staticmethod
|
||||
def format_sizeof(num, suffix='', divisor=1000):
|
||||
|
@ -554,15 +555,10 @@ class tqdm(Comparable):
|
|||
n_fmt, unit, elapsed_str, rate_fmt, postfix)
|
||||
|
||||
def __new__(cls, *_, **__):
|
||||
# Create a new instance
|
||||
instance = object.__new__(cls)
|
||||
# Construct the lock if it does not exist
|
||||
with cls.get_lock():
|
||||
# Add to the list of instances
|
||||
if not hasattr(cls, '_instances'):
|
||||
cls._instances = WeakSet()
|
||||
with cls.get_lock(): # also constructs lock if non-existent
|
||||
cls._instances.add(instance)
|
||||
# Create the monitoring thread
|
||||
# create monitoring thread
|
||||
if cls.monitor_interval and (cls.monitor is None or not
|
||||
cls.monitor.report()):
|
||||
try:
|
||||
|
@ -572,28 +568,6 @@ class tqdm(Comparable):
|
|||
" (monitor_interval = 0) due to:\n" + str(e),
|
||||
TqdmMonitorWarning, stacklevel=2)
|
||||
cls.monitor_interval = 0
|
||||
# Return the instance
|
||||
return instance
|
||||
|
||||
@classmethod
|
||||
def get_new(cls, super_cls, base_cls, *args, **kwargs):
|
||||
"""
|
||||
Workaround for mixed-class same-stream nested progressbars.
|
||||
See [#509](https://github.com/tqdm/tqdm/issues/509)
|
||||
"""
|
||||
with cls.get_lock():
|
||||
try:
|
||||
cls._instances = base_cls._instances
|
||||
except AttributeError:
|
||||
pass
|
||||
instance = super_cls.__new__(cls, *args, **kwargs)
|
||||
with cls.get_lock():
|
||||
try:
|
||||
# `base_cls` may have been changed so update
|
||||
cls._instances.update(base_cls._instances)
|
||||
except AttributeError:
|
||||
pass
|
||||
base_cls._instances = cls._instances
|
||||
return instance
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue