Skip to content

Commit 64c53ae

Browse files
committed
Allow to pass batch consensus settings when creating a batch
1 parent 70484dd commit 64c53ae

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from pydantic import BaseModel
2+
3+
4+
class ConsensusSettings(BaseModel):
5+
"""Container for holding consensus quality settings
6+
7+
>>> ConsensusSettings(
8+
>>> numberOfLabels = 2,
9+
>>> coveragePercentage = 0.2
10+
>>> )
11+
12+
Args:
13+
numberOfLabels: Number of labels for consensus
14+
coveragePercentage: Percentage of data rows to be labeled more than once
15+
"""
16+
17+
numberOfLabels: int
18+
coveragePercentage: float

labelbox/schema/project.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from labelbox.orm.db_object import DbObject, Updateable, Deletable
1717
from labelbox.orm.model import Entity, Field, Relationship
1818
from labelbox.pagination import PaginatedCollection
19+
from labelbox.schema.consensus_settings import ConsensusSettings
1920
from labelbox.schema.media_type import MediaType
2021
from labelbox.schema.queue_mode import QueueMode
2122
from labelbox.schema.resource_tag import ResourceTag
@@ -561,7 +562,11 @@ def setup(self, labeling_frontend, labeling_frontend_options) -> None:
561562
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
562563
self.update(setup_complete=timestamp)
563564

564-
def create_batch(self, name: str, data_rows: List[str], priority: int = 5):
565+
def create_batch(self,
566+
name: str,
567+
data_rows: List[str],
568+
priority: int = 5,
569+
consensus_settings: Optional[ConsensusSettings] = None):
565570
"""Create a new batch for a project. Batches is in Beta and subject to change
566571
567572
Args:
@@ -603,9 +608,14 @@ def create_batch(self, name: str, data_rows: List[str], priority: int = 5):
603608
params = {
604609
"projectId": self.uid,
605610
"batchInput": {
606-
"name": name,
607-
"dataRowIds": dr_ids,
608-
"priority": priority
611+
"name":
612+
name,
613+
"dataRowIds":
614+
dr_ids,
615+
"priority":
616+
priority,
617+
"consensusSettings":
618+
consensus_settings.dict() if consensus_settings else None
609619
}
610620
}
611621

0 commit comments

Comments
 (0)