A generic, reusable task management system built with FastAPI and asyncio
Project description
Brinjal
A generic, reusable task management system built with FastAPI and asyncio. Brinjal provides a flexible foundation for building task-based applications with real-time progress updates via Server-Sent Events (SSE).
Features
- Generic Task Management: Base
Taskclass that can be extended for any type of task - Real-time Updates: Server-Sent Events (SSE) for live progress updates
- Asynchronous Execution: Built on asyncio for high-performance task processing
- Flexible Integration: No hardcoded prefixes - easily integrated into any FastAPI application
- Web Components: Reusable frontend components for displaying tasks
- Progress Tracking: Built-in progress monitoring and status updates
Quick Start
Installation
pip install brinjal
Running the Development Server
# Clone the repository
git clone https://github.com/sg-s/brinjal.git
cd brinjal
# Install dependencies
uv sync
# Run the development server
make dev
The server will start at http://localhost:8000.
End-to-End Testing
- Start the server:
make dev - Add a task:
curl -X POST http://localhost:8000/api/tasks/example_task - View the test page: Open
http://localhost:8000/api/tasks/testin your browser - Watch real-time updates: The task will appear and progress in real-time
Usage in Other Projects
Basic Integration
from fastapi import FastAPI
from brinjal.api.router import router as brinjal_router
app = FastAPI()
# Include brinjal with your desired prefix
app.include_router(brinjal_router, prefix="/api/tasks")
Advanced Integration with Custom Endpoints
from fastapi import APIRouter
from brinjal.api.router import router as brinjal_router
from brinjal.manager import task_manager
# Create your main router with the desired prefix
router = APIRouter(prefix="/api/tasks")
# Include all of brinjal's functionality
router.include_router(brinjal_router)
# Add your custom endpoints
@router.post("/custom_task")
async def custom_task():
# Your custom logic here
pass
# Include in your main app
app.include_router(router)
Frontend Integration
<!-- Load the TaskList component from your brinjal endpoint -->
<script src="/api/tasks/static/TaskList.js"></script>
<!-- Use the component -->
<task-list base_url="https://yourdomain.com"></task-list>
API Reference
Core Endpoints
GET /api/tasks/queue- Get all tasksPOST /api/tasks/example_task- Create an example taskGET /api/tasks/{task_id}/stream- Stream task updates via SSEGET /api/tasks/static/{file}- Static files (TaskList.js, etc.)
Data Models
- TaskUpdate: Generic task update model with
task_id,task_type,status,progress,img,heading,body
Development
Running Tests
# Run all tests
make test
# Run specific test suites
make test-task-manager
make test-example-task
# Run with coverage
make test-cov
Building Documentation
make docs
Building the Package
make build
Architecture
Brinjal is designed with separation of concerns in mind:
Task: Base class for all tasks with common functionalityTaskManager: Manages task execution and SSE event generationExampleTask: Concrete implementation demonstrating task patterns- Router: FastAPI router with generic endpoints (no hardcoded prefixes)
- Static Files: Web components and assets for frontend integration
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE.txt for details.
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 brinjal-0.1.2.tar.gz.
File metadata
- Download URL: brinjal-0.1.2.tar.gz
- Upload date:
- Size: 732.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3012bca1e6872ebbd98ccd74b1cdcdafa569e717875d1a4c9d5d052b573c483a
|
|
| MD5 |
52b4e881eab15482239cf0333da581e7
|
|
| BLAKE2b-256 |
79bce8d17a0ac6644dd55858a0b346183fdc7245d7ecd118ca0c1b61ee652fb0
|
Provenance
The following attestation bundles were made for brinjal-0.1.2.tar.gz:
Publisher:
pypi.yml on sg-s/brinjal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brinjal-0.1.2.tar.gz -
Subject digest:
3012bca1e6872ebbd98ccd74b1cdcdafa569e717875d1a4c9d5d052b573c483a - Sigstore transparency entry: 407391012
- Sigstore integration time:
-
Permalink:
sg-s/brinjal@704d9aaa3fffca529041c295963bfc01a62a43ab -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/sg-s
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@704d9aaa3fffca529041c295963bfc01a62a43ab -
Trigger Event:
push
-
Statement type:
File details
Details for the file brinjal-0.1.2-py3-none-any.whl.
File metadata
- Download URL: brinjal-0.1.2-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c133a0a1d460666f4bca006a535d7383eebdc151910dccd03ca820fe237b2c90
|
|
| MD5 |
d00ead7b9333f0ca4555542cef78d268
|
|
| BLAKE2b-256 |
5746da789070c8f3702f285c0f93a197590a2fdab7143e4197e7e138be314804
|
Provenance
The following attestation bundles were made for brinjal-0.1.2-py3-none-any.whl:
Publisher:
pypi.yml on sg-s/brinjal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brinjal-0.1.2-py3-none-any.whl -
Subject digest:
c133a0a1d460666f4bca006a535d7383eebdc151910dccd03ca820fe237b2c90 - Sigstore transparency entry: 407391052
- Sigstore integration time:
-
Permalink:
sg-s/brinjal@704d9aaa3fffca529041c295963bfc01a62a43ab -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/sg-s
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@704d9aaa3fffca529041c295963bfc01a62a43ab -
Trigger Event:
push
-
Statement type: