Skip to content
Open
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 packages/uipath-platform/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-platform"
version = "0.1.29"
version = "0.1.30"
description = "HTTP client library for programmatic access to UiPath Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ORCHESTRATOR_STORAGE_BUCKET_DATA_SOURCE,
)
from ..errors import (
BatchTransformFailedException,
BatchTransformNotCompleteException,
IngestionInProgressException,
UnsupportedDataSourceException,
Expand Down Expand Up @@ -1032,6 +1033,11 @@ def download_batch_transform_result(
batch_transform = self.retrieve_batch_transform(
id=id, index_name=index_name
)
if batch_transform.last_batch_rag_status == BatchTransformStatus.FAILED:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the same logic apply to DeepRAG?

raise BatchTransformFailedException(
batch_transform_id=id,
status=batch_transform.last_batch_rag_status,
)
if batch_transform.last_batch_rag_status != BatchTransformStatus.SUCCESSFUL:
raise BatchTransformNotCompleteException(
batch_transform_id=id,
Expand Down Expand Up @@ -1091,6 +1097,11 @@ async def download_batch_transform_result_async(
batch_transform = await self.retrieve_batch_transform_async(
id=id, index_name=index_name
)
if batch_transform.last_batch_rag_status == BatchTransformStatus.FAILED:
raise BatchTransformFailedException(
batch_transform_id=id,
status=batch_transform.last_batch_rag_status,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the status redundant?

)
if batch_transform.last_batch_rag_status != BatchTransformStatus.SUCCESSFUL:
raise BatchTransformNotCompleteException(
batch_transform_id=id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
- FolderNotFoundException: Raised when a folder cannot be found
- UnsupportedDataSourceException: Raised when an operation is attempted on an unsupported data source type
- IngestionInProgressException: Raised when a search is attempted on an index during ingestion
- BatchTransformFailedException: Raised when a batch transform has failed
- BatchTransformNotCompleteException: Raised when attempting to get results from an incomplete batch transform
- OperationNotCompleteException: Raised when attempting to get results from an incomplete operation
- OperationFailedException: Raised when an operation has failed
- EnrichedException: Enriched HTTP error with detailed request/response information
"""

from ._base_url_missing_error import BaseUrlMissingError
from ._batch_transform_failed_exception import BatchTransformFailedException
from ._batch_transform_not_complete_exception import BatchTransformNotCompleteException
from ._enriched_exception import EnrichedException, ExtractedErrorInfo
from ._folder_not_found_exception import FolderNotFoundException
Expand All @@ -26,6 +28,7 @@

__all__ = [
"BaseUrlMissingError",
"BatchTransformFailedException",
"BatchTransformNotCompleteException",
"EnrichedException",
"ExtractedErrorInfo",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class BatchTransformFailedException(Exception):
"""Raised when a batch transform has failed.

This exception is raised when a batch transform task has completed
with a failed status, as opposed to still being in progress.
"""

def __init__(self, batch_transform_id: str, status: str):
self.message = (
f"Batch transform '{batch_transform_id}' failed. Status: {status}"
)
super().__init__(self.message)
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
ContextGroundingIndex,
)
from uipath.platform.errors import (
BatchTransformFailedException,
BatchTransformNotCompleteException,
OperationNotCompleteException,
)
Expand Down Expand Up @@ -323,6 +324,11 @@ async def read_trigger(self, trigger: UiPathResumeTrigger) -> Any | None:
"index_name", trigger.payload
),
)
except BatchTransformFailedException as e:
raise UiPathFaultedTriggerError(
ErrorCategory.USER,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a user error? can't it be marked as failed due to other conditions in ecs?

in ecs we have:

try {
// do various async things
} catch (Exception ex)
            {
                ex = ex.Unwrap();

                if (info != null)
                {
                    var errorMessage = (ex as LocalizedException)?.Message
                                       ?? ErrorMessages.BatchRag_InternalFailure;
                    await Workflow.ExecuteLocalActivityAsync(
                        (IBatchRagReportingActivities a) => a.ReportFailureAsync(batchRagId, errorMessage),
                        new LocalActivityOptions
                        {
                            StartToCloseTimeout = TimeSpan.FromMinutes(1),
                            RetryPolicy = new RetryPolicy { MaximumAttempts = 3 }
                        });
                }
            }

f"{e.message}",
) from e
except BatchTransformNotCompleteException as e:
raise UiPathPendingTriggerError(
ErrorCategory.SYSTEM,
Expand Down
35 changes: 35 additions & 0 deletions packages/uipath-platform/tests/services/test_hitl.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,41 @@ async def test_read_batch_rag_trigger_pending(
reader = UiPathResumeTriggerReader()
await reader.read_trigger(resume_trigger)

@pytest.mark.anyio
async def test_read_batch_rag_trigger_failed(
self,
setup_test_env: None,
) -> None:
"""Test reading a failed batch rag trigger raises faulted error."""
from uipath.core.errors import UiPathFaultedTriggerError

from uipath.platform.errors import BatchTransformFailedException

task_id = "test-batch-rag-id"
destination_path = "test/output.xlsx"
mock_download_async = AsyncMock(
side_effect=BatchTransformFailedException(task_id, "Failed")
)

with patch(
"uipath.platform.context_grounding._context_grounding_service.ContextGroundingService.download_batch_transform_result_async",
new=mock_download_async,
):
resume_trigger = UiPathResumeTrigger(
trigger_type=UiPathResumeTriggerType.BATCH_RAG,
item_key=task_id,
folder_key="test-folder",
folder_path="test-path",
payload={
"index_name": "test-index",
"destination_path": destination_path,
},
)

with pytest.raises(UiPathFaultedTriggerError):
reader = UiPathResumeTriggerReader()
await reader.read_trigger(resume_trigger)

@pytest.mark.anyio
async def test_read_ephemeral_index_trigger_successful(
self,
Expand Down
2 changes: 1 addition & 1 deletion packages/uipath-platform/uv.lock

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

Loading