Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invigilator serialization issue #1494

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading