Skip to content
Closed
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
17 changes: 15 additions & 2 deletions src/uipath/platform/resume_triggers/_protocol.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Implementation of UiPath resume trigger protocols."""

import json
import os
import uuid
from typing import Any

Expand Down Expand Up @@ -301,7 +300,21 @@ async def read_trigger(self, trigger: UiPathResumeTrigger) -> Any | None:
f"{e.message}",
) from e

return f"Batch transform completed. Modified file available at {os.path.abspath(destination_path)}"
# Upload result as job attachment (automatically links to job if available)
result_attachment_id = await uipath.jobs.create_attachment_async(
name=destination_path,
source_path=destination_path,
job_key=UiPathConfig.job_key,
)

mime_type = "text/csv"

# Return attachment info
return {
"ID": str(result_attachment_id),
"FullName": destination_path,
"MimeType": mime_type,
}

case UiPathResumeTriggerType.IXP_EXTRACTION:
if trigger.item_key:
Expand Down
35 changes: 25 additions & 10 deletions tests/cli/test_hitl.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,22 @@ async def test_read_batch_rag_trigger_successful(
setup_test_env: None,
) -> None:
"""Test reading a successful batch rag trigger."""
import os

task_id = "test-batch-rag-id"
destination_path = "test/output.xlsx"
mock_download_async = AsyncMock(return_value=None)
attachment_id = "test-attachment-id"

with patch(
"uipath.platform.context_grounding._context_grounding_service.ContextGroundingService.download_batch_transform_result_async",
new=mock_download_async,
mock_download_async = AsyncMock(return_value=None)
mock_create_attachment_async = AsyncMock(return_value=attachment_id)

with (
patch(
"uipath.platform.context_grounding._context_grounding_service.ContextGroundingService.download_batch_transform_result_async",
new=mock_download_async,
),
patch(
"uipath.platform.orchestrator._jobs_service.JobsService.create_attachment_async",
new=mock_create_attachment_async,
),
):
resume_trigger = UiPathResumeTrigger(
trigger_type=UiPathResumeTriggerType.BATCH_RAG,
Expand All @@ -542,16 +549,24 @@ async def test_read_batch_rag_trigger_successful(
)
reader = UiPathResumeTriggerReader()
result = await reader.read_trigger(resume_trigger)
assert (
result
== f"Batch transform completed. Modified file available at {os.path.abspath(destination_path)}"
)

# Verify the result is a dictionary with attachment information
assert isinstance(result, dict)
assert result["ID"] == attachment_id
assert result["FullName"] == destination_path
assert result["MimeType"] == "text/csv"

mock_download_async.assert_called_once_with(
task_id,
destination_path,
validate_status=True,
index_name="test-index",
)
mock_create_attachment_async.assert_called_once_with(
name=destination_path,
source_path=destination_path,
job_key=None,
)

@pytest.mark.anyio
async def test_read_batch_rag_trigger_pending(
Expand Down