-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add type prop to job result dicts
- Loading branch information
1 parent
b4d52eb
commit eaf190e
Showing
3 changed files
with
36 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 34 additions & 27 deletions
61
worker/orca_grader/common/grading_job/grading_job_result.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
from typing import List, Optional | ||
from orca_grader.container.grading_script.grading_script_command_response import GradingScriptCommandResponse | ||
from orca_grader.common.types.grading_job_json_types import GradingJobOutputJSON, GradingJobOutputJSON | ||
from orca_grader.common.types.grading_job_json_types import GradingJobResultJSON, GradingJobResultJSON | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
|
||
class GradingJobResult: | ||
|
||
def __init__(self, command_responses: List[GradingScriptCommandResponse], | ||
execution_errors: List[Exception] = [], | ||
output: str = None) -> None: | ||
self.__command_responses = command_responses | ||
self.__execution_errors = execution_errors | ||
self.__output = output | ||
|
||
def get_command_responses(self) -> List[GradingScriptCommandResponse]: | ||
return self.__command_responses | ||
|
||
def get_output(self) -> Optional[str]: | ||
return self.__output | ||
|
||
def get_execution_errors(self) -> List[Exception]: | ||
return self.__execution_errors | ||
|
||
def to_json(self) -> GradingJobOutputJSON: | ||
result = dict() | ||
json_responses = list(map(lambda c: c.to_json(), self.__command_responses)) | ||
result["shell_responses"] = json_responses | ||
if self.__execution_errors is not None: | ||
result["errors"] = list(map(lambda e: f"{e.__class__.__name__}: {e}", self.__execution_errors)) | ||
if self.__output is not None: | ||
result["output"] = self.__output | ||
return result | ||
|
||
def __init__(self, command_responses: List[GradingScriptCommandResponse], | ||
execution_errors: List[Exception] = [], | ||
output: str = None) -> None: | ||
self.__command_responses = command_responses | ||
self.__execution_errors = execution_errors | ||
self.__output = output | ||
|
||
def get_command_responses(self) -> List[GradingScriptCommandResponse]: | ||
return self.__command_responses | ||
|
||
def get_output(self) -> Optional[str]: | ||
return self.__output | ||
|
||
def get_execution_errors(self) -> List[Exception]: | ||
return self.__execution_errors | ||
|
||
def to_json(self) -> GradingJobResultJSON: | ||
result = {"type": "GradingJobResult"} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
williams-jack
Author
Collaborator
|
||
json_responses = list( | ||
map(lambda c: c.to_json(), self.__command_responses)) | ||
result["shell_responses"] = json_responses | ||
if self.__execution_errors is not None: | ||
result["errors"] = list( | ||
map( | ||
lambda e: f"{e.__class__.__name__}: {e}", | ||
self.__execution_errors | ||
) | ||
) | ||
if self.__output is not None: | ||
result["output"] = self.__output | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This looks like a typo (duplication)