Skip to content

Commit 828ceae

Browse files
committed
docs: update documentation for uv package management
Update developer documentation to use uv as primary package manager: - Add uv installation instructions to for-developers.md - Update REPO-GUIDELINES.md with uv sync/run commands - Add uv run prefixes to tool commands in tools.md
1 parent 917b0a7 commit 828ceae

3 files changed

Lines changed: 75 additions & 54 deletions

File tree

claude-code/smartem-decisions/REPO-GUIDELINES.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Development Environment
44
- **Python Version**: 3.12+ (strict requirement - utilize modern typing features)
5-
- **venv**: Use `source .venv/bin/activate` for tools such as pip, ruff or tox
6-
- **Package Management**: Use `pip install -e .[all]` for full development setup
5+
- **Package Manager**: uv (https://docs.astral.sh/uv/)
6+
- **Package Management**: Use `uv sync --extra all` for full development setup
77
- **Code Style**: Ruff (120 char line length) with pyright type checking
88

99
## Code Standards
@@ -41,17 +41,17 @@ This applies to ALL files: Python code, Markdown documentation, configuration fi
4141
## Common Commands
4242
```bash
4343
# Development setup
44-
pip install -e .[all]
44+
uv sync --extra all
4545

4646
# Testing
47-
pytest
47+
uv run pytest
4848

49-
# Type checking
50-
pyright src tests
49+
# Type checking
50+
uv run pyright src tests
5151

5252
# Linting and formatting
53-
ruff check
54-
ruff format
53+
uv run ruff check
54+
uv run ruff format
5555

5656
# Pre-commit checks
5757
pre-commit run --all-files
@@ -60,8 +60,8 @@ pre-commit run --all-files
6060
cd ../smartem-devtools/webui && npm run dev
6161

6262
# Database migrations
63-
python -m alembic upgrade head
64-
python -m alembic revision --autogenerate -m "Description"
63+
uv run alembic upgrade head
64+
uv run alembic revision --autogenerate -m "Description"
6565
```
6666

6767
## Project Architecture
@@ -88,7 +88,6 @@ python -m alembic revision --autogenerate -m "Description"
8888
## Testing & Quality
8989
- **Coverage**: Tests run with coverage reporting
9090
- **Doctests**: Documentation examples are executable
91-
- **Multiple environments**: tox for cross-environment testing
9291
- **CI/CD**: GitHub Actions with pre-commit hooks
9392

9493
## Documentation

docs/development/tools.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ Transform single-line XML and .dm files into human-readable format with proper i
1010

1111
```bash
1212
# Reformat all .xml and .dm files in a directory recursively
13-
python tools/format_xml.py <directory_path> -r
13+
uv run python tools/format_xml.py <directory_path> -r
1414

1515
# Process multiple directories
16-
python tools/format_xml.py -r \
16+
uv run python tools/format_xml.py -r \
1717
../smartem-decisions-test-datasets/metadata_Supervisor_20250114_220855_23_epuBSAd20_GrOxDDM \
1818
../smartem-decisions-test-datasets/metadata_Supervisor_20241220_140307_72_et2_gangshun \
1919
../smartem-decisions-test-datasets/metadata_Supervisor_20250108_101446_62_cm40593-1_EPU
2020

2121
# Display all available options
22-
python tools/format_xml.py --help
22+
uv run python tools/format_xml.py --help
2323
```
2424

2525
## Data Analysis and Debugging Tools
@@ -30,10 +30,10 @@ Identify duplicate foil hole manifests within directory structures to detect dat
3030

3131
```bash
3232
# Display help and usage information
33-
tools/find_foilhole_duplicates.py --help
33+
uv run tools/find_foilhole_duplicates.py --help
3434

3535
# Example: Search for duplicates in test data
36-
tools/find_foilhole_duplicates.py ./tests/testdata/bi37708-28
36+
uv run tools/find_foilhole_duplicates.py ./tests/testdata/bi37708-28
3737
```
3838

3939
### File Size Analysis
@@ -94,21 +94,21 @@ Comprehensive CLI tool for simulating external data processing messages that wou
9494

9595
```bash
9696
# List all available message types
97-
python tools/external_message_simulator.py list-messages
97+
uv run python tools/external_message_simulator.py list-messages
9898

9999
# Individual message simulation examples
100-
python tools/external_message_simulator.py motion-correction --foilhole-id "FH_001_001_001" --quality-score 0.85
101-
python tools/external_message_simulator.py ctf-complete --foilhole-id "FH_001_001_001" --resolution 3.2
102-
python tools/external_message_simulator.py gridsquare-prediction --gridsquare-id "GS_001_001" --prediction-score 0.85
103-
python tools/external_message_simulator.py model-update --model-name "ResNet-50"
100+
uv run python tools/external_message_simulator.py motion-correction --foilhole-id "FH_001_001_001" --quality-score 0.85
101+
uv run python tools/external_message_simulator.py ctf-complete --foilhole-id "FH_001_001_001" --resolution 3.2
102+
uv run python tools/external_message_simulator.py gridsquare-prediction --gridsquare-id "GS_001_001" --prediction-score 0.85
103+
uv run python tools/external_message_simulator.py model-update --model-name "ResNet-50"
104104

105105
# Complete workflow simulation for a single grid square
106-
python tools/external_message_simulator.py workflow-simulation --gridsquare-id "DEV_001"
106+
uv run python tools/external_message_simulator.py workflow-simulation --gridsquare-id "DEV_001"
107107

108108
# Batch simulation with different quality scenarios
109-
python tools/external_message_simulator.py batch-simulation --gridsquare-count 5 --scenario mixed
110-
python tools/external_message_simulator.py batch-simulation --gridsquare-count 3 --scenario good
111-
python tools/external_message_simulator.py batch-simulation --gridsquare-count 2 --scenario poor
109+
uv run python tools/external_message_simulator.py batch-simulation --gridsquare-count 5 --scenario mixed
110+
uv run python tools/external_message_simulator.py batch-simulation --gridsquare-count 3 --scenario good
111+
uv run python tools/external_message_simulator.py batch-simulation --gridsquare-count 2 --scenario poor
112112
```
113113

114114
**Available Message Types:**
@@ -126,7 +126,7 @@ Example client for testing agent-backend communication via Server-Sent Events:
126126

127127
```bash
128128
# Start the SSE client to receive instructions from backend
129-
python tools/sse_client_example.py
129+
uv run python tools/sse_client_example.py
130130

131131
# The client will:
132132
# 1. Auto-create a new session with the backend
@@ -161,12 +161,12 @@ pre-commit run --all-files
161161

162162
```bash
163163
# Run comprehensive test suite
164-
pytest
164+
uv run pytest
165165

166166
# Type checking with pyright
167-
pyright src tests
167+
uv run pyright src tests
168168

169169
# Code formatting and linting
170-
ruff check
171-
ruff format
170+
uv run ruff check
171+
uv run ruff format
172172
```

docs/getting-started/for-developers.md

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,75 @@ python3 --version
1010

1111
**Note:** The project specifically requires Python 3.12+ to utilise advanced typing features and maintain compatibility with the latest scientific computing libraries.
1212

13-
## Create a Virtual Environment
13+
## Install uv (Recommended)
1414

15-
It is strongly recommended that you install SmartEM Decisions within a virtual environment to prevent conflicts with existing Python installations and maintain a clean development environment:
15+
We recommend using [uv](https://docs.astral.sh/uv/) for Python package management. uv is a fast Python package manager that handles virtual environments and dependencies efficiently.
16+
17+
### Install uv
1618

1719
```bash
18-
python3 -m venv /path/to/venv
19-
source /path/to/venv/bin/activate
20+
# On macOS and Linux
21+
curl -LsSf https://astral.sh/uv/install.sh | sh
22+
23+
# Or with pip
24+
pip install uv
25+
26+
# Or with Homebrew (macOS)
27+
brew install uv
2028
```
2129

22-
For development work, consider creating the virtual environment within the project directory:
30+
## Installing the Library
31+
32+
### Development Installation (Recommended)
33+
34+
For development work, clone the repository and install using uv:
2335

2436
```bash
25-
python3 -m venv .venv
26-
source .venv/bin/activate
37+
# Clone the repository
38+
git clone https://github.com/DiamondLightSource/smartem-decisions.git
39+
cd smartem-decisions
40+
41+
# Install all dependencies (creates virtual environment automatically)
42+
uv sync --extra all
2743
```
2844

29-
## Installing the Library
45+
This will create a `.venv` directory and install all dependencies including development tools.
3046

31-
### Standard Installation
47+
### Running Commands
3248

33-
You can install the library and its core dependencies using `pip`:
49+
With uv, prefix commands with `uv run` to execute them in the virtual environment:
3450

3551
```bash
36-
python3 -m pip install smartem-decisions
52+
# Run tests
53+
uv run pytest
54+
55+
# Type checking
56+
uv run pyright src tests
57+
58+
# Linting
59+
uv run ruff check
3760
```
3861

39-
### Development Installation
62+
### Standard Installation (pip)
4063

41-
For development work or if you require the latest features, install directly from the source repository:
64+
You can also install the library using pip:
4265

4366
```bash
44-
# Clone and install in development mode
45-
git clone https://github.com/DiamondLightSource/smartem-decisions.git
46-
cd smartem-decisions
47-
pip install -e .[all]
67+
python3 -m pip install smartem-decisions
4868
```
4969

5070
### Installation with Optional Dependencies
5171

5272
Install with specific feature sets:
5373

5474
```bash
55-
# Install with MCP (Model Context Protocol) support
56-
pip install -e .[mcp]
75+
# Using uv (recommended)
76+
uv sync --extra mcp # Install with MCP support
77+
uv sync --extra all # Install with all dependencies
5778

58-
# Install with all optional dependencies (recommended for development)
59-
pip install -e .[all]
79+
# Using pip
80+
pip install -e .[mcp] # Install with MCP support
81+
pip install -e .[all] # Install with all dependencies
6082
```
6183

6284
## Verify Installation
@@ -65,17 +87,17 @@ Verify that all components are correctly installed by running:
6587

6688
```bash
6789
# Test core functionality
68-
python -c "import smartem_backend, smartem_agent, smartem_common; print('Core components imported successfully')"
90+
uv run python -c "import smartem_backend, smartem_agent, smartem_common; print('Core components imported successfully')"
6991

7092
# Test MCP functionality (if installed with MCP support)
71-
python -c "import smartem_mcp; print('MCP components available')"
93+
uv run python -c "import smartem_mcp; print('MCP components available')"
7294
```
7395

7496
You can also verify the CLI tools are available:
7597

7698
```bash
7799
# Check agent CLI is accessible
78-
python -m smartem_agent --help
100+
uv run python -m smartem_agent --help
79101
```
80102

81103
## Next Steps

0 commit comments

Comments
 (0)