From ec5bccda4f917f960226c1b0d9bb90d45c422a58 Mon Sep 17 00:00:00 2001 From: Laurenz Rettig <53396064+rettigl@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:29:35 +0200 Subject: [PATCH] Workflow restructuring (#166) * replace calculation of inverse dfield with dummy dfield in metadata test function for pose correction workflow to speed tests up * run all versions tests only on commit to main * add pytest action with single python version for pull-requests --------- Co-authored-by: Zain Sohail --- .github/workflows/pytest_coveralls.yml | 34 +++++++++++++++++++ .../{pytest.yml => pytest_muliversion.yml} | 2 -- tests/calibrator/test_momentum.py | 11 ++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pytest_coveralls.yml rename .github/workflows/{pytest.yml => pytest_muliversion.yml} (96%) diff --git a/.github/workflows/pytest_coveralls.yml b/.github/workflows/pytest_coveralls.yml new file mode 100644 index 00000000..4909c2a3 --- /dev/null +++ b/.github/workflows/pytest_coveralls.yml @@ -0,0 +1,34 @@ +# This workflow will install Python dependencies, run tests for a single versions of Python and commit test results to coveralls +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: pytest + +on: pull_request + +jobs: + pytest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + lfs: true + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Install dependencies + run: | + git lfs pull + python -m pip install --upgrade pip + python -m pip install pytest coverage coveralls + - name: Install package + run: | + python -m pip install . + - name: Test with pytest + run: | + coverage run -m pytest -sv --show-capture=no tests + - name: Submit to coveralls + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + coveralls --service=github diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest_muliversion.yml similarity index 96% rename from .github/workflows/pytest.yml rename to .github/workflows/pytest_muliversion.yml index bb07fbd9..955304ea 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest_muliversion.yml @@ -6,8 +6,6 @@ name: pytest on: push: branches: [main] - pull_request: - branches: [main] jobs: pytest: diff --git a/tests/calibrator/test_momentum.py b/tests/calibrator/test_momentum.py index 95cb2446..63ddb0f2 100644 --- a/tests/calibrator/test_momentum.py +++ b/tests/calibrator/test_momentum.py @@ -269,9 +269,20 @@ def test_apply_registration( [248.29, 248.62], ], ) + # store dummy deformation + mc.reset_deformation() + dummy_inv_dfield = np.asarray( + [ + np.asarray([np.arange(0, 2048) for _ in range(2048)]), + np.asarray([np.arange(0, 2048) for _ in range(2048)]).T, + ], + ) + mc.inverse_dfield = dummy_inv_dfield mc.add_features(features=features, rotsym=6) mc.spline_warp_estimate() mc.pose_adjustment(**transformations, apply=True) + # disable re-calculation of inverse defield to save time, as we are just testing meta data here + mc.dfield_updated = False df, metadata = mc.apply_corrections(df=df) assert "Xm" in df.columns assert "Ym" in df.columns