Python SDK for Progress Bar Tracker - Track and manage progress bars with read/write/admin permissions
Project description
Progress Bar Tracker SDK
A powerful Python SDK for tracking and managing progress bars with granular permission control.
Features
- 🔐 Three-tier Permission System: Read, Write, and Admin keys
- 📊 Easy Progress Tracking: Simple API for creating and updating progress items
- 🔄 Real-time Updates: Monitor long-running tasks with live progress updates
- 🎯 Ownership Control: Write keys can only modify their own items
- 🚀 Auto-detection: Automatically detects API key permissions
- 💪 Type Safe: Full type hints support
Installation
pip install progressbar-tracker
Quick Start
from progressbar_tracker import ProgressBar
# Initialize with your API endpoint and key
pb = ProgressBar(
api_url="http://your-server:8989",
api_key="your-api-key"
)
# Create a new progress item
pb.create(
item_id="video-encoding-001",
title="Encoding Video",
description="Processing 4K video file",
value=0.0,
weight=100 # Higher weight = higher priority in display
)
# Update progress
pb.update(
item_id="video-encoding-001",
title="Encoding Video",
description="50% complete",
value=0.5,
weight=100
)
# Get all items
items = pb.get_all()
for item in items:
print(f"{item['title']}: {item['value']*100:.0f}%")
# Delete when done
pb.delete("video-encoding-001")
API Key Types
Read Key
- ✅ View all progress items
- ❌ Cannot create, update, or delete
pb = ProgressBar(api_url="http://server:8989", api_key="readonly-key-123")
items = pb.get_all() # Works
pb.create(...) # Raises PermissionError
Write Key
- ✅ View all progress items
- ✅ Create new items
- ✅ Update own items only
- ✅ Delete own items only
pb = ProgressBar(api_url="http://server:8989", api_key="write-key-456")
pb.create("my-task", "Task", "Processing...", 0.5) # Works
pb.update("my-task", "Task", "Almost done", 0.9) # Works
pb.update("other-task", ...) # Raises PermissionError
Admin Key
- ✅ Full access to all operations
- ✅ Can modify any item
- ✅ Can delete any item
pb = ProgressBar(api_url="http://server:8989", api_key="admin-key-789")
pb.update("any-task", ...) # Works on any item
pb.delete("any-task") # Can delete any item
Advanced Usage
Check Permissions
pb = ProgressBar(api_url="http://server:8989", api_key="your-key")
if pb.is_admin():
print("You have full admin access")
elif pb.can_write():
print("You can create and modify items")
elif pb.is_read_only():
print("You can only view items")
Error Handling
from progressbar_tracker import ProgressBar, PermissionError
pb = ProgressBar(api_url="http://server:8989", api_key="write-key")
try:
pb.create("task-1", "Task 1", "Running", 0.5)
except PermissionError as e:
print(f"Permission denied: {e}")
except ValueError as e:
print(f"Validation error: {e}")
Disable Auto-detection
# Skip permission detection on initialization (faster)
pb = ProgressBar(
api_url="http://server:8989",
api_key="your-key",
auto_detect=False
)
API Reference
ProgressBar(api_url, api_key, auto_detect=True)
Initialize the SDK client.
Parameters:
api_url(str): Base URL of the progress bar serverapi_key(str): Your API keyauto_detect(bool): Auto-detect key permissions (default: True)
get_all() -> List[Dict]
Retrieve all progress items.
Returns: List of progress item dictionaries
Raises: PermissionError if key lacks read permission
create(item_id, title, description, value, weight=0)
Create a new progress item.
Parameters:
item_id(str): Unique identifiertitle(str): Display titledescription(str): Status descriptionvalue(float): Progress value (0.0 to 1.0)weight(int): Sort priority (default: 0)
Raises:
PermissionErrorif key lacks create permissionValueErrorif item already exists
update(item_id, title, description, value, weight=0)
Update an existing progress item.
Parameters: Same as create()
Raises:
PermissionErrorif key lacks update permissionValueErrorif item doesn't exist
delete(item_id)
Delete a progress item.
Parameters:
item_id(str): ID of item to delete
Raises: PermissionError if key lacks delete permission
Permission Helpers
is_admin() -> bool: Check if key is adminis_read_only() -> bool: Check if key is read-onlycan_write() -> bool: Check if key can create/updatecan_delete() -> bool: Check if key can delete
Real-world Examples
Video Encoding Pipeline
from progressbar_tracker import ProgressBar
import time
pb = ProgressBar(api_url="http://server:8989", api_key="write-key")
# Start encoding
pb.create("video-001", "Encoding: movie.mp4", "Initializing...", 0.0, weight=100)
for progress in range(0, 101, 10):
time.sleep(1)
pb.update(
"video-001",
"Encoding: movie.mp4",
f"Processing frame {progress*10}/1000",
progress / 100.0,
weight=100
)
pb.delete("video-001")
print("✓ Encoding complete!")
Batch Processing
from progressbar_tracker import ProgressBar
pb = ProgressBar(api_url="http://server:8989", api_key="write-key")
files = ["file1.txt", "file2.txt", "file3.txt"]
for i, filename in enumerate(files):
pb.create(
f"process-{i}",
f"Processing {filename}",
"In queue",
0.0,
weight=len(files) - i # Higher weight for earlier files
)
# Process and update
for i, filename in enumerate(files):
# ... do work ...
pb.update(f"process-{i}", f"Processing {filename}", "Complete", 1.0)
pb.delete(f"process-{i}")
Server Setup
This SDK requires a Progress Bar Tracker server. You can deploy one using Docker:
docker run -d \
-p 8989:8080 \
-e ADMIN_USERNAME=admin \
-e ADMIN_PASSWORD=your-password \
progressbar-server:latest
Or see the full documentation for setup instructions.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Links
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 progressbar_tracker-1.0.0.tar.gz.
File metadata
- Download URL: progressbar_tracker-1.0.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
015e6118eaccbf494729058927f500cf40219fe27c783ec3589ec051d25a7f02
|
|
| MD5 |
62afb1ce2a784cd952e9d2c78c178199
|
|
| BLAKE2b-256 |
ba2a2a21719c684ca7dafe579fe2d5c43d45feaf8cc494d18c5de67e15840061
|
File details
Details for the file progressbar_tracker-1.0.0-py3-none-any.whl.
File metadata
- Download URL: progressbar_tracker-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d9fe49d6ed50b0c97158d793652b92bf1ea44d020d9038ae4388dce84af821d
|
|
| MD5 |
d759e0307fcf6061f2676039843debfb
|
|
| BLAKE2b-256 |
db1ec2dd7270f1e64e4f63a0713f4390969a256893fed067a6da0959d2141b79
|