Skip to content

Commit

Permalink
fix: Set deleted user id when a response model has no user_id
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Jun 20, 2024
1 parent be6ad5f commit 575d746
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion argilla/src/argilla/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit 575d746

Please sign in to comment.