From 575d7463d0fb8b72530823230d0e7790781af015 Mon Sep 17 00:00:00 2001 From: Francisco Aranda Date: Thu, 20 Jun 2024 10:05:20 +0200 Subject: [PATCH] fix: Set deleted user id when a response model has no user_id --- argilla/src/argilla/responses.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/argilla/src/argilla/responses.py b/argilla/src/argilla/responses.py index d27c1c0f5b..92dce51285 100644 --- a/argilla/src/argilla/responses.py +++ b/argilla/src/argilla/responses.py @@ -19,6 +19,7 @@ from argilla._models import UserResponseModel, ResponseStatus as ResponseStatusModel from argilla._resource import Resource from argilla.settings import RankingQuestion +from argilla.users import DELETED_USER if TYPE_CHECKING: from argilla import Argilla, Dataset, Record @@ -143,7 +144,7 @@ def status(self, status: ResponseStatus) -> None: self._model.status = status @property - def user_id(self) -> UUID: + def user_id(self) -> Optional[UUID]: """Returns the user_id of the UserResponse""" return self._model.user_id @@ -160,6 +161,10 @@ def answers(self) -> List[Response]: @classmethod def from_model(cls, model: UserResponseModel, dataset: "Dataset") -> "UserResponse": """Creates a UserResponse from a ResponseModel""" + + if model.user_id is None: + model.user_id = DELETED_USER.id + answers = cls.__model_as_response_list(model) for answer in answers: question = dataset.settings.question_by_name(answer.question_name)