Skip to content

Commit 34471f2

Browse files
authored
Merge pull request #1054 from UiPath/akshaya/faster_du
fix(FasterDUTests): faster document understanding tests
2 parents 55a0c2b + 8201bd4 commit 34471f2

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.3.1"
3+
version = "2.3.2"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/platform/documents/_documents_service.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ def __init__(
124124
self,
125125
config: UiPathApiConfig,
126126
execution_context: UiPathExecutionContext,
127+
polling_interval: float = POLLING_INTERVAL,
128+
polling_timeout: float = POLLING_TIMEOUT,
127129
) -> None:
128130
super().__init__(config=config, execution_context=execution_context)
131+
self.polling_interval = polling_interval
132+
self.polling_timeout = polling_timeout
129133

130134
def _get_common_headers(self) -> Dict[str, str]:
131135
return {
@@ -479,12 +483,14 @@ async def _start_extraction_async(
479483
f"/du_/api/framework/projects/{project_id}/{tag}/document-types/{document_type_id}/extraction/start"
480484
)
481485

482-
operation_id = self.request(
483-
"POST",
484-
url=url,
485-
params={"api-version": 1.1},
486-
headers=self._get_common_headers(),
487-
json={"documentId": document_id},
486+
operation_id = (
487+
await self.request_async(
488+
"POST",
489+
url=url,
490+
params={"api-version": 1.1},
491+
headers=self._get_common_headers(),
492+
json={"documentId": document_id},
493+
)
488494
).json()["operationId"]
489495

490496
return StartExtractionResponse(
@@ -506,13 +512,13 @@ def _wait_for_operation(
506512

507513
while (
508514
status in wait_statuses
509-
and (time.monotonic() - start_time) < POLLING_TIMEOUT
515+
and (time.monotonic() - start_time) < self.polling_timeout
510516
):
511517
status, error, result = result_getter()
512-
time.sleep(POLLING_INTERVAL)
518+
time.sleep(self.polling_interval)
513519

514520
if status != success_status:
515-
if time.monotonic() - start_time >= POLLING_TIMEOUT:
521+
if time.monotonic() - start_time >= self.polling_timeout:
516522
raise TimeoutError("Operation timed out.")
517523
raise RuntimeError(
518524
f"Operation failed with status: {status}, error: {error}"
@@ -534,13 +540,13 @@ async def _wait_for_operation_async(
534540

535541
while (
536542
status in wait_statuses
537-
and (time.monotonic() - start_time) < POLLING_TIMEOUT
543+
and (time.monotonic() - start_time) < self.polling_timeout
538544
):
539545
status, error, result = await result_getter()
540-
await asyncio.sleep(POLLING_INTERVAL)
546+
await asyncio.sleep(self.polling_interval)
541547

542548
if status != success_status:
543-
if time.monotonic() - start_time >= POLLING_TIMEOUT:
549+
if time.monotonic() - start_time >= self.polling_timeout:
544550
raise TimeoutError("Operation timed out.")
545551
raise RuntimeError(
546552
f"Operation failed with status: {status}, error: {error}"

tests/sdk/services/test_documents_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def service(
3030
return DocumentsService(
3131
config=config,
3232
execution_context=execution_context,
33+
polling_interval=0.001, # 1ms for fast tests
34+
polling_timeout=10, # 10 seconds for tests
3335
)
3436

3537

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)