Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,20 @@ def _update_queue_mode(self, mode: "QueueMode") -> "QueueMode":

return mode

def get_label_count(self) -> int:
"""
Returns: the total number of labels in this project.
"""

query_str = """query LabelCountPyApi($projectId: ID!) {
project(where: {id: $projectId}) {
labelCount
}
}"""

res = self.client.execute(query_str, {'projectId': self.uid})
return res["project"]["labelCount"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any error reporting? I.e. what happens if mutation blows up or returns an error?


def get_queue_mode(self) -> "QueueMode":
"""
Provides the queue mode used for this project.
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,13 @@ def test_queue_mode(client, rand_gen):
quality_mode=QualityMode.Consensus)
assert project.auto_audit_number_of_labels == 3
assert project.auto_audit_percentage == 0


def test_label_count(client, configured_batch_project_with_label):
project = client.create_project(name="test label count")
assert project.get_label_count() == 0
project.delete()

[source_project, _, _, _] = configured_batch_project_with_label
num_labels = sum([1 for _ in source_project.labels()])
assert source_project.get_label_count() == num_labels