Skip to content

Commit

Permalink
chore: replace poetry by uv
Browse files Browse the repository at this point in the history
uv is enormously faster, more intuitive,
can install and manage different python
versions, has clearer error messages.

Thus, this should also speed up CI pipeline
see https://docs.astral.sh/uv/ for more info
  • Loading branch information
glencoe committed Nov 27, 2024
1 parent e95aab7 commit 41ec49a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 82 deletions.
33 changes: 12 additions & 21 deletions .github/actions/setup_test_environment/action.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
name: Setup Test Environment
description: "Install poetry, use poetry to install dependencies"
description: "Install uv, use uv to install dependencies"

runs:
using: "composite"
steps:
- name: create cachedir
run: mkdir ~/poetry-cache/
shell: bash
- name: Setup Caching
uses: actions/cache@v3
with:
path: ~/pypoetry-cache/
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Setup Python
uses: actions/setup-python@v4
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: 3.10.x
- name: Install Poetry
run: python3 -m pip install poetry==1.4.0 --upgrade pip
shell: bash
- name: Configure Poetry
run: poetry config cache-dir ~/poetry-cache/
shell: bash
- run: python --version
version: "0.5.4"

- name: python setup
shell: bash
- name: Install dependencies
run: poetry install --no-interaction
run: uv python install

- name: install project
shell: bash
run: uv sync --all-extras --dev
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Fetch Repository
uses: actions/checkout@v3
- uses: ./.github/actions/setup_test_environment
- run: poetry run python -m pytest -m "not simulation" tests elasticai
- run: uv run python -m pytest -m "not simulation" tests elasticai

lint-commit-messages:
name: Lint Commit Messages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: ./.github/actions/setup_test_environment

- name: Create coverage report
run: poetry run python -m pytest --cov-report xml --cov elasticai.creator -m "not simulation" tests elasticai
run: uv run python -m pytest --cov-report xml --cov elasticai.creator -m "not simulation" tests elasticai

- name: Publish coverage report
uses: orgoro/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python3.10
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ Additionally, we have unit and integration tests in the [tests](tests) folder.

### Install Dev Dependencies

- [poetry](https://python-poetry.org/)
- [uv](https://docs.astral.sh/)
- recommended:
- [pre-commit](https://pre-commit.com/)
- [commitlint](https://github.com/conventional-changelog/commitlint) to help following our [conventional commit](https://www.conventionalcommits.org/en/v1.0.0-beta.2/#summary) guidelines
poetry can be installed in the following way:
```bash
pip install poetry
poetry install
poetry shell
pip install uv
uv sync
source .venv/bin/activate
pre-commit install
npm install --save-dev @commitlint/{config-conventional,cli}

Expand Down
82 changes: 27 additions & 55 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
[tool.poetry]
[project]
name = "elasticai.creator"
version = "0.59.2"
description = "Design, train and compile neural networks optimized specifically for FPGAs."
readme = "README.md"
repository = "https://github.com/es-ude/elastic-ai.creator"
authors = ["Department Embedded Systems - University Duisburg Essen"]
packages = [{ include = "elasticai/" }]
exclude = ["elasticai/**/*_test.py", "elasticai/**/test_*.py"]


[tool.poetry.dependencies]
python = ">= 3.10, <4.0"
torch = ">=1.11"
numpy = "^1.23.0"
setuptools = "^67.5.1"
mypy = "^1.1.1"
pytest-cov = "^4.1.0"


[tool.poetry.dev-dependencies]
python-language-server = "^0.36.2"
black = ">21.12"
prospector = { extras = ["with_mypy"], version = "^1.7.7" }
pre-commit = "^3.0.0"
wily = "^1.24.0"
import-linter = "^1.7.0"
impulse = "^1.0"
pylint = "^2.16.2"
pytest = "^7.2.2"
setuptools = "^67.5.1"
elasticai-runtime-env5 = {git = "https://github.com/es-ude/elastic-ai.runtime.enV5.git", rev = "a9bc18749b1c1666828453a47c9c37f6f0aa2d61"}
author = ["Department Embedded Systems - University Duisburg Essen"]
dependencies = [
"torch>=1.11",
"numpy>=1.23.0",
]
requires-python = ">=3.10"

[dependency-groups]
dev = [
"black>=24.10.0",
"mypy>=1.13.0",
"pylint>=3.3.1",
"pytest>=8.3.3",
"semantic-release>=0.1.0",
]


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"


[tool.hatch.build.targets.sdist]
include = ["elasticai/creator/*"]
exclude = ["__pycache__"]

[tool.hatch.build.targets.wheel]
packages = ["elasticai"]

[tool.pylint]
max-line-length = 88
Expand All @@ -56,37 +52,13 @@ testpaths = ["elasticai", "tests"]
python_files = ["*_test.py", "test_*.py"]


[tool.coverage.run]
omit = [
"elasticai/creator/examples/*py",
"elasticai/creator/tests/*py",
"elasticai/creator/*Tests/*py",
"elasticai/**/__init__.py",
]
source = ["elasticai/creator"]
command_line = "-m unittest discover ."


[tool.importlinter]
root_package = "elasticai"
contract_types = [
"package_private_modules: import_contract.PackagePrivateModules",
]


[[tool.importlinter.contracts]]
name = "package private"
type = "package_private_modules"
targets = ["elasticai.creator"]
sources = ["elasticai.creator"]


[tool.semantic_release]
version_toml = ["pyproject.toml:tool.poetry.version"]
version_toml = ["pyproject.toml:project.version"]
major_on_zero = false
repository = "pypi"
upload_to_release = true
build_command = "python3 -m pip install poetry && poetry build"
build_command = "python3 -m pip install uv && poetry build"
branch = "main"
parser_angular_allowed_types = "chore,docs,feat,style,fix,refactor,wip,perf,revert"
parser_angular_minor_types = "feat"
Expand Down

0 comments on commit 41ec49a

Please sign in to comment.