Skip to content

Commit 592c9af

Browse files
[Enhancement] Migrate project environment & packaging from Poetry to uv (#71)
* feat: Migrate project environment & packaging from Poetry to uv * Updated style of SyGra docs --------- Co-authored-by: Vipul Mittal <[email protected]>
1 parent d72998a commit 592c9af

File tree

23 files changed

+6169
-344
lines changed

23 files changed

+6169
-344
lines changed

.github/dependabot.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
updates:
3+
# Keep GitHub Actions up to date
4+
- package-ecosystem: github-actions
5+
directory: "/"
6+
schedule:
7+
interval: weekly
8+
open-pull-requests-limit: 10
9+
labels:
10+
- dependencies
11+
12+
# Update UV-managed Python deps
13+
- package-ecosystem: uv
14+
directory: "/"
15+
schedule:
16+
interval: weekly
17+
open-pull-requests-limit: 10
18+
labels:
19+
- dependencies
20+
commit-message:
21+
prefix: "deps"
22+
include: scope

.github/workflows/ci.yml

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,68 @@ permissions:
1212
pages: write
1313
id-token: write
1414

15-
env:
16-
POETRY_CACHE_DIR: /tmp/poetry_cache
17-
1815
jobs:
1916

2017
build:
2118
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
2219
runs-on: ubuntu-latest
20+
env:
21+
UV_PROJECT_ENVIRONMENT: .venv
2322

2423
steps:
25-
# ---- Cleanup runner disk ----
24+
# ---- Disk Cleanup (Safe) ----
2625
- name: Free disk space
2726
run: |
2827
df -h
2928
sudo rm -rf /usr/local/lib/android || true
3029
sudo rm -rf /usr/share/dotnet || true
3130
sudo rm -rf /opt/ghc || true
3231
sudo rm -rf /usr/local/.ghcup || true
33-
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
3432
sudo apt-get clean
3533
df -h
3634
3735
# ---- Checkout ----
3836
- uses: actions/checkout@v4
3937

40-
# ---- Python + Poetry ----
38+
# ---- Python setup ----
39+
# Pin to an explicit patch version so cached venv is always valid
4140
- uses: actions/setup-python@v5
41+
id: setup-python
4242
with:
43-
python-version: "3.9"
43+
python-version: "3.9.25"
4444

45-
- uses: snok/install-poetry@v1
46-
with:
47-
virtualenvs-create: true
48-
virtualenvs-in-project: true
49-
installer-parallel: true
45+
# ---- Install uv ----
46+
- name: Install uv
47+
run: |
48+
curl -LsSf https://astral.sh/uv/install.sh | sh
49+
echo "$HOME/.local/bin" >> $GITHUB_PATH
50+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
5051
51-
# ---- Cache Poetry deps only ----
52-
- uses: actions/cache@v4
52+
# ---- Cache uv global + python installs ----
53+
- name: Cache uv global cache
54+
uses: actions/cache@v4
5355
with:
54-
path: /tmp/poetry_cache
55-
key: poetry-${{ runner.os }}-3.9-${{ hashFiles('**/poetry.lock', '**/pyproject.toml') }}
56+
path: |
57+
~/.cache/uv
58+
~/.local/share/uv
59+
key: uv-cache-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/uv.lock', '**/pyproject.toml') }}
60+
restore-keys: |
61+
uv-cache-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-
62+
63+
# ---- Cache project venv ----
64+
- name: Cache project .venv
65+
uses: actions/cache@v4
66+
with:
67+
path: .venv
68+
key: uv-venv-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/uv.lock', '**/pyproject.toml') }}
69+
restore-keys: |
70+
uv-venv-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-
5671
57-
# ---- Env Setup ----
58-
- run: make setup-dev
72+
# ---- Environment Setup ----
73+
# Important:
74+
# make setup-dev MUST *not* delete .venv — otherwise the cache is pointless.
75+
- name: Setup dev environment
76+
run: make setup-dev
5977

6078
# ---- FORMAT ----
6179
- name: Run formatter
@@ -77,7 +95,8 @@ jobs:
7795
- uses: actions/upload-pages-artifact@v3
7896
with:
7997
path: site
80-
# Deploy Docs
98+
99+
# ---- Deploy Docs ----
81100
deploy_docs:
82101
if: github.ref == 'refs/heads/main'
83102
needs: build

.github/workflows/publish.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,37 @@ jobs:
2020
with:
2121
python-version: "3.9"
2222

23-
- name: Install Poetry
24-
uses: snok/install-poetry@v1
25-
with:
26-
virtualenvs-create: true
27-
virtualenvs-in-project: true
28-
installer-parallel: true
29-
30-
- name: Cache virtualenv
31-
uses: actions/cache@v4
32-
with:
33-
path: .venv
34-
key: venv-${{ runner.os }}-3.9-${{ hashFiles('**/poetry.lock', '**/pyproject.toml') }}
23+
- name: Install uv
24+
run: |
25+
curl -LsSf https://astral.sh/uv/install.sh | sh
26+
echo "$HOME/.local/bin" >> $GITHUB_PATH
27+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
3528
3629
- name: Install dependencies
3730
run: make setup-dev
3831

32+
- name: Install versioning deps
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install tomlkit
36+
3937
- name: Set version from GitHub tag
4038
run: |
4139
# Extract tag like "v1.2.3" → "1.2.3"
4240
VERSION=${GITHUB_REF#refs/tags/v}
43-
echo "Setting version to $VERSION"
44-
# Update pyproject.toml version field
45-
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
41+
echo "Setting [project].version to $VERSION"
42+
python - << 'PY'
43+
from pathlib import Path
44+
from tomlkit import parse, dumps
45+
import os
46+
version = os.environ.get('VERSION')
47+
p = Path('pyproject.toml')
48+
doc = parse(p.read_text(encoding='utf-8'))
49+
# Update PEP 621 version
50+
if 'project' in doc:
51+
doc['project']['version'] = version
52+
p.write_text(dumps(doc), encoding='utf-8')
53+
PY
4654
4755
- name: Build package
4856
run: make build

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ logs/*
77
.DS_Store
88
.vscode/
99
.env
10-
poetry.lock
1110
*.egg-info/*
1211
site/
1312
build/
14-
dist/
13+
dist/

.pre-commit-config.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ repos:
4545

4646
- repo: local
4747
hooks:
48-
- id: mypy-poetry
48+
- id: mypy-uv
4949
name: Type check with mypy
50-
entry: poetry run mypy sygra
50+
entry: uv run mypy sygra
5151
language: system
5252
pass_filenames: false
5353
stages: [ pre-commit ]
@@ -59,16 +59,11 @@ repos:
5959
name: Format code with Black
6060
files: ^(sygra|tests)/.*\.py$
6161

62-
- repo: https://github.com/python-poetry/poetry
63-
rev: 1.7.0
64-
hooks:
65-
- id: poetry-check
66-
6762
- repo: local
6863
hooks:
6964
- id: pytest
7065
name: Run tests with pytest
71-
entry: poetry run pytest -q tests
66+
entry: uv run pytest -q tests
7267
language: system
7368
pass_filenames: false
7469
stages: [ pre-commit ]

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ We use [pre-commit](https://pre-commit.com/) to keep the codebase consistent. Ho
3030
### One-time setup
3131

3232
```bash
33-
# Install dependencies (includes pre-commit as a dev dep)
34-
poetry install
33+
# Install project dependencies (dev tools included)
34+
make setup-dev
3535

36-
# Install Git hooks for this repo
37-
poetry run pre-commit install
38-
poetry run pre-commit install -t pre-push
36+
# Install Git hooks for this repo (no need to add pre-commit to deps)
37+
uvx pre-commit install
38+
uvx pre-commit install -t pre-push
3939

4040
# (optional) Warm the caches so your first commit is fast
41-
poetry run pre-commit run --all-files
41+
uvx pre-commit run --all-files
4242
```
4343

4444
#### Why pre-commit?

Makefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include check.mk
88
# Python interpreter
99
PYTHON = python
1010
PYTEST = pytest
11-
POETRY = poetry
11+
UV = uv
1212

1313
########################################################################################################################
1414
# DEVELOPMENT ENVIRONMENT
@@ -17,58 +17,58 @@ POETRY = poetry
1717
.PHONY: setup
1818
setup: ## Install core dependencies
1919
@echo "Installing SyGra core dependencies"
20-
$(POETRY) install --no-interaction --no-root --without dev,ui
20+
$(UV) sync
2121

2222
.PHONY: setup-all
2323
setup-all: ## Install core and extra dependencies
2424
@echo "Installing SyGra Core and extra dependencies"
25-
$(POETRY) install --no-interaction --no-root --without dev
25+
$(UV) sync --extra ui
2626

2727
.PHONY: setup-ui
2828
setup-ui: ## Install development dependencies
2929
@echo "Installing SyGra UI dependencies"
30-
$(POETRY) install --no-interaction --no-root --without dev
30+
$(UV) sync --extra ui
3131

3232
.PHONY: setup-dev
3333
setup-dev: ## Install development dependencies
3434
@echo "Installing SyGra Core, Extra and Development dependencies"
35-
$(POETRY) install --no-interaction --no-root
35+
$(UV) sync --extra dev --extra ui
3636

3737
########################################################################################################################
3838
# TESTING
3939
########################################################################################################################
4040

4141
.PHONY: test
4242
test: ## Run tests
43-
$(POETRY) run $(PYTEST)
43+
$(UV) run $(PYTEST)
4444

4545
.PHONY: test-verbose
4646
test-verbose: ## Run tests in verbose mode
47-
$(POETRY) run $(PYTEST) -v
47+
$(UV) run $(PYTEST) -v
4848

4949
.PHONY: test-coverage
5050
test-coverage: ## Run tests with coverage
51-
$(POETRY) run $(PYTEST) --cov=sygra --cov-report=term --cov-report=xml
51+
$(UV) run $(PYTEST) --cov=sygra --cov-report=term --cov-report=xml
5252

5353
########################################################################################################################
5454
# DOCUMENTATION
5555
########################################################################################################################
5656

5757
.PHONY: docs
5858
docs: ## Generate documentation
59-
$(POETRY) run mkdocs build --strict
59+
$(UV) run mkdocs build --strict
6060

6161
.PHONY: docs-serve
6262
docs-serve: ## Serve documentation locally
63-
$(POETRY) run mkdocs serve
63+
$(UV) run mkdocs serve
6464

6565
########################################################################################################################
6666
# BUILDING & PUBLISHING
6767
########################################################################################################################
6868

6969
.PHONY: build
7070
build: ## Build package
71-
$(POETRY) build
71+
$(UV) run $(PYTHON) -m build
7272

7373
.PHONY: clean
7474
clean: ## Clean build artifacts
@@ -84,4 +84,4 @@ clean: ## Clean build artifacts
8484
ci: check-format check-lint test ## Run CI tasks (format, lint, test)
8585

8686
# Default target
87-
.DEFAULT_GOAL := help
87+
.DEFAULT_GOAL := help

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ See full steps in <a href="https://servicenow.github.io/SyGra/installation/">Ins
8383
git clone [email protected]:ServiceNow/SyGra.git
8484

8585
cd SyGra
86-
poetry run python main.py --task examples.glaive_code_assistant --num_records=1
86+
uv run python main.py --task examples.glaive_code_assistant --num_records=1
8787
```
8888
</details>
8989

@@ -114,7 +114,7 @@ workflow.run(num_records=1)
114114
The SyGra architecture is composed of multiple components. The following diagrams illustrate the four primary components and their associated modules.
115115

116116
### Data Handler
117-
Data handler is used for reading and writing the data. Currently, it supports following handlers:
117+
Data handler is used for reading and writing the data. Currently, it supports following handlers:
118118
- File handler with various file types like JSON, JSONL, CSV, Parquet, Folder with supported type.
119119
- Huggingface handler: When reading data from huggingface, it can read the whole dataset and process, or it can stream chunk of data.
120120
- ServiceNow Handler to connect a ServiceNow instance : Currently it reads or writes into a single table per dataset configuration.

0 commit comments

Comments
 (0)