From edbb88df4327686336afa8723bda21b2a71117dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Francisco=20Calvo?= Date: Fri, 13 Dec 2024 10:12:13 +0100 Subject: [PATCH] feat: add record's inserted_at and updated_at to the list of record attributes used to export datasets to the hub --- .../src/argilla_server/contexts/hub.py | 2 ++ .../unit/contexts/hub/test_hub_dataset.py | 1 - .../contexts/hub/test_hub_dataset_exporter.py | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/argilla-server/src/argilla_server/contexts/hub.py b/argilla-server/src/argilla_server/contexts/hub.py index 50346408fd..3efedaf93f 100644 --- a/argilla-server/src/argilla_server/contexts/hub.py +++ b/argilla-server/src/argilla_server/contexts/hub.py @@ -273,6 +273,8 @@ def _row_attributes(self, record: Record) -> dict: return { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), } diff --git a/argilla-server/tests/unit/contexts/hub/test_hub_dataset.py b/argilla-server/tests/unit/contexts/hub/test_hub_dataset.py index 94347a76d5..ead1ba551b 100644 --- a/argilla-server/tests/unit/contexts/hub/test_hub_dataset.py +++ b/argilla-server/tests/unit/contexts/hub/test_hub_dataset.py @@ -18,7 +18,6 @@ from sqlalchemy.ext.asyncio import AsyncSession from argilla_server.api.schemas.v1.datasets import HubDatasetMapping, HubDatasetMappingItem -from argilla_server.api.schemas.v1.metadata_properties import IntegerMetadataProperty from argilla_server.enums import DatasetStatus, QuestionType from argilla_server.models import Record from argilla_server.contexts.hub import HubDataset diff --git a/argilla-server/tests/unit/contexts/hub/test_hub_dataset_exporter.py b/argilla-server/tests/unit/contexts/hub/test_hub_dataset_exporter.py index f97b8b7321..0fac9be2db 100644 --- a/argilla-server/tests/unit/contexts/hub/test_hub_dataset_exporter.py +++ b/argilla-server/tests/unit/contexts/hub/test_hub_dataset_exporter.py @@ -94,6 +94,8 @@ def test_export_to(self, sync_test_session, hf_api: HfApi, hf_dataset_name: str) assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", } @@ -279,6 +281,8 @@ def test_export_to_with_text_question(self, sync_test_session, hf_dataset_name: assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "text-question.responses": ["This is a response", "This is another response"], @@ -340,6 +344,8 @@ def test_export_to_with_text_question_and_suggestion(self, sync_test_session, hf assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "text-question.responses": ["This is a response", "This is another response"], @@ -402,6 +408,8 @@ def test_export_to_with_rating_question(self, sync_test_session, hf_dataset_name assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "rating-question.responses": [2, 0], @@ -468,6 +476,8 @@ def test_export_to_with_rating_question_and_suggestion(self, sync_test_session, assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "rating-question.responses": [2, 0], @@ -529,6 +539,8 @@ def test_export_to_with_label_question(self, sync_test_session, hf_dataset_name: assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "label-question.responses": ["label-b", "label-a"], @@ -594,6 +606,8 @@ def test_export_to_with_label_question_and_suggestion(self, sync_test_session, h assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "label-question.responses": ["label-b", "label-a"], @@ -655,6 +669,8 @@ def test_export_to_with_multi_label_question(self, sync_test_session, hf_dataset assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "multi-label-question.responses": [["label-a", "label-b"], ["label-c", "label-a"]], @@ -720,6 +736,8 @@ def test_export_to_with_multi_label_question_and_suggestion(self, sync_test_sess assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "multi-label-question.responses": [["label-a", "label-b"], ["label-c", "label-a"]], @@ -790,6 +808,8 @@ def test_export_to_with_ranking_question(self, sync_test_session, hf_dataset_nam assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "ranking-question.responses": [ @@ -880,6 +900,8 @@ def test_export_to_with_ranking_question_and_suggestion(self, sync_test_session, assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "ranking-question.responses": [ @@ -964,6 +986,8 @@ def test_export_to_with_span_question(self, sync_test_session, hf_dataset_name: assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "span-question.responses": [ @@ -1047,6 +1071,8 @@ def test_export_to_with_span_question_and_suggestion(self, sync_test_session, hf assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "span-question.responses": [ @@ -1102,6 +1128,8 @@ def test_export_to_with_draft_response(self, sync_test_session, hf_dataset_name: assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "text-question.responses": [None], @@ -1143,6 +1171,8 @@ def test_export_to_with_discarded_response(self, sync_test_session, hf_dataset_n assert exported_dataset[0] == { "id": record.external_id, "status": record.status, + "inserted_at": record.inserted_at, + "updated_at": record.updated_at, "_server_id": str(record.id), "text": "Hello World", "text-question.responses": [None],