Skip to content

Commit

Permalink
CI: Optimize pytest vs. GHA configuration
Browse files Browse the repository at this point in the history
Fuse GHA/pytest configurations into single workflow recipe.
  • Loading branch information
amotl committed Nov 5, 2023
1 parent 5d7844e commit 6ce4499
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 126 deletions.
135 changes: 9 additions & 126 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ jobs:
- name: Run notebooks
run: pytest --nbmake --nbmake-kernel=cikernel -n=auto --nbmake-timeout=3000 --ignore=./tutorials/translations ./tutorials/

test_linux:
runs-on: ubuntu-latest
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
os: [ 'ubuntu-latest', 'windows-latest' ]
python-version: [ '3.8', '3.9', '3.10', '3.11' ]

defaults:
run:
shell: bash

name: Python ${{ matrix.python-version }} on OS ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -89,132 +95,9 @@ jobs:
python --version
which python
pip list
- name: Remove tests
run: |
rm tests/test_classification_tuning.py
rm tests/test_classification_plots.py
rm tests/test_regression_plots.py
rm tests/test_regression_tuning.py
rm tests/test_time_series_tune_grid.py
rm tests/test_time_series_tune_random.py
rm tests/test_time_series_plots.py
rm tests/test_time_series_utils_plots.py
rm tests/benchmarks/*.py
- name: Test with pytest
run: pytest --durations=0

# test_linux_3p11:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: ["3.11"]

# steps:
# - uses: actions/checkout@v3
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v3
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# # SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL required due to
# # pyLDAvis 3.3.1 having an "sklearn" dependency
# run: |
# export SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True
# python -m pip install -U pip
# python -m pip install -U pytest numpy

# pip install ".[full, test]"
# if [ -f requirements-prophet.txt ]; then pip install -r requirements-prophet.txt; fi
# - name: Python version and dependency list
# run: |
# echo "Python version expected: ${{ matrix.python-version }}"
# python --version
# which python
# pip list
# - name: Remove tests
# run: |
# rm tests/test_classification_tuning.py
# rm tests/test_classification_plots.py
# rm tests/test_regression_plots.py
# rm tests/test_regression_tuning.py
# rm tests/test_time_series_tune_grid.py
# rm tests/test_time_series_tune_random.py
# rm tests/test_time_series_plots.py
# rm tests/test_time_series_utils_plots.py
# rm tests/benchmarks/*.py
# - name: Test with pytest
# run: pytest --durations=0

test_windows:
runs-on: windows-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
# SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL required due to
# pyLDAvis 3.3.1 having an "sklearn" dependency
run: |
$env:SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL = 'True'
python -m pip install -U pip
python -m pip install -U pytest numpy
pip install ".[full, test]"
pip install -r requirements-prophet.txt
- name: Python version and dependency list
run: |
echo "Python version expected: ${{ matrix.python-version }}"
python --version
which python
pip list
- name: Remove tests
run: |
remove-item tests/* -Include @('test_clustering.py', 'test_classification_tuning.py','test_classification_plots.py','test_regression_plots.py', 'test_regression_tuning.py', 'test_time_series_tune_grid.py', 'test_time_series_tune_random.py', 'test_create_api.py', 'test_create_docker.py', 'test_drift_report.py', 'test_eda.py', 'test_time_series_plots.py', 'test_time_series_utils_plots.py')
remove-item tests/benchmarks/*
- name: Test with pytest
run: pytest --durations=0

# test_windows_3p11:
# runs-on: windows-latest
# strategy:
# matrix:
# python-version: ["3.11"]

# steps:
# - uses: actions/checkout@v3
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# # SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL required due to
# # pyLDAvis 3.3.1 having an "sklearn" dependency
# run: |
# $env:SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL = 'True'
# python -m pip install -U pip
# python -m pip install -U pytest numpy

# pip install ".[full, test]"
# pip install -r requirements-prophet.txt
# - name: Python version and dependency list
# run: |
# echo "Python version expected: ${{ matrix.python-version }}"
# python --version
# which python
# pip list
# - name: Remove tests
# run: |
# remove-item tests/* -Include @('test_clustering.py', 'test_classification_tuning.py','test_classification_plots.py','test_regression_plots.py', 'test_regression_tuning.py', 'test_time_series_tune_grid.py', 'test_time_series_tune_random.py', 'test_create_api.py', 'test_create_docker.py', 'test_drift_report.py', 'test_eda.py', 'test_time_series_plots.py', 'test_time_series_utils_plots.py')
# remove-item tests/benchmarks/*
# - name: Test with pytest
# run: pytest --durations=0

test_plots:
runs-on: ubuntu-latest
strategy:
Expand Down
5 changes: 5 additions & 0 deletions tests/benchmarks/test_memory_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
from pycaret.internal.memory import fast_hash # noqa
from pycaret.regression import RegressionExperiment


if "CI" in os.environ:
pytest.skip("Skipping test module on CI", allow_module_level=True)


data_df = get_data(verbose=False)
supervised_datasets_df = data_df.copy()
supervised_datasets_df["Items"] = (
Expand Down
7 changes: 7 additions & 0 deletions tests/benchmarks/test_time_series_sp_detection.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
"""Module to benchmark auto detection of time series seasonal period

Check failure on line 1 in tests/benchmarks/test_time_series_sp_detection.py

View workflow job for this annotation

GitHub Actions / code_quality

Imports are incorrectly sorted and/or formatted.
"""
import os

import pytest

from pycaret.datasets import get_data
from pycaret.time_series import TSForecastingExperiment


if "CI" in os.environ:
pytest.skip("Skipping test module on CI", allow_module_level=True)


ids = ["raw_strength", "harmonic_max", "harmonic_strength"]
params = [
(ids[0], 0.9211, 0.9307, 0.1230, 0.8365),
Expand Down
7 changes: 7 additions & 0 deletions tests/test_classification_plots.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import os

Check failure on line 1 in tests/test_classification_plots.py

View workflow job for this annotation

GitHub Actions / code_quality

Imports are incorrectly sorted and/or formatted.

import pandas as pd
import pytest

import pycaret.classification
import pycaret.datasets


if "CI" in os.environ:
pytest.skip("Skipping test module on CI", allow_module_level=True)


def test_plot():
# loading dataset
data = pycaret.datasets.get_data("juice")
Expand Down
5 changes: 5 additions & 0 deletions tests/test_classification_tuning.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys

import pandas as pd
import pytest
Expand All @@ -11,6 +12,10 @@
os.environ["TUNE_MAX_LEN_IDENTIFIER"] = "1"


if "CI" in os.environ:
pytest.skip("Skipping test module on CI", allow_module_level=True)


@pytest.mark.skip(reason="no way of currently testing this")
def test_classification_tuning():
# loading dataset
Expand Down
5 changes: 5 additions & 0 deletions tests/test_clustering.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys

Check failure on line 1 in tests/test_clustering.py

View workflow job for this annotation

GitHub Actions / code_quality

Imports are incorrectly sorted and/or formatted.
import uuid

import pandas as pd
Expand All @@ -8,6 +9,10 @@
import pycaret.datasets


if sys.platform == "win32":
pytest.skip("Skipping test module on Windows", allow_module_level=True)


@pytest.fixture(scope="module")
def data():
return pycaret.datasets.get_data("jewellery")
Expand Down
8 changes: 8 additions & 0 deletions tests/test_create_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import sys

Check failure on line 1 in tests/test_create_api.py

View workflow job for this annotation

GitHub Actions / code_quality

Imports are incorrectly sorted and/or formatted.

import pytest

import pycaret.classification
import pycaret.datasets
import pycaret.regression


if sys.platform == "win32":
pytest.skip("Skipping test module on Windows", allow_module_level=True)


def test_classification_create_api():

# loading dataset
Expand Down
8 changes: 8 additions & 0 deletions tests/test_create_docker.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import sys

Check failure on line 1 in tests/test_create_docker.py

View workflow job for this annotation

GitHub Actions / code_quality

Imports are incorrectly sorted and/or formatted.

import pytest

import pycaret.classification
import pycaret.datasets
import pycaret.regression


if sys.platform == "win32":
pytest.skip("Skipping test module on Windows", allow_module_level=True)


def test_classification_create_docker():

# loading dataset
Expand Down
7 changes: 7 additions & 0 deletions tests/test_regression_plots.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import os

Check failure on line 1 in tests/test_regression_plots.py

View workflow job for this annotation

GitHub Actions / code_quality

Imports are incorrectly sorted and/or formatted.

import pandas as pd
import pytest

import pycaret.datasets
import pycaret.regression


if "CI" in os.environ:
pytest.skip("Skipping test module on CI", allow_module_level=True)


def test_plot():
# loading dataset
data = pycaret.datasets.get_data("boston")
Expand Down
6 changes: 6 additions & 0 deletions tests/test_regression_tuning.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

Check failure on line 1 in tests/test_regression_tuning.py

View workflow job for this annotation

GitHub Actions / code_quality

Imports are incorrectly sorted and/or formatted.

import pandas as pd
import pytest

Expand All @@ -6,6 +8,10 @@
from pycaret.utils.generic import can_early_stop


if sys.platform == "linux":
pytest.skip("Skipping test module on Linux", allow_module_level=True)


@pytest.mark.skip(reason="no way of currently testing this")
def test_regression_tuning():
# loading dataset
Expand Down
4 changes: 4 additions & 0 deletions tests/test_time_series_plots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Module to test time_series plotting functionality
"""
import os
import sys

import numpy as np # type: ignore
import pytest
Expand All @@ -19,6 +20,9 @@
pytestmark = pytest.mark.filterwarnings("ignore::UserWarning")
os.environ["PYCARET_TESTING"] = "1"

if sys.platform == "win32":
pytest.skip("Skipping test module on Windows", allow_module_level=True)


##############################
# Functions Start Here ####
Expand Down
5 changes: 5 additions & 0 deletions tests/test_time_series_tune_grid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Module to test time_series functionality
"""
import os

import numpy as np # type: ignore
import pandas as pd # type: ignore
import pytest
Expand All @@ -9,6 +11,9 @@

pytestmark = pytest.mark.filterwarnings("ignore::UserWarning")

if "CI" in os.environ:
pytest.skip("Skipping test module on CI", allow_module_level=True)


##############################
# Functions Start Here ####
Expand Down
6 changes: 6 additions & 0 deletions tests/test_time_series_tune_random.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Module to test time_series functionality
"""
import os

import numpy as np # type: ignore
import pandas as pd # type: ignore
import pytest
Expand All @@ -10,6 +12,10 @@
pytestmark = pytest.mark.filterwarnings("ignore::UserWarning")


if "CI" in os.environ:
pytest.skip("Skipping test module on CI", allow_module_level=True)


##############################
# Functions Start Here ####
##############################
Expand Down
4 changes: 4 additions & 0 deletions tests/test_time_series_utils_plots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Module to test time_series plotting functionality
"""
import os
from typing import List

import pandas as pd # type: ignore
Expand All @@ -17,6 +18,9 @@

pytestmark = pytest.mark.filterwarnings("ignore::UserWarning")

if "CI" in os.environ:
pytest.skip("Skipping test module on CI", allow_module_level=True)


##########################
# Tests Start Here ####
Expand Down

0 comments on commit 6ce4499

Please sign in to comment.