Unverified Commit 7de80960 authored by Abhishek Gupta's avatar Abhishek Gupta Committed by GitHub
Browse files

feat: add __all__ exports and __repr__ methods for better debugging (#5606)

parent 7361de42
......@@ -22,6 +22,21 @@ contextual information to help with debugging and error handling.
from typing import List
__all__ = [
"PlannerError",
"DynamoGraphDeploymentNotFoundError",
"ComponentError",
"ModelNameNotFoundError",
"DeploymentModelNameMismatchError",
"UserProvidedModelNameMismatchError",
"BackendFrameworkNotFoundError",
"BackendFrameworkInvalidError",
"SubComponentNotFoundError",
"DuplicateSubComponentError",
"DeploymentValidationError",
"EmptyTargetReplicasError",
]
class PlannerError(Exception):
"""Base exception for all planner-related errors.
......@@ -49,6 +64,9 @@ class DynamoGraphDeploymentNotFoundError(PlannerError):
super().__init__(message)
def __repr__(self) -> str:
return f"{self.__class__.__name__}(deployment_name={self.deployment_name!r}, namespace={self.namespace!r})"
class ComponentError(PlannerError):
"""Base class for subComponent configuration issues.
......@@ -79,6 +97,9 @@ class DeploymentModelNameMismatchError(PlannerError):
self.message = message
super().__init__(self.message)
def __repr__(self) -> str:
return f"{self.__class__.__name__}(prefill_model_name={self.prefill_model_name!r}, decode_model_name={self.decode_model_name!r})"
class UserProvidedModelNameMismatchError(PlannerError):
"""Raised when the model name is not the same as the user provided model name"""
......@@ -130,6 +151,11 @@ class SubComponentNotFoundError(ComponentError):
super().__init__(message)
def __repr__(self) -> str:
return (
f"{self.__class__.__name__}(sub_component_type={self.sub_component_type!r})"
)
class DuplicateSubComponentError(ComponentError):
"""Raised when multiple services have the same subComponentType.
......@@ -150,6 +176,9 @@ class DuplicateSubComponentError(ComponentError):
super().__init__(message)
def __repr__(self) -> str:
return f"{self.__class__.__name__}(sub_component_type={self.sub_component_type!r}, service_names={self.service_names!r})"
class DeploymentValidationError(PlannerError):
"""Raised when deployment validation fails for multiple components.
......
......@@ -15,6 +15,8 @@ from typing import Any, Dict, Optional
logger = logging.getLogger(__name__)
__all__ = ["HealthCheckPayload", "load_health_check_from_env"]
def load_health_check_from_env(
env_var: str = "DYN_HEALTH_CHECK_PAYLOAD",
......@@ -94,3 +96,9 @@ class HealthCheckPayload:
# Check for environment override
self._payload = load_health_check_from_env() or self.default_payload
return self._payload
def __repr__(self) -> str:
"""Return a string representation of the health check payload."""
class_name = self.__class__.__name__
payload = self.to_dict()
return f"{class_name}(payload={payload!r})"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment