-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
151 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
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,2 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
__version__ = "1.2.0" | ||
__version__ = "1.3.0" |
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 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Setup for automated_grader package.""" | ||
|
||
import os | ||
|
||
from dotenv import find_dotenv, load_dotenv | ||
|
||
|
||
# for local development and unit testing | ||
dotenv_path = find_dotenv() | ||
if os.path.exists(dotenv_path): | ||
load_dotenv(dotenv_path=dotenv_path, verbose=True) | ||
|
||
|
||
# pylint: disable=too-few-public-methods | ||
class AGRubric: | ||
"""Constants for the AutomatedGrader class.""" | ||
|
||
INCORRECT_RESPONSE_TYPE_PENALTY_PCT = float(os.getenv("AG_INCORRECT_RESPONSE_TYPE_PENALTY_PCT", "0.10")) | ||
INCORRECT_RESPONSE_VALUE_PENALTY_PCT = float(os.getenv("AG_INCORRECT_RESPONSE_VALUE_PENALTY_PCT", "0.15")) | ||
RESPONSE_FAILED_PENALTY_PCT = float(os.getenv("AG_RESPONSE_FAILED_PENALTY_PCT", "0.20")) | ||
INVALID_RESPONSE_STRUCTURE_PENALTY_PCT = float(os.getenv("AG_INVALID_RESPONSE_STRUCTURE_PENALTY_PCT", "0.30")) |
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,34 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Custom exceptions for the AutomatedGrader class.""" | ||
|
||
from .config import AGRubric | ||
|
||
class InvalidResponseStructureError(Exception): | ||
|
||
class AGException(Exception): | ||
"""A custom base exception for the AutomatedGrader class.""" | ||
|
||
def __init__(self, message: str, penalty_pct: float): | ||
self.message = message | ||
|
||
if not isinstance(penalty_pct, float): | ||
raise TypeError(f"penalty_pct must be a float. penalty_pct: {penalty_pct}") | ||
if not 0 <= penalty_pct <= 1: | ||
raise ValueError(f"penalty_pct must be between 0 and 1. penalty_pct: {penalty_pct}") | ||
|
||
self._penalty_pct = penalty_pct | ||
super().__init__(self.message) | ||
|
||
@property | ||
def penalty_pct(self): | ||
"""Return the penalty percentage for this error.""" | ||
return self._penalty_pct | ||
|
||
|
||
class InvalidResponseStructureError(AGException): | ||
"""A custom exception for the AutomatedGrader class.""" | ||
|
||
def __init__(self, message): | ||
self.message = message | ||
super().__init__(self.message) | ||
super().__init__(self.message, penalty_pct=AGRubric.INVALID_RESPONSE_STRUCTURE_PENALTY_PCT) | ||
|
||
|
||
class IncorrectResponseValueError(Exception): | ||
class IncorrectResponseValueError(AGException): | ||
"""A custom exception for the AutomatedGrader class.""" | ||
|
||
def __init__(self, message): | ||
self.message = message | ||
super().__init__(self.message) | ||
super().__init__(self.message, penalty_pct=AGRubric.INCORRECT_RESPONSE_VALUE_PENALTY_PCT) | ||
|
||
|
||
class IncorrectResponseTypeError(Exception): | ||
class IncorrectResponseTypeError(AGException): | ||
"""A custom exception for the AutomatedGrader class.""" | ||
|
||
def __init__(self, message): | ||
self.message = message | ||
super().__init__(self.message) | ||
super().__init__(self.message, penalty_pct=AGRubric.INCORRECT_RESPONSE_TYPE_PENALTY_PCT) | ||
|
||
|
||
class ResponseFailedError(Exception): | ||
class ResponseFailedError(AGException): | ||
"""A custom exception for the AutomatedGrader class.""" | ||
|
||
def __init__(self, message): | ||
self.message = message | ||
super().__init__(self.message) | ||
super().__init__(self.message, penalty_pct=AGRubric.RESPONSE_FAILED_PENALTY_PCT) |
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 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 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 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 |
---|---|---|
|
@@ -15,5 +15,5 @@ | |
package_data={ | ||
"automated_grader": ["*.md"], | ||
}, | ||
install_requires=[], | ||
install_requires=["pydantic>=2.0.0"], | ||
) |