Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv migration #47

Merged
merged 13 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set Up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'poetry'
- name: Setup Python
run: uv python install 3.11

- name: Install Dependencies
run: poetry install --no-interaction
- name: Install dependencies
run: uv sync --dev

- name: Publish Package
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
poetry publish --build --no-interaction
- name: Build distributions
run: uvx --from build pyproject-build --installer uv

- name: Publish the package
run: uvx twine upload --password ${{ secrets.PYPI_API_TOKEN }} dist/*
46 changes: 32 additions & 14 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on: [push, pull_request]

jobs:
test:
env:
UV_CACHE_DIR: /tmp/.uv-cache

strategy:
fail-fast: false
matrix:
Expand All @@ -13,22 +16,37 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Chechout with submodules
uses: actions/checkout@v3
- name: Checkout with submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Poetry
run: pipx install poetry

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: "poetry"
- name: Install uv (UNIX)
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install uv (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: irm https://astral.sh/uv/install.ps1 | iex
shell: powershell

- name: Install Dependencies
run: poetry install --no-interaction
- name: Setup Python ${{ matrix.python }}
run: uv python install ${{ matrix.python }}

- name: Run Tests
run: poetry run pytest
- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}

- name: Install dependencies
run: uv sync --dev

- name: Run tests
run: uv run pytest tests

- name: Minimize uv cache
run: uv cache prune --ci
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.2
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
16 changes: 11 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.analysis.typeCheckingMode": "off",
"notebook.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit",
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff",
},
}
"notebook.formatOnSave.enabled": false,
}
6 changes: 4 additions & 2 deletions LICENCE → LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Copyright 2022 LAC Louis
MIT License

Copyright (c) 2022-present Louis Lac <lac.louis5@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,24 @@ git clone https://github.com/laclouis5/globox --recurse-submodules=tests/globox_
cd globox
```

Install with Poetry:
Install dependencies with [uv](https://github.com/astral-sh/uv):

```shell
poetry install
uv sync --dev
```

Run the tests:

```shell
poetry run pytest
uv run pytest tests
```

## Speed Banchmarks

Speed benchmark can be executed with:

```shell
python tests/benchmark.py -n 5
uv run python tests/benchmark.py -n 5
```

The following speed test is performed using Python 3.11 and `timeit` with 5 iterations on a 2021 MacBook Pro 14" (M1 Pro 8 Cores and 16 GB of RAM). The dataset is COCO 2017 Validation which comprises 5k images and 36 781 bounding boxes.
Expand Down
Loading