mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 20:59:05 +00:00
server: remove warmup methods everywhere
This commit is contained in:
@@ -52,9 +52,6 @@ class AudioTranscriptAutoProcessor(AudioTranscriptProcessor):
|
||||
def off(self, callback):
|
||||
self.processor.off(callback)
|
||||
|
||||
async def _warmup(self):
|
||||
return await self.processor._warmup()
|
||||
|
||||
async def _push(self, data: AudioFile):
|
||||
return await self.processor._push(data)
|
||||
|
||||
|
||||
@@ -12,10 +12,7 @@ API will be a POST request to TRANSCRIPT_URL:
|
||||
|
||||
"""
|
||||
|
||||
from time import monotonic
|
||||
|
||||
import httpx
|
||||
|
||||
from reflector.processors.audio_transcript import AudioTranscriptProcessor
|
||||
from reflector.processors.audio_transcript_auto import AudioTranscriptAutoProcessor
|
||||
from reflector.processors.types import AudioFile, Transcript, Word
|
||||
@@ -27,26 +24,9 @@ class AudioTranscriptModalProcessor(AudioTranscriptProcessor):
|
||||
def __init__(self, modal_api_key: str):
|
||||
super().__init__()
|
||||
self.transcript_url = settings.TRANSCRIPT_URL + "/transcribe"
|
||||
self.warmup_url = settings.TRANSCRIPT_URL + "/warmup"
|
||||
self.timeout = settings.TRANSCRIPT_TIMEOUT
|
||||
self.headers = {"Authorization": f"Bearer {modal_api_key}"}
|
||||
|
||||
async def _warmup(self):
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
start = monotonic()
|
||||
self.logger.debug("Transcribe modal: warming up...")
|
||||
response = await client.post(
|
||||
self.warmup_url,
|
||||
headers=self.headers,
|
||||
timeout=self.timeout,
|
||||
)
|
||||
response.raise_for_status()
|
||||
duration = monotonic() - start
|
||||
self.logger.debug(f"Transcribe modal: warmup took {duration:.2f}s")
|
||||
except Exception:
|
||||
self.logger.exception("Transcribe modal: warmup failed")
|
||||
|
||||
async def _transcript(self, data: AudioFile):
|
||||
async with httpx.AsyncClient() as client:
|
||||
self.logger.debug(f"Try to transcribe audio {data.name}")
|
||||
|
||||
@@ -5,7 +5,6 @@ from uuid import uuid4
|
||||
|
||||
from prometheus_client import Counter, Gauge, Histogram
|
||||
from pydantic import BaseModel
|
||||
|
||||
from reflector.logger import logger
|
||||
|
||||
|
||||
@@ -18,7 +17,6 @@ class PipelineEvent(BaseModel):
|
||||
class Processor:
|
||||
INPUT_TYPE: type = None
|
||||
OUTPUT_TYPE: type = None
|
||||
WARMUP_EVENT: str = "WARMUP_EVENT"
|
||||
|
||||
m_processor = Histogram(
|
||||
"processor",
|
||||
@@ -172,21 +170,12 @@ class Processor:
|
||||
def describe(self, level=0):
|
||||
logger.info(" " * level + self.__class__.__name__)
|
||||
|
||||
async def warmup(self):
|
||||
"""
|
||||
Warmup the processor
|
||||
"""
|
||||
await self._warmup()
|
||||
|
||||
async def _push(self, data):
|
||||
raise NotImplementedError
|
||||
|
||||
async def _flush(self):
|
||||
pass
|
||||
|
||||
async def _warmup(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def as_threaded(cls, *args, **kwargs):
|
||||
"""
|
||||
@@ -242,12 +231,6 @@ class ThreadedProcessor(Processor):
|
||||
if data is None:
|
||||
await self.processor.flush()
|
||||
break
|
||||
if data == self.WARMUP_EVENT:
|
||||
self.logger.debug(
|
||||
f"Warming up {self.processor.__class__.__name__}"
|
||||
)
|
||||
await self.processor.warmup()
|
||||
continue
|
||||
try:
|
||||
await self.processor.push(data)
|
||||
except Exception:
|
||||
@@ -258,9 +241,6 @@ class ThreadedProcessor(Processor):
|
||||
finally:
|
||||
self.queue.task_done()
|
||||
|
||||
async def _warmup(self):
|
||||
await self.queue.put(self.WARMUP_EVENT)
|
||||
|
||||
async def _push(self, data):
|
||||
await self.queue.put(data)
|
||||
|
||||
@@ -309,10 +289,6 @@ class BroadcastProcessor(Processor):
|
||||
for processor in self.processors:
|
||||
processor.set_pipeline(pipeline)
|
||||
|
||||
async def _warmup(self):
|
||||
for processor in self.processors:
|
||||
await processor.warmup()
|
||||
|
||||
async def _push(self, data):
|
||||
for processor in self.processors:
|
||||
await processor.push(data)
|
||||
@@ -352,7 +328,6 @@ class Pipeline(Processor):
|
||||
OUTPUT_TYPE = None
|
||||
|
||||
def __init__(self, *processors: Processor):
|
||||
self._warmed_up = False
|
||||
super().__init__()
|
||||
self.logger = logger.bind(pipeline=self.uid)
|
||||
self.logger.info("Pipeline created")
|
||||
@@ -369,11 +344,6 @@ class Pipeline(Processor):
|
||||
self.INPUT_TYPE = processors[0].INPUT_TYPE
|
||||
self.OUTPUT_TYPE = processors[-1].OUTPUT_TYPE
|
||||
|
||||
async def _warmup(self):
|
||||
for processor in self.processors:
|
||||
self.logger.debug(f"Warming up {processor.__class__.__name__}")
|
||||
await processor.warmup()
|
||||
|
||||
async def _push(self, data):
|
||||
await self.processors[0].push(data)
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ class TranscriptTopicDetectorProcessor(Processor):
|
||||
self.llm = LLM.get_instance()
|
||||
self.params = LLMTaskParams.get_instance(self.TASK).task_params
|
||||
|
||||
async def _warmup(self):
|
||||
await self.llm.warmup(logger=self.logger)
|
||||
|
||||
async def _push(self, data: Transcript):
|
||||
if self.transcript is None:
|
||||
self.transcript = data
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from time import monotonic
|
||||
|
||||
import httpx
|
||||
from reflector.processors.base import Processor
|
||||
from reflector.processors.types import Transcript, TranslationLanguages
|
||||
@@ -22,22 +20,6 @@ class TranscriptTranslatorProcessor(Processor):
|
||||
self.timeout = settings.TRANSCRIPT_TIMEOUT
|
||||
self.headers = {"Authorization": f"Bearer {settings.LLM_MODAL_API_KEY}"}
|
||||
|
||||
async def _warmup(self):
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
start = monotonic()
|
||||
self.logger.debug("Translate modal: warming up...")
|
||||
response = await client.post(
|
||||
settings.TRANSCRIPT_URL + "/warmup",
|
||||
headers=self.headers,
|
||||
timeout=self.timeout,
|
||||
)
|
||||
response.raise_for_status()
|
||||
duration = monotonic() - start
|
||||
self.logger.debug(f"Translate modal: warmup took {duration:.2f}s")
|
||||
except Exception:
|
||||
self.logger.exception("Translate modal: warmup failed")
|
||||
|
||||
async def _push(self, data: Transcript):
|
||||
self.transcript = data
|
||||
await self.flush()
|
||||
|
||||
Reference in New Issue
Block a user