4141from labelbox .schema .task import Task
4242from labelbox .schema .task_queue import TaskQueue
4343from labelbox .schema .ontology_kind import (EditorTaskType , OntologyKind )
44- from labelbox .schema .project_overview import ProjectOverview
44+ from labelbox .schema .project_overview import ProjectOverview , ProjectOverviewDetailed
4545
4646if TYPE_CHECKING :
4747 from labelbox import BulkImportRequest
@@ -1751,16 +1751,25 @@ def __check_data_rows_have_been_processed(
17511751 return response ["queryAllDataRowsHaveBeenProcessed" ][
17521752 "allDataRowsHaveBeenProcessed" ]
17531753
1754- def get_overview (self ) -> ProjectOverview :
1755- """ Return the number of data rows per task queue, and issues of a project
1756- Equivalent of the Overview tab of a project
1754+ def get_overview (self , details = False ) -> Union [ProjectOverview , ProjectOverviewDetailed ]:
1755+ """Return the overview of a project.
17571756
1758- Args:
1759- with_issues: (optional) boolean to include issues in the overview
1760- Returns:
1761- Object Project_Overview
1762- """
1757+ This method returns the number of data rows per task queue and issues of a project,
1758+ which is equivalent to the Overview tab of a project.
1759+
1760+ Args:
1761+ details (bool, optional): Whether to include detailed queue information for review and rework queues.
1762+ Defaults to False.
1763+
1764+ Returns:
1765+ Union[ProjectOverview, ProjectOverviewDetailed]: An object representing the project overview.
1766+ If `details` is False, returns a `ProjectOverview` object.
1767+ If `details` is True, returns a `ProjectOverviewDetailed` object.
17631768
1769+ Raises:
1770+ Exception: If there is an error executing the query.
1771+
1772+ """
17641773 query = """query ProjectGetOverviewPyApi($projectId: ID!) {
17651774 project(where: { id: $projectId }) {
17661775 workstreamStateCounts {
@@ -1782,31 +1791,38 @@ def get_overview(self) -> ProjectOverview:
17821791
17831792 # Must use experimental to access "issues"
17841793 result = self .client .execute (query , {"projectId" : self .uid },
1785- experimental = True )["project" ]
1794+ experimental = True )["project" ]
17861795
1796+ # Reformat category names
17871797 overview = {
17881798 utils .snake_case (st ["state" ]): st ["count" ]
17891799 for st in result .get ("workstreamStateCounts" )
17901800 if st ["state" ] != "NotInTaskQueue"
17911801 }
17921802
1793- review_queues = {
1794- tq ["name" ]: tq .get ("dataRowCount" )
1795- for tq in result .get ("taskQueues" )
1796- if tq .get ("queueType" ) == "MANUAL_REVIEW_QUEUE"
1797- }
1798-
1799- # Store the total number of data rows in review
1800- review_queues ["all" ] = overview .get ("in_review" )
1801- overview ["in_review" ] = review_queues
1802-
18031803 overview ["issues" ] = result .get ("issues" , {}).get ("totalCount" )
18041804
1805- # Rename keys
1805+ # Rename categories
18061806 overview ["to_label" ] = overview .pop ("unlabeled" )
1807- overview ["all_in_data_rows " ] = overview .pop ("all" )
1807+ overview ["total_data_rows " ] = overview .pop ("all" )
18081808
1809- return ProjectOverview (** overview )
1809+ if not details :
1810+ return ProjectOverview (** overview )
1811+ else :
1812+ # Build dictionary for queue details for review and rework queues
1813+ for category in ["rework" , "review" ]:
1814+ queues = [
1815+ {tq ["name" ]: tq .get ("dataRowCount" )}
1816+ for tq in result .get ("taskQueues" )
1817+ if tq .get ("queueType" ) == f"MANUAL_{ category .upper ()} _QUEUE"
1818+ ]
1819+
1820+ overview [f"in_{ category } " ] = {
1821+ "data" : queues ,
1822+ "total" : overview [f"in_{ category } " ]
1823+ }
1824+
1825+ return ProjectOverviewDetailed (** overview )
18101826
18111827 def clone (self ) -> "Project" :
18121828 """
0 commit comments