|
| 1 | +# SETUP.md |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +- Python 3.11+ |
| 6 | +- [uv](https://docs.astral.sh/uv/) 0.5+ |
| 7 | + |
| 8 | +### Supported platforms |
| 9 | + |
| 10 | +- [x] Linux |
| 11 | +- [ ] Windows |
| 12 | +- [ ] macOS |
| 13 | + |
| 14 | +## Environment Variables |
| 15 | + |
| 16 | +### Standard (injected by pipeline) |
| 17 | + |
| 18 | +None of the standard pipeline variables are required for environment setup, build, or unit tests. |
| 19 | + |
| 20 | +### Project-specific |
| 21 | + |
| 22 | +| Variable | Description | How to obtain | |
| 23 | +|----------|-------------|---------------| |
| 24 | +| `UIPATH_URL` | UiPath platform base URL — required only for E2E tests, which are excluded from the default test run | Set to your tenant URL (e.g. `https://cloud.uipath.com/myorg/mytenant`) | |
| 25 | +| `UIPATH_ACCESS_TOKEN` | Bearer token — required only for E2E tests | Generate from UiPath Cloud Platform | |
| 26 | + |
| 27 | +## Setup |
| 28 | + |
| 29 | +```bash |
| 30 | +# Install uv if not present |
| 31 | +curl -LsSf https://astral.sh/uv/install.sh | sh |
| 32 | +export PATH="$HOME/.local/bin:$PATH" |
| 33 | + |
| 34 | +# Sync all three packages with dev dependencies (dependency order: core → platform → main) |
| 35 | +uv --directory packages/uipath-core sync --all-extras |
| 36 | +uv --directory packages/uipath-platform sync --all-extras |
| 37 | +uv --directory packages/uipath sync --all-extras |
| 38 | +``` |
| 39 | + |
| 40 | +## Verify Setup |
| 41 | + |
| 42 | +```bash |
| 43 | +python3 --version |
| 44 | +uv --version |
| 45 | +uv --directory packages/uipath-core run python -c "import uipath.core; print('uipath-core ok')" |
| 46 | +uv --directory packages/uipath-platform run python -c "import uipath.platform; print('uipath-platform ok')" |
| 47 | +uv --directory packages/uipath run python -c "import uipath; print('uipath ok')" |
| 48 | +``` |
| 49 | + |
| 50 | +## Build |
| 51 | + |
| 52 | +```bash |
| 53 | +uv --directory packages/uipath-core build |
| 54 | +uv --directory packages/uipath-platform build |
| 55 | +uv --directory packages/uipath build |
| 56 | +``` |
| 57 | + |
| 58 | +## Test |
| 59 | + |
| 60 | +```bash |
| 61 | +uv --directory packages/uipath-core run pytest -m "not e2e" |
| 62 | +uv --directory packages/uipath-platform run pytest -m "not e2e" |
| 63 | +uv --directory packages/uipath run pytest -m "not e2e" |
| 64 | +``` |
| 65 | + |
| 66 | +## Sample Code Change |
| 67 | + |
| 68 | +### The change |
| 69 | + |
| 70 | +Add a new `size` property to `SpanRegistry` in `packages/uipath-core/src/uipath/core/tracing/span_utils.py`, immediately after the `clear` method (around line 130) and before the `# Global span registry instance` comment: |
| 71 | + |
| 72 | +```python |
| 73 | +@property |
| 74 | +def size(self) -> int: |
| 75 | + """Return the number of currently registered spans.""" |
| 76 | + return len(self._spans) |
| 77 | +``` |
| 78 | + |
| 79 | +Then create `packages/uipath-core/tests/tracing/test_span_registry_size.py` with two pytest tests: |
| 80 | + |
| 81 | +```python |
| 82 | +from unittest.mock import MagicMock |
| 83 | + |
| 84 | +from uipath.core.tracing.span_utils import SpanRegistry |
| 85 | + |
| 86 | + |
| 87 | +def _make_span(span_id: int) -> MagicMock: |
| 88 | + span = MagicMock() |
| 89 | + span.get_span_context.return_value.span_id = span_id |
| 90 | + del span.parent # ensure hasattr(span, "parent") is False |
| 91 | + return span |
| 92 | + |
| 93 | + |
| 94 | +def test_size_empty_registry() -> None: |
| 95 | + registry = SpanRegistry() |
| 96 | + assert registry.size == 0 |
| 97 | + |
| 98 | + |
| 99 | +def test_size_after_registrations() -> None: |
| 100 | + registry = SpanRegistry() |
| 101 | + registry.register_span(_make_span(1)) |
| 102 | + registry.register_span(_make_span(2)) |
| 103 | + assert registry.size == 2 |
| 104 | +``` |
| 105 | + |
| 106 | +### Verification |
| 107 | + |
| 108 | +```bash |
| 109 | +uv --directory packages/uipath-core run pytest tests/tracing/test_span_registry_size.py -v |
| 110 | +``` |
0 commit comments