Skip to content

Commit 256ee55

Browse files
author
Val Brodsky
committed
Prevent adding batches to live chat evaluation projects
1 parent 23cdbee commit 256ee55

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,16 @@ class Project(DbObject, Updateable, Deletable):
138138
_wait_processing_max_seconds = 3600
139139

140140
def is_chat_evaluation(self) -> bool:
141+
"""
142+
Returns:
143+
True if this project is a live chat evaluation project, False otherwise
144+
"""
141145
return self.media_type == MediaType.Conversational and self.editor_task_type == EditorTaskType.ModelChatEvaluation
142146

147+
def is_auto_data_generation(self) -> bool:
148+
return self.media_type == MediaType.LLMPromptCreation or self.media_type == MediaType.LLMPromptResponseCreation or self.is_chat_evaluation(
149+
)
150+
143151
def project_model_configs(self):
144152
query_str = """query ProjectModelConfigsPyApi($id: ID!) {
145153
project(where: {id : $id}) {
@@ -866,6 +874,10 @@ def create_batch(
866874
if self.queue_mode != QueueMode.Batch:
867875
raise ValueError("Project must be in batch mode")
868876

877+
if self.is_auto_data_generation():
878+
raise ValueError(
879+
"Cannot create batches for auto data generation projects")
880+
869881
dr_ids = []
870882
if data_rows is not None:
871883
for dr in data_rows:

libs/labelbox/tests/integration/test_chat_evaluation_ontology_project.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ def test_create_chat_evaluation_ontology_project(
3333
assert project.labeling_frontend().name == "Editor"
3434
assert project.ontology().name == ontology.name
3535

36-
with pytest.raises(MalformedQueryException,
37-
match="No valid data rows to add to project"):
36+
with pytest.raises(
37+
ValueError,
38+
match="Cannot create batches for auto data generation projects"):
3839
project.create_batch(
3940
rand_gen(str),
4041
[offline_conversational_data_row.uid], # sample of data row objects
4142
)
4243

43-
with pytest.raises(MalformedQueryException,
44-
match="No valid data rows to add to project"):
44+
with pytest.raises(
45+
ValueError,
46+
match="Cannot create batches for auto data generation projects"):
4547
with patch('labelbox.schema.project.MAX_SYNC_BATCH_ROW_COUNT',
4648
new=0): # force to async
4749

0 commit comments

Comments
 (0)