fix: make mlflow_logger import optional with no-op fallback
All checks were successful
Build and Publish ray-serve-apps / build-and-publish (push) Successful in 11s
All checks were successful
Build and Publish ray-serve-apps / build-and-publish (push) Successful in 11s
The strixhalo LLM worker uses py_executable pointing to the Docker image venv which doesn't have the updated ray-serve-apps package. Wrap all InferenceLogger imports in try/except and guard usage with None checks so apps degrade gracefully without MLflow logging.
This commit is contained in:
@@ -11,7 +11,10 @@ from typing import Any
|
||||
|
||||
from ray import serve
|
||||
|
||||
from ray_serve.mlflow_logger import InferenceLogger
|
||||
try:
|
||||
from ray_serve.mlflow_logger import InferenceLogger
|
||||
except ImportError:
|
||||
InferenceLogger = None
|
||||
|
||||
|
||||
@serve.deployment(name="TTSDeployment", num_replicas=1)
|
||||
@@ -36,13 +39,16 @@ class TTSDeployment:
|
||||
print("TTS model loaded successfully")
|
||||
|
||||
# MLflow metrics
|
||||
self._mlflow = InferenceLogger(
|
||||
experiment_name="ray-serve-tts",
|
||||
run_name=f"tts-{self.model_name.split('/')[-1]}",
|
||||
tags={"model.name": self.model_name, "model.framework": "coqui-tts", "gpu": str(self.use_gpu)},
|
||||
flush_every=5,
|
||||
)
|
||||
self._mlflow.initialize(params={"model_name": self.model_name, "use_gpu": str(self.use_gpu)})
|
||||
if InferenceLogger is not None:
|
||||
self._mlflow = InferenceLogger(
|
||||
experiment_name="ray-serve-tts",
|
||||
run_name=f"tts-{self.model_name.split('/')[-1]}",
|
||||
tags={"model.name": self.model_name, "model.framework": "coqui-tts", "gpu": str(self.use_gpu)},
|
||||
flush_every=5,
|
||||
)
|
||||
self._mlflow.initialize(params={"model_name": self.model_name, "use_gpu": str(self.use_gpu)})
|
||||
else:
|
||||
self._mlflow = None
|
||||
|
||||
async def __call__(self, request: dict[str, Any]) -> dict[str, Any]:
|
||||
"""
|
||||
@@ -104,12 +110,13 @@ class TTSDeployment:
|
||||
duration = len(wav) / sample_rate
|
||||
|
||||
# Log to MLflow
|
||||
self._mlflow.log_request(
|
||||
latency_s=time.time() - _start,
|
||||
audio_duration_s=duration,
|
||||
text_chars=len(text),
|
||||
realtime_factor=(time.time() - _start) / duration if duration > 0 else 0,
|
||||
)
|
||||
if self._mlflow:
|
||||
self._mlflow.log_request(
|
||||
latency_s=time.time() - _start,
|
||||
audio_duration_s=duration,
|
||||
text_chars=len(text),
|
||||
realtime_factor=(time.time() - _start) / duration if duration > 0 else 0,
|
||||
)
|
||||
|
||||
response = {
|
||||
"model": self.model_name,
|
||||
|
||||
Reference in New Issue
Block a user