Skip to content

Commit 6635e31

Browse files
authored
refactor: poetry to UV (#36)
1 parent 0b14293 commit 6635e31

8 files changed

Lines changed: 1930 additions & 2963 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: CI
2+
23
on:
34
push:
45
branches: [main]
@@ -10,27 +11,25 @@ jobs:
1011
runs-on: ubuntu-latest
1112

1213
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up Python 3.10
15-
uses: actions/setup-python@v4
14+
- uses: actions/checkout@v6
15+
16+
- name: Install uv and Python 3.10
17+
uses: astral-sh/setup-uv@v7
1618
with:
1719
python-version: "3.10"
18-
- name: Install dependencies
19-
run: |
20-
pip install --upgrade pip
21-
pip install poetry
22-
poetry install -v
23-
20+
enable-cache: true
21+
22+
- name: Sync dependencies
23+
run: uv sync --locked
24+
2425
- name: Run isort
25-
run: poetry run isort --profile=black --check-only .
26+
run: uv run isort --profile=black --check-only .
2627

2728
- name: Run black
28-
run: poetry run black --check .
29+
run: uv run black --check .
2930

3031
- name: Check formatting
31-
run: |
32-
poetry run ruff check .
32+
run: uv run ruff check .
3333

3434
- name: Run tests
35-
run: |
36-
poetry run pytest -sv cmonge
35+
run: uv run pytest -sv cmonge

.github/workflows/pypi.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,22 @@ jobs:
1010
if: ${{ !github.event.release.prerelease }}
1111

1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
1316
steps:
1417
- name: Checkout Code
15-
uses: actions/checkout@v3
18+
uses: actions/checkout@v6
1619

17-
- name: Set up Python
18-
uses: actions/setup-python@v4
20+
- name: Install uv and Python 3.10
21+
uses: astral-sh/setup-uv@v7
1922
with:
20-
python-version: '3.10'
21-
22-
- name: Install Poetry
23-
run: |
24-
curl -sSL https://install.python-poetry.org | python3 -
25-
echo "$HOME/.local/bin" >> $GITHUB_PATH
26-
27-
- name: Configure Poetry
28-
run: |
29-
poetry config virtualenvs.create false
30-
31-
- name: Install Dependencies
32-
run: |
33-
poetry install --no-interaction --no-ansi
23+
python-version: "3.10"
3424

3525
- name: Build Package
36-
run: |
37-
poetry build
26+
run: uv build
3827

3928
- name: Publish to PyPI
4029
env:
41-
TWINE_USERNAME: __token__
42-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
43-
run: |
44-
poetry publish --username $TWINE_USERNAME --password $TWINE_PASSWORD
30+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_PASSWORD }}
31+
run: uv publish

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ celerybeat-schedule
9191
# Environments
9292
.env
9393
.venv
94+
.uv-cache/
9495
env/
9596
venv/
9697
ENV/

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
An extension of the [Monge Gap](https://proceedings.mlr.press/v202/uscidda23a.html), an approach to estimate transport maps conditionally on arbitrary context vectors. It is based on a two-step training procedure combining an encoder-decoder architecture with an OT estimator. The model is applied to [4i](https://pubmed.ncbi.nlm.nih.gov/30072512/) and [scRNA-seq](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7289078/) datasets.
2222

2323
## Systems and software requirements
24-
Software package requirements and version information can be found in `requirements.txt` and/or the `pyproject.toml`. This package has been tested on Python versions 3.10 and 3.11.
24+
Software package requirements and version information are defined in `pyproject.toml` and locked in `uv.lock`. This package has been tested on Python versions 3.10 and 3.11.
2525
Hardware requirements enough memory (RAM) to process the data and batches. GPU is not needed but does accelerate computation. This software has been tested on HPCs and local machines (iOS).
2626

2727
## Installation from PyPI
@@ -33,18 +33,17 @@ pip install cmonge
3333
which should take about two minutes on a laptop.
3434

3535
## Development setup & installation
36-
The package environment is managed by [poetry](https://python-poetry.org/docs/managing-environments/).
36+
The package environment is managed by [uv](https://docs.astral.sh/uv/).
3737
```sh
38-
pip install poetry
39-
git clone git@github.com:AI4SCR/conditional-monge.git
40-
cd cmonge
41-
poetry install -v
38+
curl -LsSf https://astral.sh/uv/install.sh | sh
39+
git clone https://github.com/AI4SCR/conditional-monge.git
40+
cd conditional-monge
41+
uv sync --frozen
4242
```
4343

4444
If the installation was successful you can run the tests using pytest
4545
```sh
46-
poetry shell # activate env
47-
pytest
46+
uv run pytest
4847
```
4948

5049
## Data

poetry.lock

Lines changed: 0 additions & 2850 deletions
This file was deleted.

pyproject.toml

Lines changed: 58 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["hatchling>=1.27.0"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
26
name = "cmonge"
37
version = "0.1.3"
48
description = "Extension of the Monge Gap to learn conditional optimal transport maps"
5-
authors = ["Alice Driessen <adr@zurich.ibm.com>", "Benedek Harsanyi <hben.0204@gmail.com>", "Jannis Born <jab@zurich.ibm.com>"]
69
readme = "README.md"
10+
requires-python = ">=3.10,<3.12"
11+
license = { file = "LICENSE" }
12+
authors = [
13+
{ name = "Alice Driessen", email = "adr@zurich.ibm.com" },
14+
{ name = "Benedek Harsanyi", email = "hben.0204@gmail.com" },
15+
{ name = "Jannis Born", email = "jab@zurich.ibm.com" },
16+
]
717
keywords = [
818
"Machine Learning",
919
"Optimal Transport",
1020
"Neural OT",
1121
"Monge Gap",
12-
"Conditional Distribution Learning"
22+
"Conditional Distribution Learning",
1323
]
14-
homepage = "https://github.com/AI4SCR/conditional-monge"
15-
repository = "https://github.com/AI4SCR/conditional-monge"
1624
classifiers = [
1725
"Development Status :: 4 - Beta",
1826
"Intended Audience :: Developers",
@@ -21,53 +29,57 @@ classifiers = [
2129
"Programming Language :: Python :: 3",
2230
"Programming Language :: Python :: 3.10",
2331
"Programming Language :: Python :: 3.11",
24-
"Topic :: Scientific/Engineering :: Artificial Intelligence"
32+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
33+
]
34+
dependencies = [
35+
"anndata>=0.10.5.post1,<0.11",
36+
"chex>=0.1.85,<0.2",
37+
"dotmap>=1.3.30,<2",
38+
"flax>=0.10.2,<0.11",
39+
"jax>=0.4.36,<0.5",
40+
"jaxlib>=0.4.36,<0.5",
41+
"loguru>=0.7.2,<0.8",
42+
"optax>=0.2.4,<0.3",
43+
"optuna>=3.5.0,<4",
44+
"ott-jax>=0.5.0,<0.6",
45+
"pandas>=2.0.0,<3",
46+
"pyyaml>=6.0",
47+
"rdkit>=2023.9.5,<2024",
48+
"scanpy>=1.9.8,<2",
49+
"scikit-learn>=1.4.0,<2",
50+
"scipy==1.12.0",
51+
"seaborn>=0.13.2,<0.14",
52+
"typer>=0.9.0,<1",
53+
"umap-learn>=0.5.5,<0.6",
2554
]
2655

56+
[project.urls]
57+
Homepage = "https://github.com/AI4SCR/conditional-monge"
58+
Repository = "https://github.com/AI4SCR/conditional-monge"
2759

28-
[tool.poetry.group.dev.dependencies]
29-
ruff = "*"
30-
pytest = "*"
31-
pre-commit = "*"
32-
33-
[tool.poetry.dependencies]
34-
python = ">=3.10,<3.12"
35-
flax = "^0.10.2"
36-
optax = "^0.2.4"
37-
ott-jax = "^0.5.0"
38-
scikit-learn = "^1.4.0"
39-
typer = "^0.9.0"
40-
loguru = "^0.7.2"
41-
optuna = "^3.5.0"
42-
pandas = "^2.0.0"
43-
seaborn = "^0.13.2"
44-
dotmap = "^1.3.30"
45-
umap-learn = "^0.5.5"
46-
jaxlib = "^0.4.36"
47-
anndata = "^0.10.5.post1"
48-
scanpy = "^1.9.8"
49-
chex = "^0.1.85"
50-
rdkit = "^2023.9.5"
51-
jax = "^0.4.36"
52-
isort = "^5.13.2"
53-
black = "^24.4.2"
54-
ruff = "^0.5.4"
55-
types-pyyaml = "^6.0.12.20240311"
56-
scipy = "1.12.0"
57-
58-
[[tool.poetry.source]]
59-
name = "jax"
60-
url = "https://storage.googleapis.com/jax-releases/jax_releases.html"
61-
priority = "primary"
60+
[dependency-groups]
61+
dev = [
62+
"black>=24.4.2,<25",
63+
"isort>=5.13.2,<6",
64+
"pre-commit",
65+
"pytest",
66+
"ruff>=0.5.4,<0.6",
67+
"types-pyyaml>=6.0.12.20240311",
68+
]
6269

70+
[tool.hatch.build.targets.sdist]
71+
include = [
72+
"/cmonge",
73+
"/LICENSE",
74+
"/README.md",
75+
"/pyproject.toml",
76+
]
6377

64-
[[tool.poetry.source]]
65-
name = "PyPI"
66-
priority = "primary"
78+
[tool.hatch.build.targets.wheel]
79+
packages = ["cmonge"]
6780

68-
[build-system]
69-
requires = ["poetry-core"]
70-
build-backend = "poetry.core.masonry.api"
81+
[tool.uv]
82+
find-links = ["https://storage.googleapis.com/jax-releases/jax_releases.html"]
7183

7284
[tool.ruff]
7385
line-length = 88

requirements.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)