-
Notifications
You must be signed in to change notification settings - Fork 0
Services_stories
US Global Context Management : Manage global contexts during execution for logging, notifications, and MLflow tracking.
classDiagram
class Service {
<<abstract>>
+start()* None
+stop() None
}
Service --|> pdt.BaseModel : inherits
Service --|> abc.ABC : inherits
class LoggerService {
+sink: str = "stderr"
+level: str = "DEBUG"
+format: str
+colorize: bool = True
+serialize: bool = False
+backtrace: bool = True
+diagnose: bool = False
+catch: bool = True
+start() None
+logger() loguru.Logger
}
LoggerService --|> Service : inherits
class AlertsService {
+enable: bool = True
+app_name: str = "regression_model_template"
+timeout: int | None = None
+start() None
+notify(title: str, message: str) None
}
AlertsService --|> Service : inherits
class MlflowService {
+tracking_uri: str
+registry_uri: str
+experiment_name: str
+registry_name: str
+autolog_disable: bool = False
+start() None
+run_context(run_config: RunConfig) T.Generator
+client() mt.MlflowClient
}
MlflowService --|> Service : inherits
class RunConfig {
+name: str
+description: str | None = None
+tags: dict[str, T.Any] | None = None
+log_system_metrics: bool | None = True
}
MlflowService *-- RunConfig : inner class
Title:
As a developer, I want to have a centralized logging service that captures and formats log entries, so I can keep track of system activities and alerts.
Description:
The LoggerService class provides functionality to manage logging in the application using the Loguru library. It allows configuration of log outputs, levels, and formats.
Acceptance Criteria:
- The
startmethod initializes the logger with the desired configuration. - Log entries should show timestamps, log levels, and the source of the log message.
- The logger can be retrieved through the
loggermethod.
Title:
As a user, I want to be able to receive notifications from the application, so I can be alerted about important events or errors.
Description:
The AlertsService class provides capabilities to send notifications through the system or display them on the console if notifications are disabled.
Acceptance Criteria:
- The
startmethod initializes the notification service. - The
notifymethod allows sending notifications with a title and message. - When notifications are disabled, messages should be printed to the console instead.
Title:
As a data scientist, I want to manage MLflow tracking and model registry through a unified service, so I can easily log experiments and access models.
Description:
The MlflowService class integrates MLflow tracking features, enabling experiment management, automatic logging, and model registrations.
Acceptance Criteria:
- The
startmethod sets the tracking and registry URIs and initializes the experiment for logging. - The
run_contextmethod provides a context manager for tracking runs, allowing easy management of logging during model training. - Users can retrieve the MLflow client through the
clientmethod to perform direct MLflow API operations.
-
Implementation Requirements:
- Each service class must extend the
Servicebase class and implement thestartmethod. - Clear separation of responsibilities among services (logging, notifications, MLflow tracking).
- Each service class must extend the
-
Error Handling:
- Appropriate error messaging for issues encountered during starting services or sending notifications.
-
Testing:
- Unit tests validate the functionality of each service, ensuring they operate as intended when invoked.
-
Documentation:
- Each class and method contains detailed docstrings and usage examples to guide users.
- All required methods in
Service,LoggerService,AlertsService, andMlflowServiceare implemented. - Each service class passes all relevant tests.
- Documentation is clear, and examples are provided for usage.
Powered by MLOps Factory