How hrishikeshchandi/adaptive-rl-task-orchestrator works
This is a distributed task orchestrator: clients submit resource-requirement and priority data, the API stores tasks, workers register and pull capacity-fitting tasks, and the scheduler scores candidates using duration estimates and Q-learning weights. Workers report outcomes, which feed task history and the background learner’s Q-table updates. Recovery and heartbeat services provide retries and dead-worker handling; the README also documents Prometheus/Grafana monitoring and a web dashboard. Unsampled subsystems are included where documented, but their internal links are limited to README evidence.
Main entry points: task.py Task API · main.py FastAPI App · connection.py Tasks and History · workers.py Worker API
Components 20
API Control Plane
- FastAPI App
main.py - Task API
routers/task.py - Worker API
routers/workers.py - Learning API
routers/learning.py - Request and Task Models
models/model.py
Adaptive Scheduling
- Duration Estimator
scheduling/estimator.py - Q-Learning Agent
scheduling/rl_agent.py - Background Learner
scheduling/learner.py
Workers and Recovery
- Worker Runtime
workers/worker.py - Heartbeat Monitor
workers/heartbeat.py - Task Recovery
recovery/recovery.py
Persistent State
- MongoDB Access
db/connection.py - Tasks and History
db/connection.py - Worker Records
db/connection.py - Q-Table
db/connection.py
Monitoring and UI
- Prometheus Metrics
core/metrics.py - Prometheus Scraper
prometheus.yml - Grafana Dashboards
grafana/dashboards/dashboard.yml - Web Dashboard
frontend/index.html
Other components
- Client
Connections 33
- Client → Task API: submits tasks
README.md - Client → Worker API: registers workers
README.md - FastAPI App → Task API: routes requests
main.py - FastAPI App → Worker API: routes requests
main.py - FastAPI App → Learning API: routes requests
main.py - FastAPI App → MongoDB Access: initializes
main.py - FastAPI App → Background Learner: starts
main.py - Task API → Request and Task Models: validates data
routers/task.py - Worker API → Request and Task Models: validates data
routers/workers.py - Task API → Tasks and History: reads and writes
routers/task.py - Task API → Worker Records: claims capacity
routers/task.py - Task API → Duration Estimator: estimates duration
routers/task.py - Task API → Q-Learning Agent: scores candidates
routers/task.py - Task API → Prometheus Metrics: updates counters
routers/task.py - Worker API → Worker Records: registers and updates
routers/workers.py - Worker Runtime → Worker API: registers and heartbeats
workers/worker.py - Worker Runtime → Task API: pulls and reports
workers/worker.py - Heartbeat Monitor → Worker Records: checks worker status
workers/heartbeat.py - Task Recovery → Tasks and History: resets timed-out tasks
recovery/recovery.py - Learning API → Tasks and History: records outcomes
routers/learning.py - Learning API → Duration Estimator: estimates duration
routers/learning.py - Learning API → Q-Table: reads Q metrics
routers/learning.py - Duration Estimator → Tasks and History: reads history
scheduling/estimator.py - Background Learner → Tasks and History: reads training history
scheduling/learner.py - Background Learner → Q-Learning Agent: updates policy
scheduling/learner.py - Q-Learning Agent → Q-Table: loads and saves
scheduling/rl_agent.py - MongoDB Access → Tasks and History: provides collection access
db/connection.py - MongoDB Access → Worker Records: provides collection access
db/connection.py - MongoDB Access → Q-Table: provides collection access
db/connection.py - FastAPI App → Prometheus Metrics: exposes metrics
main.py - Prometheus Scraper → FastAPI App: scrapes metrics
README.md - Grafana Dashboards → Prometheus Scraper: visualizes metrics
README.md - Web Dashboard → FastAPI App: uses dashboard APIs
README.md