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

Test and CI modernization #370

Merged
merged 80 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
b707f24
test_alignments → pytest
bmcfee Mar 13, 2024
2f2e656
test_key → pytest
bmcfee Mar 13, 2024
4d8518a
test_onset → pytest
bmcfee Mar 13, 2024
c431397
test_patterns → pytest
bmcfee Mar 13, 2024
79cac51
updating sonify tests
bmcfee Mar 13, 2024
72fec4f
transcription velocity updates
bmcfee Mar 13, 2024
4eb0e93
fixed a hack in onset test
bmcfee Mar 13, 2024
4b24acc
test_beats → pytest
bmcfee Mar 13, 2024
2db23e1
test_beats → pytest
bmcfee Mar 13, 2024
c919f3b
test_beats → pytest
bmcfee Mar 13, 2024
567a322
updating CI configs to run again
bmcfee Mar 13, 2024
62377e5
adding scipy config dump to ci action
bmcfee Mar 13, 2024
7ea56fe
reverting some working direcory business
bmcfee Mar 13, 2024
7caf3f3
modernized test_segment
bmcfee Mar 15, 2024
a22fd5e
migrated to setup.cfg
bmcfee Mar 15, 2024
83daf50
adding minimal dependency environment for CI
bmcfee Mar 15, 2024
9ac4c1f
fixing ci spec
bmcfee Mar 15, 2024
06551cb
ignore coverage files
bmcfee Mar 15, 2024
7aa37ef
modernized multipitch tests
bmcfee Mar 15, 2024
b4e77ac
temporarily disabling concurrency failures to test-drive new environm…
bmcfee Mar 15, 2024
9e79105
py312 issues
bmcfee Mar 15, 2024
1ca9fe5
modernized test_tempo
bmcfee Mar 15, 2024
0aff744
removed unused import
bmcfee Mar 15, 2024
530d147
test_transcription modernized
bmcfee Mar 16, 2024
56097b6
removed nose from display test
bmcfee Mar 16, 2024
de74514
fixed display test code
bmcfee Mar 16, 2024
e40ce42
modernized melody tests
bmcfee Mar 18, 2024
c6a607e
modernized util tests
bmcfee Mar 18, 2024
ec934ea
modernized test_io
bmcfee Mar 18, 2024
6b71073
modernized hierarchy tests
bmcfee Mar 18, 2024
a255e54
modernized separation tests
bmcfee Mar 19, 2024
6123d16
chord test translation in progress
bmcfee Mar 19, 2024
0ba98cb
chord test translation in progress
bmcfee Mar 19, 2024
2821bbd
chord test translation in progress
bmcfee Mar 19, 2024
9677077
test modernization complete
bmcfee Mar 20, 2024
9351cfe
blacked the tests
bmcfee Mar 20, 2024
c2a9f59
Adding linter action
bmcfee Mar 20, 2024
b630f20
ingesting style check configs
bmcfee Mar 20, 2024
b94d24e
mild spellchecking
bmcfee Mar 20, 2024
d8e1097
Fixed spellcheck dictionary
bmcfee Mar 20, 2024
6a54024
blaked package code
bmcfee Mar 20, 2024
b400143
velinized docstrings
bmcfee Mar 20, 2024
ecfb62e
velinized docstrings
bmcfee Mar 20, 2024
28b77c4
docstyle checks on util and key
bmcfee Mar 20, 2024
301e24b
docstyle updatse
bmcfee Mar 20, 2024
72f2d60
docstyle updates for chord
bmcfee Mar 20, 2024
d33a946
docstyle updates
bmcfee Mar 20, 2024
5afae79
velinizing again
bmcfee Mar 20, 2024
d69527c
docstyle on patterns
bmcfee Mar 20, 2024
588ee9a
docstyle pass
bmcfee Mar 20, 2024
3033bbd
black updates
bmcfee Mar 20, 2024
97fd74a
don't require bz2 for conda packages
bmcfee Mar 20, 2024
0128800
let's see if tv tests pass on minimal env
bmcfee Mar 21, 2024
8580166
let's see if tv tests pass on minimal env
bmcfee Mar 21, 2024
9133cd8
disabling group concurrency for now
bmcfee Mar 21, 2024
c44d711
trying once more with disbaling fail-fast
bmcfee Mar 21, 2024
f95c7a8
skipping broken chord sonification test for now
bmcfee Mar 21, 2024
fc156e8
skipping display tests for now
bmcfee Mar 21, 2024
b273a1f
blacking tests again
bmcfee Mar 21, 2024
c5b2d74
explicitizing a scalar conversion in goto metric to avoid numpy warning
bmcfee Mar 21, 2024
9e3b9eb
dancing around fancy index deprecations in numpy
bmcfee Mar 21, 2024
3c9e007
dancing around fancy index deprecations in numpy
bmcfee Mar 21, 2024
969d2fe
suppressing noisy warnings in melody
bmcfee Mar 21, 2024
d12b583
making segment empty tests more precise
bmcfee Mar 21, 2024
4878992
catching more warnings in separation test
bmcfee Mar 21, 2024
6589a98
blacking tests
bmcfee Mar 21, 2024
037d890
bumpy min numpy version, redoing transscription velocity fixture 2
bmcfee Mar 22, 2024
74b19e8
formatting
bmcfee Mar 22, 2024
0ac93b3
updated minimal scipy to 1.4
bmcfee Mar 22, 2024
9927de9
bumping min matplotlib as well
bmcfee Mar 22, 2024
ddfb4d3
bumping min matplotlib as well
bmcfee Mar 22, 2024
8dd2ce6
bumping matplotlib to 3.0 (2018)
bmcfee Mar 22, 2024
69653f1
making minimal numpy match scipy requirement
bmcfee Mar 22, 2024
c962ddc
Trying mpl-base instead of full package for test environment
bmcfee Mar 22, 2024
d427482
Maybe mpl 3.3 will work
bmcfee Mar 22, 2024
ecf4dcc
bumping numpy to 1.15.4
bmcfee Mar 22, 2024
2a8d9fb
removing janky warn nesting in separation test
bmcfee Mar 22, 2024
0e95576
forgot to modernize multipitch tests
bmcfee Mar 22, 2024
1baa497
update action versions
bmcfee Mar 22, 2024
89adb77
fixed content type for setup.cfg description
bmcfee Mar 22, 2024
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
5 changes: 5 additions & 0 deletions .codespell_ignore_list
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
nce
fpr
shepard
dum
theis
21 changes: 21 additions & 0 deletions .github/environment-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: lint
channels:
- conda-forge
- defaults
dependencies:
# required
- pip
- bandit
- codespell
- flake8
- pytest
- pydocstyle

# Dependencies for velin
- numpydoc>=1.1.0
- sphinx>=5.1.0
- pygments
- black

- pip:
- velin
12 changes: 12 additions & 0 deletions .github/environment-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test
channels:
- conda-forge
- defaults
dependencies:
- pip
- numpy ==1.15.4
- scipy ==1.4.0
- matplotlib-base==3.3.0
- pytest
- pytest-cov
- pytest-mpl
6 changes: 3 additions & 3 deletions .github/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ channels:
- defaults
dependencies:
- pip
- numpy
- scipy
- matplotlib
- numpy >=1.15.4
- scipy >=1.4.0
- matplotlib-base>=3.3.0
- pytest
- pytest-cov
- pytest-mpl
71 changes: 71 additions & 0 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: lint_python
on: [pull_request, push]
jobs:
lint_python:
name: "Lint and code analysis"
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
python-version: "3.11"
channel-priority: "flexible"
envfile: ".github/environment-lint.yml"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache conda
uses: actions/cache@v4
env:
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles( matrix.envfile ) }}
- name: Install conda environmnent
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: false
python-version: ${{ matrix.python-version }}
add-pip-as-python-dependency: true
auto-activate-base: false
activate-environment: lint
# mamba-version: "*"
channel-priority: ${{ matrix.channel-priority }}
environment-file: ${{ matrix.envfile }}
use-only-tar-bz2: false

- name: Conda info
shell: bash -l {0}
run: |
conda info -a
conda list

- name: Spell check package
shell: bash -l {0}
run: codespell --ignore-words .codespell_ignore_list mir_eval

- name: Security check
shell: bash -l {0}
run: bandit --recursive --skip B101,B110 .

- name: Style check package
shell: bash -l {0}
run: python -m flake8 mir_eval

- name: Format check package
shell: bash -l {0}
run: python -m black --check mir_eval

- name: Format check tests
shell: bash -l {0}
run: python -m black --check tests

- name: Docstring check
shell: bash -l {0}
run: python -m velin --check mir_eval

- name: Docstring style check
shell: bash -l {0}
run: python -m pydocstyle mir_eval
55 changes: 40 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,58 @@ name: Test Python code
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: True
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: True

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.10", "3.11"]
channel-priority: [strict]
envfile: [".github/environment.yml"]
include:
- python-version: "3.10"
- python-version: "3.12"
os: macos-latest
- python-version: "3.10"
- python-version: "3.12"
os: windows-latest
- python-version: "3.10"
- python-version: "3.12"
os: ubuntu-latest
channel-priority: flexible
- os: ubuntu-latest
python-version: "3.7"
envfile: ".github/environment-minimal.yml"
channel-priority: "flexible"
name: "Minimal dependencies"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Cache conda packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('.github/environment.yml') }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles( matrix.envfile ) }}

- name: Create conda environment
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
auto-activate-base: false
channel-priority: ${{ matrix.channel-priority }}
environment-file: .github/environment.yml
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
environment-file: ${{ matrix.envfile }}
# Disabling bz2 to get more recent dependencies.
# NOTE: this breaks cache support, so CI will be slower.
use-only-tar-bz2: False # IMPORTANT: This needs to be set for caching to work properly!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important for this to be set, but it's not set... I think we can remove this comment given your above comments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment comes from the starter code for the action. I think it's serving a useful purpose here to indicate that caching does not currently work, and it cannot until the setup-miniconda action gets fixed upstream. I'd prefer to leave it in as a provenance trail for why the flag is set the way it is.


- name: Install package in development mode
shell: bash -l {0}
Expand All @@ -60,7 +70,22 @@ jobs:
shell: bash -l {0}
run: python -c "import numpy; numpy.show_config()"

- name: Show libraries in the system on which SciPy was built
shell: bash -l {0}
run: python -c "import scipy; scipy.show_config()"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something you were using for debugging, or do we want it always?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good to include. Scipy configs can change out from under us as dependencies update, and these things have historically caused us trouble (eg transcription velocity recently, bsseval a few years back).


- name: Run unit tests
shell: bash -l {0}
run: pytest --cov=mir_eval
run: pytest
working-directory: tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@ Thumbs.db
# docs
docs/_build/*

# matplotlib tsets
# matplotlib tests
tests/result_images/*

# coverage
coverage.xml

2 changes: 1 addition & 1 deletion mir_eval/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
from . import transcription_velocity
from . import key

__version__ = '0.7'
__version__ = "0.7"
19 changes: 7 additions & 12 deletions mir_eval/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@
from mir_eval.util import filter_kwargs


def validate(
reference_timestamps: np.ndarray, estimated_timestamps: np.ndarray
):
"""Checks that the input annotations to a metric look like valid onset time
def validate(reference_timestamps: np.ndarray, estimated_timestamps: np.ndarray):
"""Check that the input annotations to a metric look like valid onset time
arrays, and throws helpful errors if not.

Parameters
Expand Down Expand Up @@ -103,13 +101,9 @@ def validate(

# Check monotonicity
if not np.all(reference_timestamps[1:] - reference_timestamps[:-1] >= 0):
raise ValueError(
"Reference timestamps are not monotonically increasing!"
)
raise ValueError("Reference timestamps are not monotonically increasing!")
if not np.all(estimated_timestamps[1:] - estimated_timestamps[:-1] >= 0):
raise ValueError(
"Estimated timestamps are not monotonically increasing!"
)
raise ValueError("Estimated timestamps are not monotonically increasing!")

# Check positivity (need for correct PCS metric calculation)
if not np.all(reference_timestamps >= 0):
Expand Down Expand Up @@ -181,7 +175,7 @@ def percentage_correct(reference_timestamps, estimated_timestamps, window=0.3):
def percentage_correct_segments(
reference_timestamps, estimated_timestamps, duration: Optional[float] = None
):
"""Calculates the percentage of correct segments (PCS) metric.
"""Calculate the percentage of correct segments (PCS) metric.

It constructs segments out of predicted and estimated timestamps separately
out of each given timestamp vector and calculates the percentage of overlap between correct
Expand Down Expand Up @@ -317,6 +311,7 @@ def karaoke_perceptual_metric(reference_timestamps, estimated_timestamps):

def evaluate(reference_timestamps, estimated_timestamps, **kwargs):
"""Compute all metrics for the given reference and estimated annotations.

Examples
--------
>>> reference_timestamps = mir_eval.io.load_events('reference.txt')
Expand All @@ -330,7 +325,7 @@ def evaluate(reference_timestamps, estimated_timestamps, **kwargs):
reference timestamp locations, in seconds
estimated_timestamps : np.ndarray
estimated timestamp locations, in seconds
kwargs
**kwargs
Additional keyword arguments which will be passed to the
appropriate metric or preprocessing functions.

Expand Down
Loading