Name | tqdm-publisher JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | Extends the base tqdm progress bar with a subscribe method that can expose updates to external (potentially non-Python) processes. |
upload_time | 2024-05-20 18:09:52 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | BSD 3-Clause License Copyright (c) 2024, CatalystNeuro All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
keywords |
bar
meter
progress
progressbar
progressmeter
publish-subscribe pattern
pubsub
time
tqdm
|
VCS |
![](/static/img/github-24-000000.png) |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
# tqdm-publisher
[![PyPI version](https://badge.fury.io/py/tqdm-publisher.svg)](https://badge.fury.io/py/tqdm-publisher.svg)
[![codecov](https://codecov.io/github/catalystneuro/tqdm_publisher/coverage.svg?branch=main)](https://codecov.io/github/catalystneuro/tqdm_publisher?branch=main)
[![License](https://img.shields.io/pypi/l/tqdm_publisher.svg)](https://github.com/catalystneuro/tqdm_publisher/blob/main/license.txt)
`tqdm_publisher` is a small Python package that allows you to subscribe to updates from `tqdm` progress bars with arbitrary callback functions.
This is useful if you want to use `tqdm` to track the progress of a long-running task, but you also want to do something else with the progress information (e.g., forward it to a user interface, log it to a file, etc.).
## Installation
```bash
pip install tqdm_publisher
```
## Getting Started
### Basic Usage
To monitor the progress of an existing `tqdm` progress bar, simply swap the `tqdm`and `TQDMPublisher` constructors. Then, declare a callback function to handle progress updates, and subscribe it to the `TQDMPublisher` updates using the `subscribe` method _before iteration begins_.
#### Original Code
```python
import random
import time
from tqdm import tqdm
N_TASKS = 100
# Create a list of tasks
durations = [ random.uniform(0, 1.0) for _ in range(N_TASKS) ]
# Create a progress bar
progress_bar = tqdm(durations)
# Iterate over the progress bar
for duration in progress_bar:
time.sleep(duration) # Execute the task
```
#### Modified Code
```python
import random
import time
from tqdm_publisher import TQDMPublisher
N_TASKS = 100
durations = [ random.uniform(0, 1.0) for _ in range(N_TASKS) ]
progress_bar = TQDMPublisher(durations)
# Declare a callback function to handle progress updates
on_update = lambda info: print('Progress Update', info)
# Subscribe the callback to the TQDMPublisher
progress_bar.subscribe(on_update)
for duration in progress_bar:
time.sleep(duration)
```
## Demo
A complete demo of `tqdm_publisher` can be found in the `demo` directory, which shows how to forward progress updates from the same `TQDMPublisher` instance to multiple clients.
To run the demo, first install the dependencies:
```bash
pip install tqdm_publisher[demo]
```
Then, run the base CLI command to start the demo server and client:
```bash
tqdm_publisher demo
```
> **Note:** Alternatively, you can run each part of the demo separately by running `tqdm_publisher demo --server` and `tqdm_publisher demo --client` in separate terminals.
Finally, you can click the Create Progress Bar button to create a new `TQDMPublisher` instance, which will begin updating based on the `TQDMPublisher` instance in the Python script.
Raw data
{
"_id": null,
"home_page": null,
"name": "tqdm-publisher",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "bar, meter, progress, progressbar, progressmeter, publish-subscribe pattern, pubsub, time, tqdm",
"author": null,
"author_email": "Garrett Flynn <garrett.flynn@catalystneuro.com>, Cody Baker <cody.baker@catalystneuro.com>",
"download_url": "https://files.pythonhosted.org/packages/1c/a5/dedf07e40a1db3372db087bc166521e7f8408bd8a42f36e01a42fb14cffb/tqdm_publisher-0.1.1.tar.gz",
"platform": null,
"description": "# tqdm-publisher\n[![PyPI version](https://badge.fury.io/py/tqdm-publisher.svg)](https://badge.fury.io/py/tqdm-publisher.svg)\n[![codecov](https://codecov.io/github/catalystneuro/tqdm_publisher/coverage.svg?branch=main)](https://codecov.io/github/catalystneuro/tqdm_publisher?branch=main)\n[![License](https://img.shields.io/pypi/l/tqdm_publisher.svg)](https://github.com/catalystneuro/tqdm_publisher/blob/main/license.txt)\n\n`tqdm_publisher` is a small Python package that allows you to subscribe to updates from `tqdm` progress bars with arbitrary callback functions.\n\nThis is useful if you want to use `tqdm` to track the progress of a long-running task, but you also want to do something else with the progress information (e.g., forward it to a user interface, log it to a file, etc.).\n\n## Installation\n```bash\npip install tqdm_publisher\n```\n## Getting Started\n### Basic Usage\nTo monitor the progress of an existing `tqdm` progress bar, simply swap the `tqdm`and `TQDMPublisher` constructors. Then, declare a callback function to handle progress updates, and subscribe it to the `TQDMPublisher` updates using the `subscribe` method _before iteration begins_.\n\n#### Original Code\n```python\nimport random\nimport time\n\nfrom tqdm import tqdm\n\nN_TASKS = 100\n\n# Create a list of tasks\ndurations = [ random.uniform(0, 1.0) for _ in range(N_TASKS) ]\n\n# Create a progress bar\nprogress_bar = tqdm(durations)\n\n# Iterate over the progress bar\nfor duration in progress_bar:\n time.sleep(duration) # Execute the task\n```\n\n#### Modified Code\n\n```python\nimport random\nimport time\n\nfrom tqdm_publisher import TQDMPublisher\n\nN_TASKS = 100\ndurations = [ random.uniform(0, 1.0) for _ in range(N_TASKS) ]\nprogress_bar = TQDMPublisher(durations)\n\n# Declare a callback function to handle progress updates\non_update = lambda info: print('Progress Update', info)\n\n# Subscribe the callback to the TQDMPublisher\nprogress_bar.subscribe(on_update)\n\nfor duration in progress_bar:\n time.sleep(duration)\n```\n\n## Demo\nA complete demo of `tqdm_publisher` can be found in the `demo` directory, which shows how to forward progress updates from the same `TQDMPublisher` instance to multiple clients.\n\nTo run the demo, first install the dependencies:\n```bash\npip install tqdm_publisher[demo]\n```\n\nThen, run the base CLI command to start the demo server and client:\n```bash\ntqdm_publisher demo\n```\n\n> **Note:** Alternatively, you can run each part of the demo separately by running `tqdm_publisher demo --server` and `tqdm_publisher demo --client` in separate terminals.\n\nFinally, you can click the Create Progress Bar button to create a new `TQDMPublisher` instance, which will begin updating based on the `TQDMPublisher` instance in the Python script.\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License Copyright (c) 2024, CatalystNeuro All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
"summary": "Extends the base tqdm progress bar with a subscribe method that can expose updates to external (potentially non-Python) processes.",
"version": "0.1.1",
"project_urls": {
"Bug Tracker": "https://github.com/catalystneuro/tqdm_publisher/issues",
"Homepage": "https://github.com/catalystneuro/tqdm_publisher"
},
"split_keywords": [
"bar",
" meter",
" progress",
" progressbar",
" progressmeter",
" publish-subscribe pattern",
" pubsub",
" time",
" tqdm"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "54efb5ffc080f21ac4c352043f0c4cb02722631aab1fabd2179fb8d29d64902f",
"md5": "afc8e494a4142d4ec76069690ed90fd0",
"sha256": "85a9b7a4d04e704f1564f4256feec33677f0e96f364f75f77377eba98c3ac283"
},
"downloads": -1,
"filename": "tqdm_publisher-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "afc8e494a4142d4ec76069690ed90fd0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 23138,
"upload_time": "2024-05-20T18:09:50",
"upload_time_iso_8601": "2024-05-20T18:09:50.541886Z",
"url": "https://files.pythonhosted.org/packages/54/ef/b5ffc080f21ac4c352043f0c4cb02722631aab1fabd2179fb8d29d64902f/tqdm_publisher-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1ca5dedf07e40a1db3372db087bc166521e7f8408bd8a42f36e01a42fb14cffb",
"md5": "bca1377cd6f6732fbd36ff7ebac5e6f1",
"sha256": "9a966153e222b26d5a312ad1c0b7cd2a61f585e7e7d7cc6e68104ef46f2558e3"
},
"downloads": -1,
"filename": "tqdm_publisher-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "bca1377cd6f6732fbd36ff7ebac5e6f1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 22028,
"upload_time": "2024-05-20T18:09:52",
"upload_time_iso_8601": "2024-05-20T18:09:52.238198Z",
"url": "https://files.pythonhosted.org/packages/1c/a5/dedf07e40a1db3372db087bc166521e7f8408bd8a42f36e01a42fb14cffb/tqdm_publisher-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-20 18:09:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "catalystneuro",
"github_project": "tqdm_publisher",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "tqdm-publisher"
}