Skip to content
Draft
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
15 changes: 5 additions & 10 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,20 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Ubuntu - install libsndfile
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends --yes libsndfile1

- name: Install package
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

# DOCS
- name: Ubuntu - install graphviz
run: sudo apt-get install --yes graphviz

- name: Install docs requirements
run: pip install -r docs/requirements.txt

- name: Test building documentation
run: python -m sphinx docs/ docs/_build/ -b html -W
run: uv run python -m sphinx docs/ docs/_build/ -b html -W

- name: Check links in documentation
run: python -m sphinx docs/ docs/_build/ -b linkcheck -W
run: uv run python -m sphinx docs/ docs/_build/ -b linkcheck -W
10 changes: 5 additions & 5 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
with:
python-version: '3.10'

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install pre-commit hooks
run: |
pip install pre-commit
pre-commit install --install-hooks
run: uvx pre-commit install --install-hooks

- name: Code style check via pre-commit
run: |
pre-commit run --all-files
run: uvx pre-commit run --all-files
12 changes: 4 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ jobs:
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build virtualenv
- name: Install uv
uses: astral-sh/setup-uv@v5

# PyPI package
- name: Build Python package
run: python -m build
run: uv build

- name: Publish Python package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand All @@ -48,12 +46,10 @@ jobs:
run: |
sudo apt-get install --no-install-recommends --yes libsndfile1 sox
sudo apt-get install --yes graphviz
pip install -r requirements.txt
pip install -r docs/requirements.txt

- name: Build documentation
run: |
python -m sphinx docs/ docs/_build/ -b html
uv run python -m sphinx docs/ docs/_build/ -b html

- name: Deploy documentation to Github pages
uses: peaceiris/actions-gh-pages@v4
Expand Down
26 changes: 11 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,26 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Ubuntu - install libsndfile
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends --yes libsndfile1
if: matrix.os == 'ubuntu-latest'

- name: Install package
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Install numpy<2.0.0 for pandas==2.0.3
run: |
pip install "numpy<2.0.0"
if: matrix.pandas == 'pandas==2.0.3'

- name: Install requested pandas version
run: |
pip install "${{ matrix.pandas }}"
uv add "${{ matrix.pandas }}"
if: matrix.pandas

- name: Sync Python environment
run: uv sync

- name: List installed Python packages
run: uv pip list

# TESTS
- name: Ubuntu - install ffmpeg/mediainfo
run: |
Expand All @@ -84,11 +83,8 @@ jobs:
run: choco install ffmpeg mediainfo-cli
if: matrix.os == 'windows-latest'

- name: Install tests requirements
run: pip install -r tests/requirements.txt

- name: Test with pytest
run: python -m pytest
run: uv run pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ coverage.xml
docs/api/
benchmarks/cache/
benchmarks/results/
uv.lock
51 changes: 20 additions & 31 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ Development Installation
Instead of pip-installing the latest release from PyPI_,
you should get the newest development version from Github_::

git clone https://github.com/audeering/audb/
cd audb
# Create virtual environment for this project
# e.g.
# virtualenv --python="python3" $HOME/.envs/audb
# source $HOME/.envs/audb/bin/activate
pip install -r requirements.txt
git clone https://github.com/audeering/audb/
cd audb
uv sync


This way,
Expand All @@ -50,25 +46,23 @@ are defined in :file:`pyproject.toml`.
The checks are executed in the CI using `pre-commit`_.
You can enable those checks locally by executing::

pip install pre-commit # consider system wide installation
pre-commit install
pre-commit run --all-files
uvx pre-commit install
uvx pre-commit run --all-files

Afterwards ruff_ and codespell_ are executed
every time you create a commit.

You can also install ruff_ and codespell_
and call it directly::

pip install ruff codespell # consider system wide installation
ruff check --fix . # lint all Python files, and fix any fixable errors
ruff format . # format code of all Python files
codespell
uvx ruff check --fix . # lint all Python files, and fix any fixable errors
uvx ruff format . # format code of all Python files
uvx codespell

It can be restricted to specific folders::

ruff check audfoo/ tests/
codespell audfoo/ tests/
uvx ruff check audfoo/ tests/
uvx codespell audfoo/ tests/


.. _codespell: https://github.com/codespell-project/codespell/
Expand All @@ -81,36 +75,31 @@ Building the Documentation
--------------------------

If you make changes to the documentation,
you can re-create the HTML pages using Sphinx_.
You can install it and a few other necessary packages with::
you can re-create the HTML pages using Sphinx_::

pip install -r docs/requirements.txt
uv run python -m sphinx docs/ build/html -b html

To create the HTML pages, use::
The generated files will be available
in the directory :file:`build/html/`.

python -m sphinx docs/ build/sphinx/html -b html
Note,
that you need ``graphviz`` for building the documentation::

The generated files will be available
in the directory :file:`build/sphinx/html/`.
sudo apt install graphviz

It is also possible to automatically check if all links are still valid::

python -m sphinx docs/ build/sphinx/html -b linkcheck
uv run python -m sphinx docs/ build/html -b linkcheck

.. _Sphinx: http://sphinx-doc.org


Running the Tests
-----------------

You'll need pytest_ for that.
It can be installed with::

pip install -r tests/requirements.txt

To execute the tests, simply run::
You can run tests with pytest_::

python -m pytest
uv run pytest

.. _pytest: https://pytest.org

Expand Down
16 changes: 4 additions & 12 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ on the following machine:
* Linux: Ubuntu 22.04
* Python: 3.10

Before running any benchmark,
make sure to install missing requirements with:

```bash
$ cd benchmarks/
$ pip install -r requirements.txt
```


## audb.Dependencies methods

Expand All @@ -34,7 +26,7 @@ the dependency table internally.
To run the benchmark execute:

```bash
$ python benchmark-dependencies-methods.py
$ uv run --python 3.10 benchmark-dependencies-methods.py
```

Execution times in seconds
Expand Down Expand Up @@ -97,14 +89,14 @@ This benchmark was executed on:
To run the benchmark execute:

```bash
$ python benchmark-dependencies-methods-polars.py
$ uv run --python 3.11 benchmark-dependencies-methods-polars.py
```

The data were compared to
the results from `benchmark-dependencies-methods.py` using

```bash
python compare_dependency_methods_polars.py
$ uv run --python 3.11 compare_dependency_methods_polars.py
```
Both steps require that `benchmark-dependencies-methods.py`
has been run previously in order to create the test data
Expand Down Expand Up @@ -161,7 +153,7 @@ and `pyarrow.Table`).
To run the benchmark execute:

```bash
$ python benchmark-dependencies-save-and-load.py
$ uv run --python 3.10 benchmark-dependencies-save-and-load.py
```

**Writing**
Expand Down
10 changes: 10 additions & 0 deletions benchmarks/benchmark-dependencies-methods-polars.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# /// script
# dependencies = [
# "audb",
# "tabulate",
# ]
#
# [tool.uv.sources]
# audb = { path = "../", editable = true }
# ///

import random
import time

Expand Down
10 changes: 10 additions & 0 deletions benchmarks/benchmark-dependencies-methods.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# /// script
# dependencies = [
# "audb",
# "tabulate",
# ]
#
# [tool.uv.sources]
# audb = { path = "../", editable = true }
# ///

import hashlib
import os
import pickle
Expand Down
11 changes: 11 additions & 0 deletions benchmarks/benchmark-dependencies-save-and-load.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# /// script
# dependencies = [
# "audb",
# "memray ==1.11.0",
# "tabulate",
# ]
#
# [tool.uv.sources]
# audb = { path = "../", editable = true }
# ///

import hashlib
import os
import pickle
Expand Down
7 changes: 7 additions & 0 deletions benchmarks/compare_dependency_methods_polars.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# /// script
# dependencies = [
# "pandas",
# "tabulate",
# ]
# ///

import pandas as pd
import tabulate

Expand Down
11 changes: 11 additions & 0 deletions benchmarks/dependencies_polars.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# /// script
# dependencies = [
# "audb",
# "polars",
# "tabulate",
# ]
#
# [tool.uv.sources]
# audb = { path = "../", editable = true }
# ///

from __future__ import annotations

from collections.abc import Callable
Expand Down
5 changes: 0 additions & 5 deletions benchmarks/requirements.txt

This file was deleted.

7 changes: 0 additions & 7 deletions docs/requirements.txt

This file was deleted.

12 changes: 12 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# build documentation
docs:
uv run python -m sphinx docs/ build/html -b html

# run tests
test *ARGS:
uv run pytest {{ARGS}}

# run pre-commit
pre-commit:
uvx pre-commit install
uvx pre-commit run --all-files
Loading