Skip to content

Commit e5256c5

Browse files
authored
Refactor/migrate to uv (#257)
* move autointent to `src/` * add dependency groups to pyproject * upd makefile * upd ci/cd * upd typing * upd typing ci/cd * bug fix * remove files previously added by accident * fix typing * update contributing guidelines * bug fix * try to fix some ci/cd * try to fix reusable test * fix tests * accept samoed * add logger calls to json schema script * try to fix gh actions * declare conflicting extras * update `autoapi_dirs` setting * properly set up python version * remove redundant checks in `test_dumper`
1 parent 3b77616 commit e5256c5

File tree

178 files changed

+114
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+114
-93
lines changed

.github/workflows/build-docs.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ jobs:
3131
fetch-depth: 0
3232
fetch-tags: true
3333

34-
- name: Set up Python 3.10
35-
uses: actions/setup-python@v5
36-
with:
37-
python-version: "3.10"
38-
3934
- name: Cache Hugging Face
4035
id: cache-hf
4136
uses: actions/cache@v4
@@ -47,25 +42,30 @@ jobs:
4742
run: |
4843
sudo apt install pandoc
4944
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v6
47+
with:
48+
version: "0.8.8"
49+
5050
- name: Install dependencies
5151
run: |
52-
pip install .[docs]
52+
uv sync --group docs
5353
5454
- name: Run tests
5555
if: github.event_name != 'workflow_dispatch'
5656
run: |
5757
echo "Testing documentation build..."
58-
python -m sphinx build -b doctest docs/source docs/build/html
58+
make test-docs
5959
6060
- name: Build documentation
6161
if: ${{ github.ref == 'refs/heads/dev' }} && github.event_name != 'workflow_dispatch'
6262
run: |
63-
python -m sphinx build -b html docs/source docs/build/html
63+
make docs
6464
6565
- name: build multiversion documentation
6666
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
6767
run: |
68-
sphinx-multiversion docs/source docs/build/html
68+
make multi-version-docs
6969
7070
- name: Deploy to GitHub Pages
7171
uses: peaceiris/actions-gh-pages@v3

.github/workflows/check-schema.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ jobs:
1616
with:
1717
ref: ${{ github.head_ref }}
1818

19-
- name: Set up Python
20-
uses: actions/setup-python@v5
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v6
2121
with:
22-
python-version: '3.10'
22+
version: "0.8.8"
2323

2424
- name: Install dependencies
2525
run: |
26-
pip install .
26+
uv sync
2727
2828
- name: Generate JSON Schema
2929
run: |
30-
python -m scripts.generate_json_schema_config
30+
uv run python -m scripts.generate_json_schema_config
3131
3232
- name: Check for changes in JSON Schema
3333
id: check_changes

.github/workflows/reusable-test.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ jobs:
3131
path: ~/.cache/huggingface
3232
key: ${{ runner.os }}-hf
3333

34-
- name: Setup Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v5
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v6
3636
with:
37-
python-version: ${{ matrix.python-version }}
38-
cache: "pip"
37+
version: "0.8.8"
3938

40-
- name: Install dependencies
39+
- name: Install dependencies for Python ${{ matrix.python-version }}
4140
run: |
42-
pip install .[test]
41+
uv python pin ${{ matrix.python-version }}
42+
uv sync --group test
4343
4444
- name: Run tests
4545
run: |
46-
${{ inputs.test_command }}
46+
uv run ${{ inputs.test_command }}

.github/workflows/typing.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ jobs:
99
- uses: actions/setup-python@v5
1010
with:
1111
python-version: "3.10"
12-
cache: "pip"
12+
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v6
15+
with:
16+
version: "0.8.8"
1317

1418
- name: Install dependencies
1519
run: |
16-
pip install .[typing]
20+
uv lock
21+
uv sync --group typing
1722
1823
- name: Run mypy
19-
run: mypy autointent
24+
run: uv run mypy src/autointent

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ data/RuBanking77
172172
data/RuClinc150
173173
data/RuSnips
174174
eurlex.json
175-
poetry.lock
175+
uv.lock
176176

177177
indexes_dirnames.json
178178
tests_logs

CONTRIBUTING.md

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

33
## Minimum Configuration
44

5-
We use `poetry` as our dependency manager and packager.
5+
We use `uv` as our dependency manager and packager.
66

7-
1. Install `poetry`. We recommend referring to the official documentation section [Installation with the official installer](https://python-poetry.org/docs/#installing-with-the-official-installer). In short, you just need to run:
7+
1. Install `uv`. We recommend referring to the documentations on [installing uv](https://docs.astral.sh/uv/#installation). In short, you just need to run:
88
```bash
9-
curl -sSL https://install.python-poetry.org | python3 -
9+
curl -LsSf https://astral.sh/uv/install.sh | sh
1010
```
1111

1212
2. Clone the project and navigate to the root directory
@@ -45,7 +45,7 @@ make test
4545
```
4646
Or run a specific test (using `test_bert.py` as an example):
4747
```bash
48-
poetry run pytest tests/modules/scoring/test_bert.py
48+
uv run pytest tests/modules/scoring/test_bert.py
4949
```
5050
- Check code style (it also applies formatter)
5151
```bash
@@ -57,7 +57,7 @@ make typing
5757
```
5858
Note: If mypy shows different errors locally compared to github actions, you should update your local dependencies:
5959
```bash
60-
make update
60+
make install
6161
```
6262
But it still doesn't guarantee that the local type checker will give the same errors as CI. This is because CI is configured to check on Python 3.10 and your local python version is probably the latest one.
6363

Makefile

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1+
.PHONY: all
2+
all: lint
3+
14
.DEFAULT_GOAL := all
2-
poetry = poetry run
5+
6+
sh = uv run --no-sync --frozen
37

48
.PHONY: install
59
install:
6-
poetry install --extras "dev test typing docs"
10+
rm -rf uv.lock
11+
uv sync --all-groups
712

813
.PHONY: test
914
test:
10-
$(poetry) pytest tests --cov
15+
$(sh) pytest tests --cov
1116

1217
.PHONY: test-html
1318
test-html:
14-
$(poetry) pytest --cov --cov-report html
19+
$(sh) pytest --cov --cov-report html
1520

1621
.PHONY: typing
1722
typing:
18-
$(poetry) mypy autointent
23+
$(sh) mypy src/autointent
1924

2025
.PHONY: lint
2126
lint:
22-
$(poetry) ruff format
23-
$(poetry) ruff check --fix
24-
25-
.PHONY: update
26-
update:
27-
rm -f poetry.lock
28-
poetry install --extras "dev test typing docs"
27+
$(sh) ruff format
28+
$(sh) ruff check --fix
2929

3030
.PHONY: docs
3131
docs:
32-
$(poetry) python -m sphinx build -b html docs/source docs/build/html
32+
$(sh) python -m sphinx build -b html docs/source docs/build/html
3333

3434
.PHONY: test-docs
3535
test-docs:
36-
$(poetry) python -m sphinx build -b doctest docs/source docs/build/html
36+
$(sh) python -m sphinx build -b doctest docs/source docs/build/html
3737

3838
.PHONY: serve-docs
3939
serve-docs:
40-
$(poetry) python -m http.server -d docs/build/html 8333
40+
$(sh) python -m http.server -d docs/build/html 8333
4141

4242
.PHONY: multi-version-docs
4343
multi-version-docs:
44-
$(poetry) sphinx-multiversion docs/source docs/build/html
44+
$(sh) sphinx-multiversion docs/source docs/build/html
4545

4646
.PHONY: clean-docs
4747
clean-docs:
@@ -51,7 +51,5 @@ clean-docs:
5151

5252
.PHONY: schema
5353
schema:
54-
$(poetry) python -m scripts.generate_json_schema_config
54+
$(sh) python -m scripts.generate_json_schema_config
5555

56-
.PHONY: all
57-
all: lint

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
}
7373

7474
autoapi_keep_files = True
75-
autoapi_dirs = [Path.cwd().parent.parent / "autointent"]
75+
autoapi_dirs = [Path.cwd().parent.parent / "src/autointent"]
7676
autoapi_options = [
7777
"members",
7878
"undoc-members",

pyproject.toml

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ classifiers=[
2929
'Framework :: Sphinx',
3030
'Typing :: Typed',
3131
]
32-
requires-python = ">=3.10,<4.0"
32+
requires-python = ">=3.10,<3.13"
3333
dependencies = [
3434
"sentence-transformers (>=3,<4)",
3535
"scikit-learn (>=1.5,<2.0)",
@@ -52,11 +52,46 @@ dependencies = [
5252
]
5353

5454
[project.optional-dependencies]
55-
dev = [
56-
"tach (>=0.11.3,<1.0.0)",
55+
dspy = [
56+
"dspy (>=2.6.5,<3.0.0)",
57+
]
58+
wandb = [
59+
"wandb (>=0.19.10,<1.0.0)",
60+
]
61+
codecarbon = [
62+
"codecarbon (==3.0.0)",
63+
"pynvml (>=8.0.4, <12.0.0)", # to avoid "attribute nvmlDeviceGetTotalEnergyConsumption not found" error
64+
]
65+
fastapi = [
66+
"fastapi (>=0.115, <1.0)",
67+
"uvicorn (>=0.24, <1.0)",
68+
"pydantic-settings (>=2.0, <3.0)"
69+
]
70+
fastmcp = [
71+
"pydantic-settings (>=2.0, <3.0)",
72+
"fastmcp (>=2.11.3, <3.0)"
73+
]
74+
opensearch = [
75+
"opensearch-py (>=3.0.0, <4.0.0)",
76+
]
77+
78+
[tool.uv]
79+
conflicts = [
80+
[
81+
{ extra = "codecarbon" },
82+
{ extra = "fastmcp" },
83+
]
84+
]
85+
86+
[dependency-groups]
87+
nb = [
5788
"ipykernel (>=6.29.5,<7.0.0)",
5889
"ipywidgets (>=8.1.5,<9.0.0)",
90+
]
91+
lint = [
5992
"ruff (==0.8.4)",
93+
]
94+
sentencepiece = [
6095
"sentencepiece (>=0.2.0,<0.3.0)",
6196
]
6297
test = [
@@ -90,28 +125,6 @@ docs = [
90125
"sphinx-toolbox (>=4.0.0,<5.0.0)",
91126
"sphinx-llms-txt (>=0.3.0,<0.4.0)"
92127
]
93-
dspy = [
94-
"dspy (>=2.6.5,<3.0.0)",
95-
]
96-
wandb = [
97-
"wandb (>=0.19.10,<1.0.0)",
98-
]
99-
# codecarbon = [
100-
# "codecarbon (>=3.0.2, <3.1.0)",
101-
# "pynvml (>=8.0.4, <12.0.0)", # to avoid "attribute nvmlDeviceGetTotalEnergyConsumption not found" error
102-
# ]
103-
fastapi = [
104-
"fastapi (>=0.115, <1.0)",
105-
"uvicorn (>=0.24, <1.0)",
106-
"pydantic-settings (>=2.0, <3.0)"
107-
]
108-
fastmcp = [
109-
"pydantic-settings (>=2.0, <3.0)",
110-
"fastmcp (>=2.11.3, <3.0)"
111-
]
112-
opensearch = [
113-
"opensearch-py (>=3.0.0, <4.0.0)",
114-
]
115128

116129
[project.urls]
117130
Homepage = "https://deeppavlov.github.io/AutoIntent/"
@@ -121,8 +134,10 @@ Documentation = "https://deeppavlov.github.io/AutoIntent/"
121134
[project.scripts]
122135
"basic-aug" = "autointent.generation.utterances.basic.cli:main"
123136
"evolution-aug" = "autointent.generation.utterances.evolution.cli:main"
124-
"autointent-mcp" = "autointent.server.mcp:main"
125-
"autointent-http" = "autointent.server.http:main"
137+
138+
[build-system]
139+
requires = ["uv_build>=0.8.7,<0.9.0"]
140+
build-backend = "uv_build"
126141

127142
[tool.ruff]
128143
line-length = 120
@@ -145,11 +160,11 @@ ignore = [
145160

146161
[tool.ruff.lint.per-file-ignores]
147162
"__init__.py" = ["F401", "D104"]
148-
"autointent/__init__.py" = ["I001"]
149-
"autointent/_wrappers/__init__.py" = ["I001"]
163+
"src/autointent/__init__.py" = ["I001"]
164+
"src/autointent/_wrappers/__init__.py" = ["I001"]
150165
"tests/*.py" = ["S", "PLR2004", "ERA", "D", "ANN", "SLF"]
151166
"tests/context/datahandler/test_data_handler.py" = ["PT011"]
152-
"autointent/modules/*" = ["ARG002", "ARG003"] # unused argument
167+
"src/autointent/modules/*" = ["ARG002", "ARG003"] # unused argument
153168
"docs/*" = ["INP001", "A001", "D"]
154169
"*/utils.py" = ["D104", "D100"]
155170
"*user_guides/*" = ["B018", "E501", "INP001", "T", "D", "E402", "I001", "W292", "ANN202", "ANN001", "ANN201", "PLR2004"]
@@ -160,17 +175,12 @@ max-args = 10
160175
[tool.ruff.lint.pydocstyle]
161176
convention = "google"
162177

163-
164-
[build-system]
165-
requires = ["poetry-core>=2.0"]
166-
build-backend = "poetry.core.masonry.api"
167-
168178
[tool.pytest.ini_options]
169179
minversion = "8.0"
170180
testpaths = [
171181
"tests",
172182
]
173-
pythonpath = "autointent"
183+
pythonpath = "src/autointent"
174184
# `--cov` option breaks pycharm's test debugger
175185
addopts = """
176186
-m "not transformers"
@@ -210,7 +220,7 @@ omit = [
210220

211221
[tool.coverage.paths]
212222
source = [
213-
"autointent/",
223+
"src/autointent/",
214224
]
215225

216226
[tool.coverage.report]
@@ -227,7 +237,7 @@ local_partial_types = true
227237
plugins = [
228238
"pydantic.mypy",
229239
]
230-
mypy_path = "autointent"
240+
mypy_path = "src/autointent"
231241
disable_error_code = ["override"]
232242

233243
[[tool.mypy.overrides]]
@@ -268,4 +278,3 @@ module = [
268278
"autointent.server.mcp",
269279
]
270280
ignore_errors = true
271-

0 commit comments

Comments
 (0)