Skip to content

Commit ff973cf

Browse files
authored
[Integration][ADO] Improved the PR kind to process concurrently (#1536)
1 parent 1076e3e commit ff973cf

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Diff for: integrations/azure-devops/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
<!-- towncrier release notes start -->
99

10+
## 0.1.143 (2025-04-03)
11+
12+
13+
### Improvements
14+
15+
- Added support for fetching pull requests concurently
16+
17+
1018
## 0.1.142 (2025-04-03)
1119

1220

Diff for: integrations/azure-devops/azure_devops/client/azure_devops_client.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
MAX_ALLOWED_FILE_SIZE_IN_BYTES = 1 * 1024 * 1024
3131
MAX_CONCURRENT_FILE_DOWNLOADS = 50
3232
MAX_CONCURRENT_REPOS_FOR_FILE_PROCESSING = 25
33+
MAX_CONCURRENT_REPOS_FOR_PULL_REQUESTS = 25
3334

3435

3536
class AzureDevopsClient(HTTPBaseClient):
@@ -182,12 +183,20 @@ async def generate_pull_requests(
182183
async for repositories in self.generate_repositories(
183184
include_disabled_repositories=False
184185
):
185-
for repository in repositories:
186-
pull_requests_url = f"{self._organization_base_url}/{repository['project']['id']}/{API_URL_PREFIX}/git/repositories/{repository['id']}/pullrequests"
187-
async for filtered_pull_requests in self._get_paginated_by_top_and_skip(
188-
pull_requests_url, search_filters
189-
):
190-
yield filtered_pull_requests
186+
semaphore = asyncio.BoundedSemaphore(MAX_CONCURRENT_REPOS_FOR_PULL_REQUESTS)
187+
tasks = [
188+
semaphore_async_iterator(
189+
semaphore,
190+
functools.partial(
191+
self._get_paginated_by_top_and_skip,
192+
f"{self._organization_base_url}/{repository['project']['id']}/{API_URL_PREFIX}/git/repositories/{repository['id']}/pullrequests",
193+
search_filters,
194+
),
195+
)
196+
for repository in repositories
197+
]
198+
async for pull_requests in stream_async_iterators_tasks(*tasks):
199+
yield pull_requests
191200

192201
async def generate_pipelines(self) -> AsyncGenerator[list[dict[Any, Any]], None]:
193202
async for projects in self.generate_projects():

Diff for: integrations/azure-devops/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "azure-devops"
3-
version = "0.1.142"
3+
version = "0.1.143"
44
description = "An Azure Devops Ocean integration"
55
authors = ["Matan Geva <[email protected]>"]
66

0 commit comments

Comments
 (0)