Skip to content

Commit be3b050

Browse files
Update install instructions to use uv sync instead of pip (#169)
* chore(docs): replace pip install with uv sync instructions * refactor(Makefile): rewrite setup and checks to use uv * refactor: use uv in dockerfiles * chore: update readme * chore: install uv in Dockerfiles * refactor(ci): install uv in CI workflow * fix: update mypy version to >=1.17.1 in pyproject.toml and uv.lock * chore: update pytest ini_options * chore: update base image to python:3.13.5-slim in Dockerfiles * refactor: update Dockerfiles to use pre-built uv images * refactor(ci): simplify uv installation in CI workflow * fix: update command to run chatbot script in README * fix: use uv run in post_install script execution * chore: update dependencies for mcp functionality * fix: update type hint for ORFS_DIR environment variable to Optional[str] * fix: update graph type hint to use Optional * ruff: fix formatting * feat: use uv in all make targets --------- Signed-off-by: Palaniappan R <[email protected]>
1 parent 6046e2a commit be3b050

File tree

13 files changed

+2097
-2195
lines changed

13 files changed

+2097
-2195
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,29 @@ jobs:
2222
uses: actions/setup-python@v5
2323
with:
2424
python-version: '3.12'
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v6
28+
2529
- name: Checkout code
2630
uses: actions/checkout@v4
31+
2732
- name: Setup prereqs
2833
run: |
2934
make init-dev
35+
3036
- name: Run formatting checks
3137
run: |
3238
make check
39+
3340
- name: Run unit tests
3441
working-directory: backend
3542
run: |
36-
pip install huggingface_hub[cli]
43+
uv pip install huggingface_hub[cli]
3744
huggingface-cli download --repo-type dataset The-OpenROAD-Project/ORAssistant_RAG_Dataset --include source_list.json --local-dir data/
3845
export GOOGLE_API_KEY="dummy-unit-test-key"
3946
make test
47+
4048
- name: Build Docker images
4149
run: |
4250
docker compose build

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ The current architecture uses certain retrieval techniques on OpenROAD documenta
1515

1616
## Components
1717

18-
We have divided our app into three components, each of which can be hosted on a separate machine for scalability.
18+
We have divided our app into three components, each of which can be hosted on a separate machine for scalability.
19+
1920
- Backend: Generates the necessary chat endpoints for users to communicate with.
2021
- Frontend: We use Streamlit to communicate with a chat endpoint, providing a user-friendly chat interface.
2122
- Evaluation: Besides the vanilla chat interface, we also have a human evaluation interface for research and development.
2223

2324
## Setup
2425

25-
This setup involves the setting of both the frontend and backend components. We shall begin with backend:
26+
This setup involves the setting of both the frontend and backend components. We shall begin with backend:
2627

2728
### Backend Setup
2829

@@ -40,7 +41,7 @@ git clone https://github.com/The-OpenROAD-Project/ORAssistant.git
4041

4142
Modify the Docker `HEALTHCHECK_` variables based on the hardware requirements.
4243
If you have a resource-constrained PC, try increasing `HEALTHCHECK_START_PERIOD` to a value large
43-
enough before healthcheck begins.
44+
enough before healthcheck begins.
4445
For more information, please refer to this [link](https://docs.docker.com/reference/compose-file/services/#healthcheck)
4546

4647
```bash
@@ -57,16 +58,17 @@ make docker-down
5758

5859
#### Option 2 - Local Install
5960

60-
Prerequisites:
61-
- `Python 3.12`, recommended using a virtual environment like `conda`.
62-
- `wget`
63-
- `pandoc`
61+
### Prerequisites
62+
63+
- [`uv`](https://docs.astral.sh/uv/) (for managing Python, virtual environments, and dependencies)
64+
- `wget`
65+
- `pandoc`
6466
- `git`
6567

6668
**Step 1**: Install the required dependencies.
6769

68-
```bash
69-
pip install -r backend/requirements.txt
70+
```bash
71+
uv sync
7072
```
7173

7274
**Step 2**: Copy the `.env.example` file, and update your `.env` file with the appropriate API keys.
@@ -98,7 +100,7 @@ python main.py
98100
python chatbot.py
99101
```
100102

101-
The backend will then be hosted at [http://0.0.0.0:8000](http://0.0.0.0:8000).
103+
The backend will then be hosted at [http://0.0.0.0:8000](http://0.0.0.0:8000).
102104

103105
Open [http://0.0.0.0:8000/docs](http://0.0.0.0:8000/docs) for the API docs.
104106

@@ -127,7 +129,7 @@ streamlit run streamlit_app.py
127129

128130
## Architecture Overview
129131

130-
OpenROAD documentation, OpenROAD-flow-scripts documentation, manpages and OpenSTA documentation is chunked and embedded into FAISS Vector Databases.
132+
OpenROAD documentation, OpenROAD-flow-scripts documentation, manpages and OpenSTA documentation is chunked and embedded into FAISS Vector Databases.
131133

132134
Documents are first retrieved from the vectorstore using a hybrid retriever, combining vector and semantic search methods. These retrieved documents undergo re-ranking using a cross-encoder re-ranker model.
133135

@@ -145,9 +147,10 @@ flowchart LR
145147
146148
id5([Reranking]) ---> id6(top-n docs)
147149
148-
```
150+
```
149151

150152
Depending on the input query, each query can be forwarded to any one of the following retrievers,
153+
151154
1. General OR/ORFS information
152155
2. OR tools and commands
153156
3. OR/ORFS installation
@@ -195,7 +198,7 @@ make check
195198

196199
## Acknowledgements
197200

198-
This work is completed as part of the Google Summer of Code 2024 project under the
201+
This work is completed as part of the Google Summer of Code 2024 project under the
199202
[UCSC Open-Source Program Office](https://ucsc-ospo.github.io/osre24/).
200203
Please see their contributions at this [link](https://github.com/The-OpenROAD-Project/ORAssistant/wiki/Google-Summer-of-Code-2024).
201204

backend/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

backend/Dockerfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
1-
FROM python:3.12.3-slim
1+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
22

33
WORKDIR /ORAssistant-backend
44

5-
RUN apt-get update && apt-get install -y \
6-
pandoc git wget curl \
7-
git-lfs
5+
RUN apt-get update && apt-get install -y pandoc git wget curl git-lfs && git lfs install
86

9-
RUN git lfs install
7+
RUN pip install uv
108

11-
COPY ./requirements.txt /ORAssistant-backend/requirements.txt
12-
COPY ./requirements-test.txt /ORAssistant-backend/requirements-test.txt
139
COPY ./pyproject.toml /ORAssistant-backend/pyproject.toml
10+
COPY . .
1411

15-
RUN pip install --upgrade pip && \
16-
pip install --no-cache-dir -r requirements.txt && \
17-
pip install --no-cache-dir -r requirements-test.txt && \
18-
pip install --no-cache-dir -e .
12+
RUN uv venv .venv && uv sync --dev && uv run /ORAssistant-backend/src/post_install.py
1913

2014
RUN git clone https://huggingface.co/datasets/The-OpenROAD-Project/ORAssistant_RAG_Dataset && \
2115
mkdir -p data && \
2216
mv ORAssistant_RAG_Dataset/* data/ && \
2317
rm -rf ORAssistant_RAG_Dataset
2418

25-
COPY . .
26-
27-
RUN python /ORAssistant-backend/src/post_install.py
28-
2919
EXPOSE 8000
3020

31-
CMD ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
21+
CMD ["uv", "run", "uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

backend/Dockerfile_slim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12.3-slim
1+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
22

33
WORKDIR /ORAssistant-backend
44

@@ -7,20 +7,20 @@ RUN apt-get update && apt-get install -y \
77
git-lfs
88

99
RUN git lfs install
10+
RUN pip install uv
1011

11-
COPY ./requirements.txt /ORAssistant-backend/requirements.txt
12+
COPY ./pyproject.toml /ORAssistant-backend/pyproject.toml
13+
COPY . .
1214

13-
RUN pip install --upgrade -r /ORAssistant-backend/requirements.txt
15+
RUN uv venv .venv && \
16+
uv sync --dev && \
17+
uv run /ORAssistant-backend/src/post_install.py
1418

1519
RUN git clone https://huggingface.co/datasets/The-OpenROAD-Project/ORAssistant_RAG_Dataset && \
1620
mkdir -p data && \
1721
mv ORAssistant_RAG_Dataset/* data/ && \
1822
rm -rf ORAssistant_RAG_Dataset
1923

20-
COPY . .
21-
22-
RUN python /ORAssistant-backend/src/post_install.py
23-
2424
EXPOSE 8000
2525

26-
CMD ["uvicorn", "src.api.dummy:app", "--host", "0.0.0.0", "--port", "8000"]
26+
CMD ["uv", "run", "uvicorn", "src.api.dummy:app", "--host", "0.0.0.0", "--port", "8000"]

backend/Makefile

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,35 @@
11
.PHONY: init
22
init:
3-
@python3 -m venv .venv && \
4-
. .venv/bin/activate && \
5-
pip install -r requirements.txt && \
6-
pip install -e .
3+
@uv venv .venv && \
4+
uv sync
75

86
.PHONY: init-dev
9-
init-dev: init
10-
@. .venv/bin/activate && \
11-
pip install -r requirements-test.txt
7+
init-dev:
8+
@uv venv .venv && \
9+
uv sync --dev
1210

1311
.PHONY: format
1412
format:
15-
@. .venv/bin/activate && \
16-
ruff format && \
17-
ruff check --fix
13+
@uv run ruff format && \
14+
uv run ruff check --fix
1815

1916
.PHONY: check
2017
check:
21-
@. .venv/bin/activate && \
22-
mypy . && \
23-
ruff check
18+
@uv run mypy . && \
19+
uv run ruff check
2420

2521
.PHONY: build-docs
2622
build-docs:
27-
@. .venv/bin/activate && \
28-
python build_docs.py
23+
@uv run python build_docs.py
2924

3025
.PHONY: test
3126
test:
32-
@. .venv/bin/activate && \
33-
pytest
27+
@uv run pytest
3428

35-
# For MCP Development
3629
.PHONY: mcp
3730
mcp:
38-
@. .venv/bin/activate && \
39-
python -m src.openroad_mcp.server.orfs.orfs_server
31+
@uv run python -m src.openroad_mcp.server.orfs.orfs_server
4032

4133
.PHONY: chat
4234
chat:
43-
@. .venv/bin/activate && \
44-
python -m chatbot
35+
@uv run python -m chatbot

backend/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,19 @@ Provide the value for `HF_TOKEN` with the token that is generated
113113
114114
## Running the Application
115115
116+
To use that chatbot in a text-based in your terminal, use the `chatbot.py` script:
117+
```python
118+
uv run chatbot.py
119+
```
120+
116121
### Install Required Packages
117122
118-
Ensure you have the necessary dependencies installed by running:
123+
Install dependencies defined in `pyproject.toml` with:
119124
120125
```bash
121-
pip install -r requirements.txt
126+
uv sync
122127
```
128+
123129
### Docker Command
124130
125131
If you want to run an isolated container for backend, you can use the following command

0 commit comments

Comments
 (0)