Skip to content

Logging, worker tmp clean, and inference-service tests - #48

Open
AraNge wants to merge 7 commits into
devfrom
feature/logging_and_worker_tmp_clean
Open

Logging, worker tmp clean, and inference-service tests#48
AraNge wants to merge 7 commits into
devfrom
feature/logging_and_worker_tmp_clean

Conversation

@AraNge

@AraNge AraNge commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Pull Request: Structured Logging Implementation

Description

Implementing structured logging, automated resource cleanup, and a comprehensive test suite.

Related Issues

Fixes #43

Affected Components

  • Orchestrator
  • Training Worker
  • Inference Service
  • Monitoring Service (Dashboard)
  • Shared / Utils
  • Infrastructure (Docker, CI/CD)

Changes Made

Structured Logging & Aggregation (Task 1)

  • Shared Module: Created shared/utils/logging_utils.py with a custom JSONFormatter and setup_logging function.
  • Correlation ID: Integrated asgi-correlation-id across FastAPI services and manual injection for Streamlit/Worker.
  • Configured Grafana Loki as a centralized log store.
  • Added grafana/datasource.yaml for automated Loki connection.
  • Switched Docker logging driver to loki with mode: non-blocking for system stability.
  • Added integration tests for log format validation
  • Tested correlation ID propagation across services
  • Verified JSON format parsing across all services

Automated Resource Cleanup (Task 2)

  • Implemented cleanup_temp_files in worker.py that handles both files and directories (fixes IsADirectoryError).
  • Integrated cleanup into a finally block in process_job, ensuring no orphaned files remain in /tmp regardless of job success or failure.
  • Added specific log events for cleanup operations.

Inference Service Testing (Task 3)

  • Added tests covering /predict, /reload, /health, and invalid payloads.

Testing Performed

  • Local testing via docker-compose up
  • Unit tests added / updated
  • Manual API testing (e.g., Postman / cURL)

laschien and others added 7 commits April 18, 2026 14:36
- Updated README.md/System Architecture to reflect removal of PostgreSQL.
- Added sections for Reliability & Resiliency detailing the new retry logic.
- Updated Graceful Failure Handling documentation with 404, 503, and 500 status codes.
- Refined Request Life Cycle to include model-fetch retries and multi-process handoff.
- Synchronized Configuration table with current MinIO environment variables.
… all services

- Create shared JSON formatter for consistent log format
- Add correlation ID propagation to orchestrator, training worker, inference service, and dashboard
- Implement request tracking with X-Correlation-ID header
- Add comprehensive logging tests for all services
- Log key events: requests, job processing, training pipeline, model persistence, and errors
- Added Grafana Loki Docker Driver for all services
- Implemented structured JSON logging with custom Formatter
- Added persistent volumes for Loki and Grafana data
- Updated docker-compose with automated Loki health checks and retries
- Update Dockerfiles to use root context (.) for better build management
- Add logging verification tests for all microservices
- Implement correlation_id injection for Streamlit and FastAPI
- Implement `cleanup_temp_files`
- Added comprehensive integration tests for job processing lifecycle
- Verified `finally` block execution for guaranteed file cleanup on success and failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants