From 51cc37c8b3a826da1859feaf397d49ee5153788d Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Thu, 27 Jun 2024 16:49:10 -0400 Subject: [PATCH] Add more test for adding batch to live chat model eval projects --- libs/labelbox/src/labelbox/schema/project.py | 4 ++-- .../test_chat_evaluation_ontology_project.py | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/libs/labelbox/src/labelbox/schema/project.py b/libs/labelbox/src/labelbox/schema/project.py index d96485ccf..f1263e06d 100644 --- a/libs/labelbox/src/labelbox/schema/project.py +++ b/libs/labelbox/src/labelbox/schema/project.py @@ -53,6 +53,7 @@ DataRowPriority] logger = logging.getLogger(__name__) +MAX_SYNC_BATCH_ROW_COUNT = 1_000 def validate_labeling_parameter_overrides( @@ -861,7 +862,6 @@ def create_batch( Returns: the created batch """ - # @TODO: make this automatic? if self.queue_mode != QueueMode.Batch: raise ValueError("Project must be in batch mode") @@ -897,7 +897,7 @@ def create_batch( consensus_settings = ConsensusSettings(**consensus_settings).dict( by_alias=True) - if row_count >= 1_000: + if row_count >= MAX_SYNC_BATCH_ROW_COUNT: return self._create_batch_async(name, dr_ids, global_keys, priority, consensus_settings) else: diff --git a/libs/labelbox/tests/integration/test_chat_evaluation_ontology_project.py b/libs/labelbox/tests/integration/test_chat_evaluation_ontology_project.py index f0b58f1d3..078f7bab1 100644 --- a/libs/labelbox/tests/integration/test_chat_evaluation_ontology_project.py +++ b/libs/labelbox/tests/integration/test_chat_evaluation_ontology_project.py @@ -1,4 +1,6 @@ import pytest +from unittest.mock import patch + from labelbox import MediaType from labelbox.schema.ontology_kind import OntologyKind from labelbox.exceptions import MalformedQueryException @@ -6,8 +8,8 @@ def test_create_chat_evaluation_ontology_project( client, chat_evaluation_ontology, - live_chat_evaluation_project_with_new_dataset, conversation_data_row, - rand_gen): + live_chat_evaluation_project_with_new_dataset, + offline_conversational_data_row, rand_gen): ontology = chat_evaluation_ontology # here we are essentially testing the ontology creation which is a fixture @@ -35,9 +37,20 @@ def test_create_chat_evaluation_ontology_project( match="No valid data rows to add to project"): project.create_batch( rand_gen(str), - [conversation_data_row.uid], # sample of data row objects + [offline_conversational_data_row.uid], # sample of data row objects ) + with pytest.raises(MalformedQueryException, + match="No valid data rows to add to project"): + with patch('labelbox.schema.project.MAX_SYNC_BATCH_ROW_COUNT', + new=0): # force to async + + project.create_batch( + rand_gen(str), + [offline_conversational_data_row.uid + ], # sample of data row objects + ) + def test_create_chat_evaluation_ontology_project_existing_dataset( client, chat_evaluation_ontology,