Skip to content

Commit 91a0cc5

Browse files
committed
85: Refactor pipeline service - simplified
1 parent 4afdde5 commit 91a0cc5

3 files changed

Lines changed: 105 additions & 248 deletions

File tree

service/src/ai_document_plugin_service/api/routes.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import fastapi
44

5-
from ai_document_plugin_service.ai.common.config import LLMConfig
65
from ai_document_plugin_service.api.auth import verify_authenticated
76
from ai_document_plugin_service.api.jwt import extract_identity_from_token
87
from ai_document_plugin_service.api.types import (
@@ -100,19 +99,11 @@ async def start_pipeline(
10099
run_id = str(uuid4())
101100
pipeline.enqueue_pipeline_job(
102101
run_id,
103-
payload.questionnaire_uuid,
104-
payload.template_uuid,
102+
payload,
105103
template['title'],
106104
user_uuid,
107105
tenant_uuid,
108-
auth.token,
109-
auth.api_url,
110-
LLMConfig(
111-
model=payload.llm_model,
112-
api_key=payload.llm_api_key,
113-
api_url=payload.llm_api_url,
114-
parallel_workers=payload.llm_max_workers,
115-
),
106+
auth,
116107
config,
117108
)
118109
return _model_from_fields(
@@ -139,5 +130,4 @@ def get_pipeline_status(run_id: str, pipeline: PipelineServiceDI) -> PipelineSta
139130
async def save_pipeline_result(
140131
run_id: str, save_request: PipelineSaveRequest, pipeline: PipelineServiceDI
141132
) -> PipelineStatusResponse:
142-
143133
return await pipeline.update_pipeline_result(run_id, save_request)

service/src/ai_document_plugin_service/service/pipeline_queue_manager.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def format_queue_progress(jobs_ahead: int) -> str:
2121
class PipelineQueueManager:
2222
"""FIFO pipeline job queue running coroutines on a dedicated event loop.
2323
24-
Jobs are coroutines scheduled onto a single background event loop and gated by an
24+
Jobs are coroutines scheduled onto a single background event loop and gated by a
25+
semaphore so at most ``max_concurrent_jobs`` run at once.
2526
"""
2627

2728
def __init__(self, max_concurrent_jobs: int) -> None:
@@ -56,10 +57,8 @@ def progress_message(self, run_id: str) -> str | None:
5657

5758
def remove(self, run_id: str) -> None:
5859
with self._order_lock:
59-
try:
60+
if run_id in self._order:
6061
self._order.remove(run_id)
61-
except ValueError:
62-
return
6362

6463
def _jobs_waiting_ahead(self, run_id: str) -> int | None:
6564
with self._order_lock:

0 commit comments

Comments
 (0)