Skip to content

Commit

Permalink
Merge pull request #1494 from expectedparrot/fix_exception_invigilato…
Browse files Browse the repository at this point in the history
…r_serialization

Fix invigilator serialization issue
  • Loading branch information
zer0dss authored Jan 17, 2025
2 parents b936a19 + 2713bc6 commit 4013d70
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions edsl/jobs/interviews/InterviewExceptionEntry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import traceback
import datetime
from edsl.agents.InvigilatorBase import InvigilatorBase


class InterviewExceptionEntry:
Expand All @@ -9,7 +10,7 @@ def __init__(
self,
*,
exception: Exception,
invigilator: "Invigilator",
invigilator: "InvigilatorBase",
traceback_format="text",
answers=None,
):
Expand All @@ -20,6 +21,8 @@ def __init__(
self.traceback_format = traceback_format
self.answers = answers

# breakpoint()

@property
def question_type(self):
# return self.failed_question.question.question_type
Expand Down Expand Up @@ -163,20 +166,27 @@ def to_dict(self) -> dict:
>>> entry = InterviewExceptionEntry.example()
>>> _ = entry.to_dict()
"""
return {
invigilator = (
self.invigilator.to_dict() if self.invigilator is not None else None
)
d = {
"exception": self.serialize_exception(self.exception),
"time": self.time,
"traceback": self.traceback,
"invigilator": self.invigilator.to_dict(),
"invigilator": invigilator,
}
return d

@classmethod
def from_dict(cls, data: dict) -> "InterviewExceptionEntry":
"""Create an InterviewExceptionEntry from a dictionary."""
from edsl.agents.Invigilator import InvigilatorAI

exception = cls.deserialize_exception(data["exception"])
invigilator = InvigilatorAI.from_dict(data["invigilator"])
if data["invigilator"] is None:
invigilator = None
else:
invigilator = InvigilatorAI.from_dict(data["invigilator"])
return cls(exception=exception, invigilator=invigilator)


Expand Down

0 comments on commit 4013d70

Please sign in to comment.