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
4 changes: 2 additions & 2 deletions packages/uipath/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[project]
name = "uipath"
version = "2.15.12"
version = "2.15.13"
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"
dependencies = [
"uipath-core>=0.5.35, <0.6.0",
"uipath-runtime>=0.13.5, <0.14.0",
"uipath-runtime>=0.13.7, <0.14.0",
"uipath-platform>=0.3.15, <0.4.0",
"uipath-ipc>=2.5.1, <2.6.0",
"click>=8.3.3, <9.0.0",
Expand Down
9 changes: 3 additions & 6 deletions packages/uipath/src/uipath/_cli/_execution_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import asyncio
import concurrent.futures
import contextvars
import importlib
import threading
from typing import Any

Expand Down Expand Up @@ -120,8 +119,6 @@ def run_execution_loop(coro: Any) -> Any:

def _report_stops_as_stopped(control: ExecutionControl) -> None:
"""Let the runtime tell a cancellation this control delivered from a failure."""
try:
stop = importlib.import_module("uipath.runtime.stop")
except ImportError: # uipath-runtime before 0.13.6 reports a stop as a fault
return
stop.set_stop_requested_probe(lambda: control.delivered)
from uipath.runtime.stop import set_stop_requested_probe

set_stop_requested_probe(lambda: control.delivered)
45 changes: 8 additions & 37 deletions packages/uipath/tests/cli/test_execution_control.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
"""What an execution's loop tells the runtime about the stops it delivers."""

import asyncio
import contextvars
import sys
import types
from typing import Any

import pytest

from uipath._cli._execution_control import (
CURRENT_EXECUTION_CONTROL,
ExecutionControl,
run_execution_loop,
)
from uipath.runtime.stop import get_stop_requested_probe


def _run_controlled(control: ExecutionControl, coro: Any) -> Any:
Expand All @@ -23,22 +19,12 @@ def _run_controlled(control: ExecutionControl, coro: Any) -> Any:
CURRENT_EXECUTION_CONTROL.reset(token)


@pytest.fixture
def stop_module(monkeypatch: pytest.MonkeyPatch) -> contextvars.ContextVar[Any]:
probe: contextvars.ContextVar[Any] = contextvars.ContextVar("probe", default=None)
module = types.ModuleType("uipath.runtime.stop")
module.set_stop_requested_probe = probe.set # type: ignore[attr-defined]
monkeypatch.setitem(sys.modules, "uipath.runtime.stop", module)
return probe


def test_the_runtime_learns_a_stop_reached_the_execution(
stop_module: contextvars.ContextVar[Any],
) -> None:
def test_the_runtime_learns_a_stop_reached_the_execution() -> None:
control = ExecutionControl()

async def body() -> tuple[bool, bool]:
probe = stop_module.get()
probe = get_stop_requested_probe()
assert probe is not None
before = probe()
control.cancel()
try:
Expand Down Expand Up @@ -66,32 +52,17 @@ def test_a_stop_that_reaches_a_finished_execution_is_not_delivered() -> None:
assert control.delivered is False


def test_the_probe_stays_inside_the_execution(
stop_module: contextvars.ContextVar[Any],
) -> None:
def test_the_probe_stays_inside_the_execution() -> None:
async def body() -> None:
return None

_run_controlled(ExecutionControl(), body())

assert stop_module.get() is None
assert get_stop_requested_probe() is None


def test_an_uncontrolled_run_installs_no_probe(
stop_module: contextvars.ContextVar[Any],
) -> None:
def test_an_uncontrolled_run_installs_no_probe() -> None:
async def body() -> Any:
return stop_module.get()
return get_stop_requested_probe()

assert run_execution_loop(body()) is None


def test_a_runtime_without_the_probe_still_runs(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setitem(sys.modules, "uipath.runtime.stop", None)

async def body() -> str:
return "ran"

assert _run_controlled(ExecutionControl(), body()) == "ran"
12 changes: 6 additions & 6 deletions packages/uipath/uv.lock

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

Loading