Skip to content

Commit

Permalink
Remove single abstract class
Browse files Browse the repository at this point in the history
  • Loading branch information
kaancayli committed Feb 28, 2024
1 parent cda7905 commit 4ef9022
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 26 deletions.
18 changes: 0 additions & 18 deletions app/common/singleton_abstract.py

This file was deleted.

6 changes: 5 additions & 1 deletion app/domain/pipeline_execution_dto.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from pydantic import BaseModel
from typing import List

from pydantic import BaseModel, Field

from domain.pipeline_execution_settings_dto import PipelineExecutionSettingsDTO
from domain.status.stage_dto import StageDTO


class PipelineExecutionDTO(BaseModel):
settings: PipelineExecutionSettingsDTO
initial_stages: List[StageDTO] = Field(alias="initialStages")
1 change: 1 addition & 0 deletions app/domain/pipeline_execution_settings_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
class PipelineExecutionSettingsDTO(BaseModel):
authentication_token: str = Field(alias="authenticationToken")
allowed_models: List[str] = Field(alias="allowedModels")
artemis_base_url: str = Field(alias="artemisBaseUrl")
5 changes: 3 additions & 2 deletions app/domain/tutor_chat/tutor_chat_pipeline_execution_dto.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import List

from pydantic import BaseModel, Field
from pydantic import Field

from domain import PipelineExecutionDTO
from domain.data.course_dto import CourseDTO
from domain.data.message_dto import MessageDTO
from domain.data.programming_exercise_dto import ProgrammingExerciseDTO
from domain.data.user_dto import UserDTO
from domain.data.submission_dto import SubmissionDTO


class TutorChatPipelineExecutionDTO(BaseModel):
class TutorChatPipelineExecutionDTO(PipelineExecutionDTO):
latest_submission: SubmissionDTO = Field(alias="latestSubmission")
exercise: ProgrammingExerciseDTO
course: CourseDTO
Expand Down
4 changes: 2 additions & 2 deletions app/pipeline/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from app.common.singleton_abstract import SingletonABCMeta
from abc import ABCMeta


class Pipeline(metaclass=SingletonABCMeta):
class Pipeline(metaclass=ABCMeta):
"""Abstract class for all pipelines"""

implementation_id: str
Expand Down
6 changes: 4 additions & 2 deletions app/web/routers/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
TutorChatPipelineExecutionDTO,
)
from app.pipeline.chat.tutor_chat_pipeline import TutorChatPipeline
from web.status.status_update import TutorChatStatusCallback

router = APIRouter(prefix="/api/v1/pipelines", tags=["pipelines"])
logger = logging.getLogger(__name__)


@router.post("/tutor-chat/{variant}/run", status_code=status.HTTP_202_ACCEPTED)
def run_pipeline(variant: str, dto: TutorChatPipelineExecutionDTO):
pipeline = TutorChatPipeline()
pipeline(wrapper=dto, callback=None)
callback = TutorChatStatusCallback(run_id=dto.settings.authentication_token)
pipeline = TutorChatPipeline(callback=callback)
pipeline(dto=dto)


@router.get("/{feature}")
Expand Down
5 changes: 4 additions & 1 deletion app/web/status/status_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ def on_status_update(self, status: Any):
class TutorChatStatusCallback(StatusCallback):
def __init__(self, run_id: str):
url = f"/api/v1/public/pyris/tutorchat/runs/{run_id}/status"
self.run_id = run_id
super().__init__(url)

def on_status_update(self, status: TutorChatStatusUpdateDTO):
requests.post(
self.url, headers={"Content-Type": "application/json"}, json=status.json()
self.url,
headers={"Content-Type": "application/json", "Authorization": self.run_id},
json=status.json(),
)

0 comments on commit 4ef9022

Please sign in to comment.