Skip to content

Commit 04195e1

Browse files
author
Val Brodsky
committed
Add more test for adding batch to live chat model eval projects
1 parent 2a83849 commit 04195e1

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

libs/labelbox/src/labelbox/schema/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
DataRowPriority]
5454

5555
logger = logging.getLogger(__name__)
56+
MAX_SYNC_BATCH_ROW_COUNT = 1_000
5657

5758

5859
def validate_labeling_parameter_overrides(
@@ -861,7 +862,6 @@ def create_batch(
861862
862863
Returns: the created batch
863864
"""
864-
865865
# @TODO: make this automatic?
866866
if self.queue_mode != QueueMode.Batch:
867867
raise ValueError("Project must be in batch mode")
@@ -897,7 +897,7 @@ def create_batch(
897897
consensus_settings = ConsensusSettings(**consensus_settings).dict(
898898
by_alias=True)
899899

900-
if row_count >= 1_000:
900+
if row_count >= MAX_SYNC_BATCH_ROW_COUNT:
901901
return self._create_batch_async(name, dr_ids, global_keys, priority,
902902
consensus_settings)
903903
else:

libs/labelbox/tests/integration/test_chat_evaluation_ontology_project.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import pytest
2+
from unittest.mock import patch
3+
24
from labelbox import MediaType
35
from labelbox.schema.ontology_kind import OntologyKind
46
from labelbox.exceptions import MalformedQueryException
57

68

79
def test_create_chat_evaluation_ontology_project(
810
client, chat_evaluation_ontology,
9-
live_chat_evaluation_project_with_new_dataset, conversation_data_row,
10-
rand_gen):
11+
live_chat_evaluation_project_with_new_dataset,
12+
offline_conversational_data_row, rand_gen):
1113
ontology = chat_evaluation_ontology
1214

1315
# here we are essentially testing the ontology creation which is a fixture
@@ -31,12 +33,23 @@ def test_create_chat_evaluation_ontology_project(
3133
assert project.labeling_frontend().name == "Editor"
3234
assert project.ontology().name == ontology.name
3335

36+
# with pytest.raises(MalformedQueryException,
37+
# match="No valid data rows to add to project"):
38+
# project.create_batch(
39+
# rand_gen(str),
40+
# [offline_conversational_data_row.uid], # sample of data row objects
41+
# )
42+
3443
with pytest.raises(MalformedQueryException,
3544
match="No valid data rows to add to project"):
36-
project.create_batch(
37-
rand_gen(str),
38-
[conversation_data_row.uid], # sample of data row objects
39-
)
45+
with patch('labelbox.schema.project.MAX_SYNC_BATCH_ROW_COUNT',
46+
new=0): # force to async
47+
48+
project.create_batch(
49+
rand_gen(str),
50+
[offline_conversational_data_row.uid
51+
], # sample of data row objects
52+
)
4053

4154

4255
def test_create_chat_evaluation_ontology_project_existing_dataset(

0 commit comments

Comments
 (0)