Skip to content
Merged
Changes from 1 commit
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
61 changes: 32 additions & 29 deletions packages/uipath/src/uipath/_cli/cli_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import uuid
from contextlib import AsyncExitStack
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -468,40 +469,42 @@ async def execute_eval():
)
)

runtime = await runtime_factory.new_runtime(
entrypoint=eval_context.entrypoint or "",
runtime_id=eval_context.execution_id,
settings=settings_override,
agent_memory_settings=agent_memory_settings_override,
)
# Resource overwrites must be in scope before any runtime is
# created: building the agent graph resolves folder-scoped
# resources (e.g. escalation memory spaces) at tool-creation
# time, and those lookups need the overwritten folder paths.
async with AsyncExitStack() as stack:
if project_id:
studio_client = StudioClient(project_id)

await stack.enter_async_context(
ResourceOverwritesContext(
lambda: studio_client.get_resource_overwrites()
)
)
else:
logger.debug(
"No UIPATH_PROJECT_ID configured, executing evaluation without resource overwrites"
)

eval_context.runtime_schema = await runtime.get_schema()
runtime = await runtime_factory.new_runtime(
entrypoint=eval_context.entrypoint or "",
runtime_id=eval_context.execution_id,
settings=settings_override,
agent_memory_settings=agent_memory_settings_override,
Comment on lines +500 to +504

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in e4fb14e — schema/evaluator loading is now wrapped in try/finally so runtime.dispose() runs even when get_schema() or load_evaluators() raises. Covered by test_runtime_disposed_when_schema_loading_fails.

)

eval_context.evaluators = await EvalHelpers.load_evaluators(
resolved_eval_set_path,
eval_context.evaluation_set,
get_agent_model(eval_context.runtime_schema),
)
eval_context.runtime_schema = await runtime.get_schema()

# Runtime is not required anymore.
await runtime.dispose()
eval_context.evaluators = await EvalHelpers.load_evaluators(
resolved_eval_set_path,
eval_context.evaluation_set,
get_agent_model(eval_context.runtime_schema),
)

if project_id:
studio_client = StudioClient(project_id)
# Runtime is not required anymore.
await runtime.dispose()

async with ResourceOverwritesContext(
lambda: studio_client.get_resource_overwrites()
):
ctx.result = await evaluate(
runtime_factory,
trace_manager,
eval_context,
event_bus,
)
else:
logger.debug(
"No UIPATH_PROJECT_ID configured, executing evaluation without resource overwrites"
)
ctx.result = await evaluate(
runtime_factory,
trace_manager,
Expand Down
Loading