Skip to content

Commit 1ebadba

Browse files
authored
Merge pull request #14 from UiPath/fix/mock_schame
fix: update uipath-runtime, dispose
2 parents 92c303a + 94e7085 commit 1ebadba

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath-dev"
3-
version = "0.0.4"
3+
version = "0.0.5"
44
description = "UiPath Developer Console"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-runtime>=0.0.11, <0.1.0",
8+
"uipath-runtime>=0.0.15, <0.1.0",
99
"textual>=6.6.0, <7.0.0",
1010
"pyperclip>=1.11.0, <2.0.0",
1111
]

src/uipath/dev/_demo/mock_runtime.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
class MockRuntimeFactory:
2727
"""Runtime factory compatible with UiPathRuntimeFactoryProtocol."""
2828

29-
async def new_runtime(self, entrypoint: str) -> UiPathRuntimeProtocol:
29+
async def new_runtime(
30+
self, entrypoint: str, runtime_id: str
31+
) -> UiPathRuntimeProtocol:
3032
"""Create a new runtime instance for the given entrypoint."""
3133
if entrypoint == ENTRYPOINT_GREETING:
3234
return MockGreetingRuntime(entrypoint=entrypoint)

src/uipath/dev/services/run_service.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ async def execute(self, run: ExecutionRun) -> None:
7777
7878
This is the extracted version of the old `_execute_runtime` method.
7979
"""
80+
new_runtime: UiPathRuntimeProtocol | None = None
8081
try:
8182
execution_input: dict[str, Any] | None = {}
8283
execution_options: UiPathExecuteOptions = UiPathExecuteOptions()
@@ -100,7 +101,8 @@ async def execute(self, run: ExecutionRun) -> None:
100101
)
101102

102103
new_runtime = await self.runtime_factory.new_runtime(
103-
entrypoint=run.entrypoint
104+
entrypoint=run.entrypoint,
105+
runtime_id=run.id,
104106
)
105107

106108
runtime: UiPathRuntimeProtocol
@@ -177,6 +179,9 @@ async def execute(self, run: ExecutionRun) -> None:
177179
title=str(e),
178180
detail=traceback.format_exc(),
179181
)
182+
finally:
183+
if new_runtime is not None:
184+
await new_runtime.dispose()
180185

181186
self.runs[run.id] = run
182187
self._emit_run_updated(run)

src/uipath/dev/ui/panels/new_run_panel.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from textual.containers import Container, Horizontal, Vertical
88
from textual.reactive import reactive
99
from textual.widgets import Button, Select, TabbedContent, TabPane, TextArea
10-
from uipath.runtime import UiPathRuntimeFactoryProtocol
10+
from uipath.runtime import UiPathRuntimeFactoryProtocol, UiPathRuntimeProtocol
1111

1212
from uipath.dev.ui.widgets.json_input import JsonInput
1313

@@ -182,18 +182,22 @@ async def _load_schema_and_update_input(self, entrypoint: str) -> None:
182182
schema = self.entrypoint_schemas.get(entrypoint)
183183

184184
if schema is None:
185+
runtime: UiPathRuntimeProtocol | None = None
185186
try:
186-
runtime = await self._runtime_factory.new_runtime(entrypoint)
187+
runtime = await self._runtime_factory.new_runtime(
188+
entrypoint, runtime_id="default"
189+
)
187190
schema_obj = await runtime.get_schema()
188191

189192
input_schema = schema_obj.input or {}
190193
self.entrypoint_schemas[entrypoint] = input_schema
191194
schema = input_schema
192-
193-
await runtime.dispose()
194195
except Exception:
195196
schema = {}
196197
self.entrypoint_schemas[entrypoint] = schema
198+
finally:
199+
if runtime is not None:
200+
await runtime.dispose()
197201

198202
json_input.text = json.dumps(
199203
mock_json_from_schema(schema),

uv.lock

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)