Skip to content

Commit a8a8970

Browse files
committed
docs: add SETUP.MD
1 parent 4233a02 commit a8a8970

1 file changed

Lines changed: 131 additions & 0 deletions

File tree

SETUP.MD

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# SETUP.MD
2+
3+
This file documents how to provision a clean development environment for `uipath-runtime`, run the build, execute the tests, and validate a sample code change end-to-end. It is intended both as a quick reference for human contributors and as a structured guide for automated environment-setup tooling.
4+
5+
## Prerequisites
6+
7+
- Python 3.11+
8+
- [uv](https://docs.astral.sh/uv/) 0.5+
9+
10+
### Supported platforms
11+
12+
`uv` is shell- and OS-agnostic, so the commands below run unchanged on every supported platform:
13+
14+
- [x] Linux
15+
- [x] Windows
16+
- [x] macOS
17+
18+
## Environment Variables
19+
20+
None required for environment setup, build, or unit tests. The suite under the `Test` section runs fully offline and requires no external authentication.
21+
22+
> **All commands below must be run from the repository root.** The `uv` invocations resolve `pyproject.toml`, `src/`, and `tests/` relative to the current working directory. The first line of `## Setup` enforces this by `cd`-ing to the git root.
23+
24+
## Setup
25+
26+
```bash
27+
cd "$(git rev-parse --show-toplevel)"
28+
python3 -m pip install --upgrade uv
29+
uv sync --all-extras
30+
```
31+
32+
## Verify Setup
33+
34+
```bash
35+
uv --version
36+
uv run python --version
37+
uv run python -c "import uipath.runtime; print('uipath_runtime ok')"
38+
```
39+
40+
## Build
41+
42+
N/A
43+
44+
## Test
45+
46+
```bash
47+
uv run pytest
48+
```
49+
50+
## Sample Code Change
51+
52+
### The change
53+
54+
Add a new `count` classmethod to `UiPathRuntimeFactoryRegistry` in `src/uipath/runtime/registry.py`, immediately after the existing `get_all` method:
55+
56+
```python
57+
@classmethod
58+
def count(cls) -> int:
59+
"""Return the number of currently registered factories."""
60+
return len(cls._factories)
61+
```
62+
63+
Then create `tests/test_registry_count.py` with two pytest tests:
64+
65+
```python
66+
"""Tests for UiPathRuntimeFactoryRegistry.count."""
67+
68+
from unittest.mock import MagicMock
69+
70+
from uipath.runtime.registry import UiPathRuntimeFactoryRegistry
71+
72+
73+
def _make_factory():
74+
"""Return a callable that yields a protocol-shaped mock.
75+
76+
The registry stores the callable in `_factories` without invoking it, so
77+
`count()` only needs the entry to exist. Returning a `MagicMock()` keeps
78+
the callable's return type structurally compatible with
79+
`UiPathRuntimeFactoryProtocol` without dragging the real type in.
80+
"""
81+
return lambda _context: MagicMock()
82+
83+
84+
def test_count_empty(monkeypatch) -> None:
85+
monkeypatch.setattr(UiPathRuntimeFactoryRegistry, "_factories", {})
86+
monkeypatch.setattr(UiPathRuntimeFactoryRegistry, "_registration_order", [])
87+
assert UiPathRuntimeFactoryRegistry.count() == 0
88+
89+
90+
def test_count_after_registrations(monkeypatch) -> None:
91+
monkeypatch.setattr(UiPathRuntimeFactoryRegistry, "_factories", {})
92+
monkeypatch.setattr(UiPathRuntimeFactoryRegistry, "_registration_order", [])
93+
UiPathRuntimeFactoryRegistry.register("alpha", _make_factory(), "a.json")
94+
UiPathRuntimeFactoryRegistry.register("beta", _make_factory(), "b.json")
95+
assert UiPathRuntimeFactoryRegistry.count() == 2
96+
```
97+
98+
### Verification
99+
100+
```bash
101+
uv run pytest tests/test_registry_count.py -v
102+
```
103+
104+
## Test with a real UiPath Coded Agent
105+
106+
> This section is for human contributors who want to validate changes end-to-end against the real cloud platform. It is **not executed by the Agentic Inner Loop validation pipeline** — that pipeline only runs the sections above (Setup → Verify → Build → Test → Sample Code Change).
107+
108+
The unit tests above are necessary but not sufficient — they don't exercise the package end-to-end through a real agent. The flow below validates changes against a live runtime:
109+
110+
1. Apply the code changes locally.
111+
2. Run the unit tests (see the `Sample Code Change` section above).
112+
3. Scaffold a coded UiPath agent that exercises the changed code path.
113+
4. In the downstream project's `pyproject.toml`, add this local library as an editable dependency:
114+
115+
```toml
116+
[tool.uv.sources]
117+
uipath-runtime = { path = "../path/to/uipath-runtime-python", editable = true }
118+
```
119+
120+
5. Exercise the new behavior end-to-end:
121+
122+
```bash
123+
uv run uipath run <agent-name> --input '{...}'
124+
```
125+
126+
6. (Optional) Open a PR and apply the `build:dev` label — this publishes the development version to Test PyPI.
127+
7. The PR description is updated automatically with instructions for pointing the downstream agent at the Test PyPI dev version.
128+
8. Validate the new behavior against the real platform — use either or both of the deploy targets below (Studio Web and Orchestrator are not mutually exclusive):
129+
- **Studio Web**: export the `UIPATH_PROJECT_ID` environment variable pointing to an existing Coded Agent project in your solution, then run [`uipath push`](https://uipath.github.io/uipath-python/cli/#push) to push the dev version to that project. Open it in Studio Web and exercise the changed code path.
130+
- **Orchestrator**: run [`uipath deploy`](https://uipath.github.io/uipath-python/cli/#deploy) to deploy the dev version as a package, then start a job in Orchestrator and exercise the changed code path.
131+
9. Once validation is done, close the dev PR — these PRs are not meant to be merged; their only purpose was to publish a Test PyPI build for end-to-end validation.

0 commit comments

Comments
 (0)