diff --git a/app/main.py b/app/main.py index 9d394f81..1abc5200 100644 --- a/app/main.py +++ b/app/main.py @@ -7,6 +7,7 @@ from app.web.routers.health import router as health_router from app.web.routers.pipelines import router as pipelines_router from app.web.routers.webhooks import router as webhooks_router +from app.web.routers.ingestion_status import router as ingestion_status_router import logging from fastapi import FastAPI, Request, status @@ -57,3 +58,4 @@ async def some_middleware(request: Request, call_next): app.include_router(health_router) app.include_router(pipelines_router) app.include_router(webhooks_router) +app.include_router(ingestion_status_router) diff --git a/app/pipeline/lecture_ingestion_pipeline.py b/app/pipeline/lecture_ingestion_pipeline.py index 72903f33..3a954389 100644 --- a/app/pipeline/lecture_ingestion_pipeline.py +++ b/app/pipeline/lecture_ingestion_pipeline.py @@ -29,7 +29,7 @@ CapabilityRequestHandler, RequirementList, ) -from ..web.status import IngestionStatusCallback +from ..web.status import ingestion_status_callback from langchain_text_splitters import RecursiveCharacterTextSplitter batch_update_lock = threading.Lock() diff --git a/app/web/routers/webhooks.py b/app/web/routers/webhooks.py index d0da34fb..92c167b9 100644 --- a/app/web/routers/webhooks.py +++ b/app/web/routers/webhooks.py @@ -9,8 +9,8 @@ from app.domain.ingestion.ingestion_pipeline_execution_dto import ( IngestionPipelineExecutionDto, ) -from ..status.IngestionStatusCallback import IngestionStatusCallback -from ..status.LecturesDeletionStatusCallback import LecturesDeletionStatusCallback +from ..status.ingestion_status_callback import IngestionStatusCallback +from ..status.lecture_deletion_status_callback import LecturesDeletionStatusCallback from ...domain.ingestion.deletionPipelineExecutionDto import ( LecturesDeletionExecutionDto, ) diff --git a/app/web/status/IngestionStatusCallback.py b/app/web/status/IngestionStatusCallback.py deleted file mode 100644 index 35ffaccf..00000000 --- a/app/web/status/IngestionStatusCallback.py +++ /dev/null @@ -1,45 +0,0 @@ -from typing import List - -from .status_update import StatusCallback -from ...domain.ingestion.ingestion_status_update_dto import IngestionStatusUpdateDTO -from ...domain.status.stage_state_dto import StageStateEnum -from ...domain.status.stage_dto import StageDTO -import logging - -logger = logging.getLogger(__name__) - - -class IngestionStatusCallback(StatusCallback): - """ - Callback class for updating the status of a Tutor Chat pipeline run. - """ - - def __init__( - self, - run_id: str, - base_url: str, - initial_stages: List[StageDTO] = None, - lecture_unit_id: int = None, - ): - url = f"{base_url}/api/public/pyris/webhooks/ingestion/runs/{run_id}/status" - - current_stage_index = len(initial_stages) if initial_stages else 0 - stages = initial_stages or [] - stages += [ - StageDTO( - weight=10, state=StageStateEnum.NOT_STARTED, name="Old slides removal" - ), - StageDTO( - weight=60, - state=StageStateEnum.NOT_STARTED, - name="Slides Interpretation", - ), - StageDTO( - weight=30, - state=StageStateEnum.NOT_STARTED, - name="Slides ingestion", - ), - ] - status = IngestionStatusUpdateDTO(stages=stages, id=lecture_unit_id) - stage = stages[current_stage_index] - super().__init__(url, run_id, status, stage, current_stage_index) diff --git a/app/web/status/LecturesDeletionStatusCallback.py b/app/web/status/LecturesDeletionStatusCallback.py deleted file mode 100644 index 3aaeb803..00000000 --- a/app/web/status/LecturesDeletionStatusCallback.py +++ /dev/null @@ -1,31 +0,0 @@ -from typing import List - -from .status_update import StatusCallback -from ...domain.ingestion.ingestion_status_update_dto import IngestionStatusUpdateDTO -from ...domain.status.stage_state_dto import StageStateEnum -from ...domain.status.stage_dto import StageDTO -import logging - -logger = logging.getLogger(__name__) - - -class LecturesDeletionStatusCallback(StatusCallback): - """ - Callback class for updating the status of a Tutor Chat pipeline run. - """ - - def __init__( - self, run_id: str, base_url: str, initial_stages: List[StageDTO] = None - ): - url = f"{base_url}/api/public/pyris/webhooks/ingestion/runs/{run_id}/status" - - current_stage_index = len(initial_stages) if initial_stages else 0 - stages = initial_stages or [] - stages += [ - StageDTO( - weight=100, state=StageStateEnum.NOT_STARTED, name="Slides removal" - ), - ] - status = IngestionStatusUpdateDTO(stages=stages) - stage = stages[current_stage_index] - super().__init__(url, run_id, status, stage, current_stage_index)