From f77d943d79bfaea6123876673663cd756c00d7e7 Mon Sep 17 00:00:00 2001 From: Mikhail Yevchenko Date: Thu, 21 May 2026 19:25:09 +0000 Subject: [PATCH] Refactor log message handling and improve word extraction in completions benchmark --- workers/openai/worker.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/workers/openai/worker.py b/workers/openai/worker.py index 4254f33..00aa336 100644 --- a/workers/openai/worker.py +++ b/workers/openai/worker.py @@ -10,16 +10,6 @@ MODEL_LOG_FILE = '/var/log/onstart.log' MODEL_HEALTHCHECK_ENDPOINT = "/" # Ollama-specific log messages -MODEL_LOAD_LOG_MSG = [ - "llama runner started in " -] - -MODEL_ERROR_LOG_MSGS = [ -] - -MODEL_INFO_LOG_MSGS = [ -] - def request_parser(request): data = request if request.get("input") is not None: @@ -33,11 +23,14 @@ def completions_benchmark_generator() -> dict: WORD_LIST = [] with open(__file__, 'r') as f: - for line in f: - WORD_LIST.extend(line.strip().split()) + # Use regex to extract words from the source code + import re + source_code = f.read() + WORD_LIST = re.findall(r'\b\w+\b', source_code) prompt = " ".join(random.choices(WORD_LIST, k=int(250))) model = os.environ.get("MODEL_NAME") + if not model: raise ValueError("MODEL_NAME environment variable not set") @@ -77,9 +70,9 @@ worker_config = WorkerConfig( ) ], log_action_config=LogActionConfig( - on_load=MODEL_LOAD_LOG_MSG, - on_error=MODEL_ERROR_LOG_MSGS, - on_info=MODEL_INFO_LOG_MSGS + on_load=["llama runner started in "], + #on_error=MODEL_ERROR_LOG_MSGS, + #on_info=MODEL_INFO_LOG_MSGS ) )