Echo tqdm progress to a prometheus endpoint
Project description
Prometheus exporter for tqdm
Publish your pretty CLI stats for monitoring elsewhere
Usage
There are no security or authentication mechanisms provided, be careful exposing the host more widely
Initalise the proxy
proxy = TqdmPromProxy(http_host='[::1]', http_port=3000, metric_func=metric_formatter_func)
proxy.start()
Use the proxy
Replace tqdm initalisers with proxy.tqdm.
for item in proxy.tqdm(range(100), desc='My first bar')
item.doathing()
with proxy.tqdm(range(100), desc='My second bar') as f:
f.update(50)
# etc
Formatting your content
TQDM bars are a lot more verbose than prometheus metrics. You can customise their names by passing in a function with this signature.
def metric_formatter_func(metric_name: str, metric_property: str, metric_scale: str) -> str:
pass
metric_property is one of:
completedthe number executions thus far in TQDM;totalthe configured expected maximum in TQDM astqdm(total=x);activebased on the naming, how many current bars are being grouped together as this namefinishedbased on the naming, how many bars with this name have been completely finished
The str that is returned must adhere to the metric naming conventions (A-Za-z0-9_) outlined in the prometheus docs https://prometheus.io/docs/practices/naming/
This function is called a lot, so avoid computation or cache your values
Additionally to control which properties are aggregated, provide a bucket_func:
This example will aggregate all bars with a description starting with upload together
def bucketting_func(snapshot: TqdmSnapshot):
if snapshot.desc.lowercase().startswith('upload'):
return "Upload"
return snapshot.desc
If you require tqdm.write for sticky console output,
from tqdm import tqdm as tqdm_og
tqdm_og.write('Job done')
curl http://[::1]:3000/metrics
[!WARNING]
For windows users ensure you add this to your__main__block, and before any initialisation ofTqdmPrometheusProxyfrom multiprocessing import freeze_support freeze_support()
Overview
---
Conceptual Overview
---
flowchart LR
Queue@{ shape: das, label: "Update buffer" }
TQDM@{ shape: process, label: "(your) faux TQDM instance"}
Bucketting@{ shape: process, label: "Metric extraction & aggregation"}
TQDM -- "Periodic Updates" --> Queue
Queue --> Bucketting
Bucketting -- "Expose aggregate metrics" --> HttpServer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tqdm_prometheus_exporter-0.1.12.tar.gz.
File metadata
- Download URL: tqdm_prometheus_exporter-0.1.12.tar.gz
- Upload date:
- Size: 55.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7c2a86ea498e034a2abb157f13f8fae1c0c1cb3ef250d31ae0c65db765a3f4b
|
|
| MD5 |
28ad533de8c232db39fdc891cea6ae76
|
|
| BLAKE2b-256 |
d7442e33d466f1096391e22b9138a9b6ff71b2d9a927c0023aa2ba50ac000171
|
Provenance
The following attestation bundles were made for tqdm_prometheus_exporter-0.1.12.tar.gz:
Publisher:
python-publish.yml on arrowed/tqdm-prometheus-exporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tqdm_prometheus_exporter-0.1.12.tar.gz -
Subject digest:
e7c2a86ea498e034a2abb157f13f8fae1c0c1cb3ef250d31ae0c65db765a3f4b - Sigstore transparency entry: 171914803
- Sigstore integration time:
-
Permalink:
arrowed/tqdm-prometheus-exporter@4fadb62597e2aff1f92652115b5d7ca41c279ee5 -
Branch / Tag:
refs/tags/0.1.12 - Owner: https://github.com/arrowed
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@4fadb62597e2aff1f92652115b5d7ca41c279ee5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tqdm_prometheus_exporter-0.1.12-py3-none-any.whl.
File metadata
- Download URL: tqdm_prometheus_exporter-0.1.12-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cec09c6831130f2e9327c81097875208dc1cf0fb00b754293ffc8c231907393d
|
|
| MD5 |
81bef41c472348d4c8cf2d9bd5d57480
|
|
| BLAKE2b-256 |
ab8862db456acd8eb5a7d96430b155834968e20fbce54e0a9d04a47a28f967e2
|
Provenance
The following attestation bundles were made for tqdm_prometheus_exporter-0.1.12-py3-none-any.whl:
Publisher:
python-publish.yml on arrowed/tqdm-prometheus-exporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tqdm_prometheus_exporter-0.1.12-py3-none-any.whl -
Subject digest:
cec09c6831130f2e9327c81097875208dc1cf0fb00b754293ffc8c231907393d - Sigstore transparency entry: 171914805
- Sigstore integration time:
-
Permalink:
arrowed/tqdm-prometheus-exporter@4fadb62597e2aff1f92652115b5d7ca41c279ee5 -
Branch / Tag:
refs/tags/0.1.12 - Owner: https://github.com/arrowed
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@4fadb62597e2aff1f92652115b5d7ca41c279ee5 -
Trigger Event:
release
-
Statement type: