Skip to content

Commit cf02be9

Browse files
Merge pull request #79 from nathan-weinberg/new-exec
feat: add new InvalidModelError and handling
2 parents dbf4db2 + f851f86 commit cf02be9

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/instructlab/eval/exceptions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ def __init__(self, path) -> None:
2222
self.message = f"Model could not be found at {path}"
2323

2424

25+
class InvalidModelError(EvalError):
26+
"""
27+
Error raised when model can be found but is invalid
28+
29+
Attributes
30+
message error message to be printed on raise
31+
path filepath of model location
32+
reason root cause for model invalidity
33+
"""
34+
35+
def __init__(self, path, reason) -> None:
36+
super().__init__()
37+
self.path = path
38+
self.reason = reason
39+
self.message = f"Model found at {path} but was invalid due to: {reason}"
40+
41+
2542
class InvalidGitRepoError(EvalError):
2643
"""
2744
Error raised when taxonomy dir provided isn't a valid git repo

src/instructlab/eval/mmlu.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# First Party
1313
from instructlab.eval.evaluator import Evaluator
1414
from instructlab.eval.exceptions import (
15+
InvalidModelError,
1516
InvalidTasksDirError,
1617
ModelNotFoundError,
1718
TasksDirNotFoundError,
@@ -158,6 +159,9 @@ def _simple_evaluate_with_error_handling(self, **kwargs):
158159
ose
159160
) or "does not appear to have a file named" in str(ose):
160161
raise ModelNotFoundError(self.model_path) from ose
162+
if "is not a valid JSON file" in str(ose):
163+
reason = "Looked for valid JSON file but couldn't find one - are you pointing at a directory with a 'config.json'?"
164+
raise InvalidModelError(self.model_path, reason) from ose
161165
raise
162166

163167

0 commit comments

Comments
 (0)