8686 pass
8787
8888
89+ _MAX_BATCH_IDS = 1000
90+
91+
92+ def _validate_batch_ids (batch_ids : List [str ]) -> None :
93+ if not isinstance (batch_ids , list ):
94+ raise ValueError ("batch_ids filter expects a list." )
95+ if len (batch_ids ) == 0 :
96+ raise ValueError ("batch_ids filter expects a non-empty list." )
97+ if len (batch_ids ) > _MAX_BATCH_IDS :
98+ raise ValueError (
99+ f"batch_ids filter only supports a max of { _MAX_BATCH_IDS } items."
100+ )
101+
102+
89103DataRowPriority = int
90104LabelingParameterOverrideInput = Tuple [DataRowIdentifier , DataRowPriority ]
91105
@@ -1737,48 +1751,82 @@ def __check_data_rows_have_been_processed(
17371751 ]
17381752
17391753 def get_overview (
1740- self , details = False
1754+ self ,
1755+ details : bool = False ,
1756+ batch_ids : Optional [List [str ]] = None ,
17411757 ) -> Union [ProjectOverview , ProjectOverviewDetailed ]:
17421758 """Return the overview of a project.
17431759
17441760 This method returns the number of data rows per task queue and issues of a project,
17451761 which is equivalent to the Overview tab of a project.
17461762
17471763 Args:
1748- details (bool, optional): Whether to include detailed queue information for review and rework queues.
1749- Defaults to False.
1764+ details (bool, optional): Whether to include detailed queue information for
1765+ review and rework queues. Defaults to False.
1766+ batch_ids (Optional[List[str]], optional): When provided, limits counts to data
1767+ rows in the given batch(es). Multiple batch IDs return combined counts, not
1768+ per-batch breakdowns. Unknown or foreign batch IDs return zero counts.
1769+ Defaults to None (project-wide counts).
17501770
17511771 Returns:
1752- Union[ProjectOverview, ProjectOverviewDetailed]: An object representing the project overview.
1753- If `details` is False, returns a `ProjectOverview` object.
1754- If `details` is True, returns a `ProjectOverviewDetailed` object.
1772+ Union[ProjectOverview, ProjectOverviewDetailed]: An object representing the
1773+ project overview. If `details` is False, returns a `ProjectOverview` object.
1774+ If `details` is True, returns a `ProjectOverviewDetailed` object. When
1775+ `batch_ids` is set, `issues` is None because issue counts are not
1776+ batch-scoped.
17551777
17561778 Raises:
1779+ ValueError: If `batch_ids` is an empty list or exceeds the maximum allowed size.
17571780 Exception: If there is an error executing the query.
17581781
17591782 """
1760- query = """query ProjectGetOverviewPyApi($projectId: ID!) {
1761- project(where: { id: $projectId }) {
1762- workstreamStateCounts {
1783+ if batch_ids is not None :
1784+ _validate_batch_ids (batch_ids )
1785+
1786+ query = """query ProjectGetOverviewPyApi(
1787+ $projectId: ID!,
1788+ $batchIds: [String!],
1789+ $countInput: DataRowCountQueryInput,
1790+ $includeIssues: Boolean!
1791+ ) {
1792+ project(where: { id: $projectId }) {
1793+ workstreamStateCounts(batchIds: $batchIds) {
17631794 state
17641795 count
17651796 }
17661797 taskQueues {
17671798 queueType
17681799 name
1769- dataRowCount
1800+ dataRowCount(input: $countInput)
17701801 }
1771- issues {
1802+ issues @include(if: $includeIssues) {
17721803 totalCount
17731804 }
17741805 completedDataRowCount
17751806 }
17761807 }
17771808 """
17781809
1810+ variables : Dict [str , Any ] = {
1811+ "projectId" : self .uid ,
1812+ "batchIds" : batch_ids ,
1813+ "includeIssues" : batch_ids is None ,
1814+ }
1815+ if batch_ids is not None :
1816+ variables ["countInput" ] = {
1817+ "searchQuery" : {
1818+ "scope" : {"projectId" : self .uid },
1819+ "query" : [
1820+ {"ids" : batch_ids , "operator" : "is" , "type" : "batch" }
1821+ ],
1822+ }
1823+ }
1824+ else :
1825+ variables ["countInput" ] = None
1826+
17791827 # Must use experimental to access "issues"
17801828 result = self .client .execute (
1781- query , { "projectId" : self . uid } , experimental = True
1829+ query , variables , experimental = True
17821830 )["project" ]
17831831
17841832 # Reformat category names
@@ -1788,7 +1836,10 @@ def get_overview(
17881836 if st ["state" ] != "NotInTaskQueue"
17891837 }
17901838
1791- overview ["issues" ] = result .get ("issues" , {}).get ("totalCount" )
1839+ if batch_ids is None :
1840+ overview ["issues" ] = result .get ("issues" , {}).get ("totalCount" )
1841+ else :
1842+ overview ["issues" ] = None
17921843
17931844 # Rename categories
17941845 overview ["to_label" ] = overview .pop ("unlabeled" )
0 commit comments