diff --git a/edsl/jobs/interviews/InterviewExceptionEntry.py b/edsl/jobs/interviews/InterviewExceptionEntry.py index 74f7638f..8e3db7d3 100644 --- a/edsl/jobs/interviews/InterviewExceptionEntry.py +++ b/edsl/jobs/interviews/InterviewExceptionEntry.py @@ -1,5 +1,6 @@ import traceback import datetime +from edsl.agents.InvigilatorBase import InvigilatorBase class InterviewExceptionEntry: @@ -9,7 +10,7 @@ def __init__( self, *, exception: Exception, - invigilator: "Invigilator", + invigilator: "InvigilatorBase", traceback_format="text", answers=None, ): @@ -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 @@ -163,12 +166,16 @@ 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": @@ -176,7 +183,10 @@ def from_dict(cls, data: dict) -> "InterviewExceptionEntry": 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)