Skip to content

Commit 4bdf851

Browse files
authored
[QQC-2962] Add a method to get label count for project (#1380)
2 parents 37ae2ae + 3bac4d6 commit 4bdf851

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

labelbox/schema/project.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,20 @@ def _update_queue_mode(self, mode: "QueueMode") -> "QueueMode":
11491149

11501150
return mode
11511151

1152+
def get_label_count(self) -> int:
1153+
"""
1154+
Returns: the total number of labels in this project.
1155+
"""
1156+
1157+
query_str = """query LabelCountPyApi($projectId: ID!) {
1158+
project(where: {id: $projectId}) {
1159+
labelCount
1160+
}
1161+
}"""
1162+
1163+
res = self.client.execute(query_str, {'projectId': self.uid})
1164+
return res["project"]["labelCount"]
1165+
11521166
def get_queue_mode(self) -> "QueueMode":
11531167
"""
11541168
Provides the queue mode used for this project.

tests/integration/test_project.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,13 @@ def test_queue_mode(client, rand_gen):
280280
quality_mode=QualityMode.Consensus)
281281
assert project.auto_audit_number_of_labels == 3
282282
assert project.auto_audit_percentage == 0
283+
284+
285+
def test_label_count(client, configured_batch_project_with_label):
286+
project = client.create_project(name="test label count")
287+
assert project.get_label_count() == 0
288+
project.delete()
289+
290+
[source_project, _, _, _] = configured_batch_project_with_label
291+
num_labels = sum([1 for _ in source_project.labels()])
292+
assert source_project.get_label_count() == num_labels

0 commit comments

Comments
 (0)