Skip to content

Commit

Permalink
Fix fields in dtos
Browse files Browse the repository at this point in the history
  • Loading branch information
kaancayli committed Mar 1, 2024
1 parent f961ebc commit cc8d56a
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 16 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,3 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
/app/pipeline_playground.py
2 changes: 1 addition & 1 deletion app/domain/data/course_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
class CourseDTO(BaseModel):
id: int
name: str
description: str
description: str | None = None
4 changes: 2 additions & 2 deletions app/domain/data/programming_exercise_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class ProgrammingExerciseDTO(BaseModel):
solution_repository: Dict[str, str] = Field(alias="solutionRepository")
test_repository: Dict[str, str] = Field(alias="testRepository")
problem_statement: str = Field(alias="problemStatement")
start_date: datetime = Field(alias="startDate")
end_date: datetime = Field(alias="endDate")
start_date: datetime | None = Field(alias="startDate")
end_date: datetime | None = Field(alias="endDate")
6 changes: 4 additions & 2 deletions app/domain/pipeline_execution_dto.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Optional

from pydantic import BaseModel, Field

Expand All @@ -8,4 +8,6 @@

class PipelineExecutionDTO(BaseModel):
settings: PipelineExecutionSettingsDTO
initial_stages: List[StageDTO] = Field(alias="initialStages")
initial_stages: Optional[List[StageDTO]] = Field(
default=None, alias="initialStages"
)
2 changes: 1 addition & 1 deletion app/domain/pipeline_execution_settings_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

class PipelineExecutionSettingsDTO(BaseModel):
authentication_token: str = Field(alias="authenticationToken")
allowed_models: List[str] = Field(alias="allowedModels")
allowed_model_identifiers: List[str] = Field(alias="allowedModelIdentifiers")
artemis_base_url: str = Field(alias="artemisBaseUrl")
2 changes: 1 addition & 1 deletion app/domain/tutor_chat/tutor_chat_pipeline_execution_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class TutorChatPipelineExecutionDTO(PipelineExecutionDTO):
latest_submission: SubmissionDTO = Field(alias="latestSubmission")
submission: SubmissionDTO
exercise: ProgrammingExerciseDTO
course: CourseDTO
chat_history: List[MessageDTO] = Field(alias="chatHistory")
Expand Down
6 changes: 3 additions & 3 deletions app/pipeline/chat/tutor_chat_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def __call__(self, dto: TutorChatPipelineExecutionDTO, **kwargs):
logger.debug("Running tutor chat pipeline...")
logger.debug(f"DTO: {dto}")
history: List[MessageDTO] = dto.chat_history[:-1]
build_logs = dto.latest_submission.build_log_entries
build_logs = dto.submission.build_log_entries
query: IrisMessage = dto.chat_history[-1].convert_to_iris_message()
problem_statement: str = dto.exercise.problem_statement
exercise_title: str = dto.exercise.name
message = query.text
file_map = dto.latest_submission.repository
file_map = dto.submission.repository
programming_language = dto.exercise.programming_language.value.lower()
if not message:
raise ValueError("IrisMessage must not be empty")
Expand All @@ -115,7 +115,7 @@ def __call__(self, dto: TutorChatPipelineExecutionDTO, **kwargs):
}
)
logger.debug(f"Response from tutor chat pipeline: {response}")
stages = dto.initial_stages
stages = dto.initial_stages or []
stages.append(
StageDTO(
name="Final Stage",
Expand Down
2 changes: 2 additions & 0 deletions app/web/routers/pipelines.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import traceback
from threading import Thread

from fastapi import APIRouter, status, Response, Depends
Expand All @@ -22,6 +23,7 @@ def run_tutor_chat_pipeline_worker(dto):
pipeline(dto=dto)
except Exception as e:
logger.error(f"Error running tutor chat pipeline: {e}")
logger.error(traceback.format_exc())


@router.post(
Expand Down
19 changes: 14 additions & 5 deletions app/web/status/status_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from abc import ABC, abstractmethod

from ...domain.tutor_chat.tutor_chat_status_update_dto import TutorChatStatusUpdateDTO
import logging

logger = logging.getLogger(__name__)


class StatusCallback(ABC):
Expand All @@ -26,8 +29,14 @@ def __init__(self, run_id: str, base_url: str):
super().__init__(url)

def on_status_update(self, status: TutorChatStatusUpdateDTO):
requests.post(
self.url,
headers={"Content-Type": "application/json", "Authorization": self.run_id},
json=status.dict(by_alias=True),
)
try:
requests.post(
self.url,
headers={
"Content-Type": "application/json",
"Authorization": self.run_id,
},
json=status.dict(by_alias=True),
).raise_for_status()
except requests.exceptions.RequestException as e:
logger.error(f"Error sending status update: {e}")

0 comments on commit cc8d56a

Please sign in to comment.