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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath"
version = "2.3.1"
version = "2.3.2"
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
30 changes: 18 additions & 12 deletions src/uipath/platform/documents/_documents_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ def __init__(
self,
config: UiPathApiConfig,
execution_context: UiPathExecutionContext,
polling_interval: float = POLLING_INTERVAL,
polling_timeout: float = POLLING_TIMEOUT,
) -> None:
super().__init__(config=config, execution_context=execution_context)
self.polling_interval = polling_interval
self.polling_timeout = polling_timeout

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

operation_id = self.request(
"POST",
url=url,
params={"api-version": 1.1},
headers=self._get_common_headers(),
json={"documentId": document_id},
operation_id = (
await self.request_async(
"POST",
url=url,
params={"api-version": 1.1},
headers=self._get_common_headers(),
json={"documentId": document_id},
)
).json()["operationId"]

return StartExtractionResponse(
Expand All @@ -506,13 +512,13 @@ def _wait_for_operation(

while (
status in wait_statuses
and (time.monotonic() - start_time) < POLLING_TIMEOUT
and (time.monotonic() - start_time) < self.polling_timeout
):
status, error, result = result_getter()
time.sleep(POLLING_INTERVAL)
time.sleep(self.polling_interval)

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

while (
status in wait_statuses
and (time.monotonic() - start_time) < POLLING_TIMEOUT
and (time.monotonic() - start_time) < self.polling_timeout
):
status, error, result = await result_getter()
await asyncio.sleep(POLLING_INTERVAL)
await asyncio.sleep(self.polling_interval)

if status != success_status:
if time.monotonic() - start_time >= POLLING_TIMEOUT:
if time.monotonic() - start_time >= self.polling_timeout:
raise TimeoutError("Operation timed out.")
raise RuntimeError(
f"Operation failed with status: {status}, error: {error}"
Expand Down
2 changes: 2 additions & 0 deletions tests/sdk/services/test_documents_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def service(
return DocumentsService(
config=config,
execution_context=execution_context,
polling_interval=0.001, # 1ms for fast tests
polling_timeout=10, # 10 seconds for tests
)


Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.