Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
lpm0073 committed Nov 28, 2023
1 parent 9d33b3d commit d911787
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
File renamed without changes.
17 changes: 12 additions & 5 deletions grader/grader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AutomatedGrader:

def __init__(self, assignment):
self.assignment = assignment
with open(REQUIRED_KEYS_SPEC, "r", encoding="utf-8") as f: # pylint: disable=invalid-name
with open("data/" + REQUIRED_KEYS_SPEC, "r", encoding="utf-8") as f: # pylint: disable=invalid-name
self.required_keys = json.load(f)

def validate_keys(self, subject, control):
Expand All @@ -31,15 +31,19 @@ def validate_keys(self, subject, control):
required_keys = set(control.keys())

if not required_keys.issubset(assignment_keys):
raise InvalidResponseStructureError("The assignment is missing one or more required keys.")
missing_keys = required_keys.difference(assignment_keys)
raise InvalidResponseStructureError(
f"The assignment is missing one or more required keys. missing: {missing_keys}"
)
return True

def validate_statuscode(self):
"""Validate that the assignment's statusCode is 200."""
if not isinstance(self.assignment.get("statusCode"), int):
raise IncorrectResponseTypeError("The assignment's statusCode must be an integer.")
if not self.assignment["statusCode"] == 200:
raise ResponseFailedError("The assignment's statusCode must be 200.")
status_code = self.assignment["statusCode"]
if not status_code == 200:
raise ResponseFailedError(f"The assignment's statusCode must be 200. received: {status_code}")
return True

def validate_base64encoded(self):
Expand Down Expand Up @@ -96,7 +100,10 @@ def validate_metadata(self):
body = self.assignment.get("body")
request_meta_data = body["request_meta_data"]
if not isinstance(request_meta_data, dict):
raise InvalidResponseStructureError(f"The assignment must has a dict named request_meta_data. body: {body}")
meta_data_type = type(request_meta_data)
raise InvalidResponseStructureError(
f"The assignment must has a dict named request_meta_data. received: {meta_data_type}"
)
if not request_meta_data["lambda"] == "lambda_langchain":
raise IncorrectResponseValueError(f"The request_meta_data.lambda must be lambda_langchain. body: {body}")
if not request_meta_data["model"] == "gpt-3.5-turbo":
Expand Down

0 comments on commit d911787

Please sign in to comment.