diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfee8dfd..aef58512 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,14 +22,16 @@ jobs: with: python-version: '3.10' - - name: Upgrade pip and nox + - name: Upgrade pip run: | - pip install --upgrade pip nox + pip install --upgrade pip pip --version - nox --version + + - name: Install + run: python -m pip install build setuptools - name: Build package - run: nox -s build + run: python -m build - name: Upload package if: github.event_name == 'release' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8536c6d6..2e5407f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,57 @@ concurrency: cancel-in-progress: true jobs: - tests: + test_full: + timeout-minutes: 30 + runs-on: ubuntu-latest + + steps: + - name: Check out the repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.8' + cache: 'pip' + cache-dependency-path: setup.cfg + + - name: Upgrade pip + run: | + python -m pip install --upgrade pip wheel + pip --version + + - run: python -m pip install pre-commit + + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit/ + key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + + - name: pre-commit + run: | + pre-commit run --show-diff-on-failure --color=always --all-files + + - name: Full install + run: pip install -e '.[dev]' + + - name: pylint + run: | + python -m pylint src tests + + - name: mypy + run: | + python -m mypy --install-types --non-interactive + + - name: Run tests + run: pytest -v tests --cov --cov-report=xml --cov-config=pyproject.toml + + - name: Upload coverage report + uses: codecov/codecov-action@v3.1.1 + + test_core: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: @@ -33,28 +83,17 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.pyv }} + cache: 'pip' + cache-dependency-path: setup.cfg - - name: Upgrade pip and nox + - name: Upgrade pip run: | - python -m pip install --upgrade pip nox + python -m pip install --upgrade pip wheel pip --version - nox --version - - name: install libomp - # required for xgboost - if: runner.os == 'macOS' + - name: Install core run: | - wget https://raw.githubusercontent.com/Homebrew/homebrew-core/679923b4eb48a8dc7ecc1f05d06063cd79b3fc00/Formula/libomp.rb -O $(find $(brew --repository) -name libomp.rb) - brew install ninja libomp - brew pin libomp - - name: Lint code and check dependencies - run: nox -s lint safety + pip install -e '.[tests]' - name: Run tests - run: nox -s tests-${{ matrix.nox_pyv || matrix.pyv }} -- --cov-report=xml - - - name: Upload coverage report - uses: codecov/codecov-action@v3.1.1 - - - name: Build package - run: nox -s build + run: pytest -v tests --ignore=tests/test_frameworks diff --git a/setup.cfg b/setup.cfg index 1a8bfd6f..fd0c4293 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,6 +32,17 @@ install_requires= ruamel.yaml>=0.17.11 [options.extras_require] +dvc = + dvc>=2.37.0 +image = + numpy + pillow +sklearn = + scikit-learn +plots = + %(sklearn)s +markdown = + matplotlib tests = pytest==7.2.0 pytest-sugar==0.9.5 @@ -40,15 +51,13 @@ tests = pylint==2.15.0 pylint-plugin-utils>=0.6 mypy==0.981 + %(image)s + %(plots)s + %(dvc)s + %(markdown)s dev = %(tests)s %(all)s -image = - pillow -sklearn = - scikit-learn -plots = - %(sklearn)s mmcv = mmcv tf = diff --git a/tests/test_catalyst.py b/tests/test_frameworks/test_catalyst.py similarity index 100% rename from tests/test_catalyst.py rename to tests/test_frameworks/test_catalyst.py diff --git a/tests/test_fastai.py b/tests/test_frameworks/test_fastai.py similarity index 100% rename from tests/test_fastai.py rename to tests/test_frameworks/test_fastai.py diff --git a/tests/test_huggingface.py b/tests/test_frameworks/test_huggingface.py similarity index 100% rename from tests/test_huggingface.py rename to tests/test_frameworks/test_huggingface.py diff --git a/tests/test_keras.py b/tests/test_frameworks/test_keras.py similarity index 100% rename from tests/test_keras.py rename to tests/test_frameworks/test_keras.py diff --git a/tests/test_lgbm.py b/tests/test_frameworks/test_lgbm.py similarity index 100% rename from tests/test_lgbm.py rename to tests/test_frameworks/test_lgbm.py diff --git a/tests/test_lightning.py b/tests/test_frameworks/test_lightning.py similarity index 100% rename from tests/test_lightning.py rename to tests/test_frameworks/test_lightning.py diff --git a/tests/test_xgboost.py b/tests/test_frameworks/test_xgboost.py similarity index 100% rename from tests/test_xgboost.py rename to tests/test_frameworks/test_xgboost.py diff --git a/tests/test_main.py b/tests/test_main.py index a2c1766d..5c2ebe6a 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -4,7 +4,6 @@ import os import pytest -from funcy import last from dvclive import Live, env from dvclive.error import ( @@ -218,7 +217,7 @@ def test_continue(tmp_dir, resume, steps, metrics): dvclive.next_step() assert read_history(dvclive, "metric") == (steps, metrics) - assert read_latest(dvclive, "metric") == (last(steps), last(metrics)) + assert read_latest(dvclive, "metric") == (steps[-1], metrics[-1]) def test_resume_on_first_init(tmp_dir): @@ -259,7 +258,7 @@ def test_custom_steps(tmp_dir): dvclive.make_summary() assert read_history(dvclive, "m") == (steps, metrics) - assert read_latest(dvclive, "m") == (last(steps), last(metrics)) + assert read_latest(dvclive, "m") == (steps[-1], metrics[-1]) def test_log_reset_with_set_step(tmp_dir):