Skip to content

Commit

Permalink
ci: efficiency tests (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez authored Nov 19, 2024
1 parent 479a7e4 commit 8680a13
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
CIBW_TEST_COMMAND: >
uv pip install -r {project}/setup.py --extra all &&
nbdev_test --path {project}/nbs/ --skip_file_re "(distributed|prophet).*.ipynb" --pause 1.0 --do_print --timing &&
pytest --durations=0 {project}/action_files
pytest --durations=0 {project}/action_files -k "not efficiency"
- name: Build wheels and run local tests
if: matrix.os-platform[0] != 'ubuntu-latest'
Expand Down Expand Up @@ -126,3 +126,23 @@ jobs:
python -m src.experiment
python -m src.evaluation --test
working-directory: ./experiments/m3

efficiency-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: "true"

- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.12"

- name: Install dependencies
run: pip install uv && uv pip install --system . pytest-codspeed pytest-xdist

- name: Run benchmarks
uses: CodSpeedHQ/action@fa1dcde8d58f2ab0b407a6a24d6cc5a8c1444a8c # 3.1.0
with:
token: ${{ secrets.CODESPEED_TOKEN }}
run: pytest action_files/test_efficiency.py --codspeed -n 2
33 changes: 33 additions & 0 deletions action_files/test_efficiency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import inspect

import numpy as np
import pytest

import statsforecast.models


models = [
statsforecast.models.AutoARIMA,
statsforecast.models.AutoCES,
statsforecast.models.AutoETS,
statsforecast.models.AutoTheta,
statsforecast.models.TBATS,
statsforecast.models.GARCH,
]


@pytest.fixture(scope="module")
def y():
return np.arange(24)[np.arange(200) % 24]


@pytest.mark.parametrize("model_cls", models)
def test_efficiency(benchmark, y, model_cls):
if model_cls is statsforecast.models.AutoCES:
# fails to fit without model="N"
model = model_cls(season_length=24, model="N")
elif "season_length" in inspect.signature(model_cls).parameters:
model = model_cls(season_length=24)
else:
model = model_cls()
benchmark(model.forecast, y=y, h=48)

0 comments on commit 8680a13

Please sign in to comment.