diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 544f751b..c6a1d1d7 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -11,7 +11,7 @@ on: jobs: docs: name: Push Sphinx Pages - runs-on: ubuntu-latest + runs-on: Linux-x64 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 diff --git a/.github/workflows/pypi-test.yml b/.github/workflows/pypi-test.yml index f74ec8b0..14be0dae 100644 --- a/.github/workflows/pypi-test.yml +++ b/.github/workflows/pypi-test.yml @@ -1,40 +1,74 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Test the library on: push: - branches: [ main ] + branches: + - master # for legacy repos + - main pull_request: - branches: [ main ] + branches: + - master # for legacy repos + - main + workflow_dispatch: # Allow manually triggering the workflow + schedule: + # Run roughly every 15 days at 00:00 UTC + # (useful to check if updates on dependencies break the package) + - cron: "0 0 1,16 * *" -jobs: - build: +permissions: + contents: read + +concurrency: + group: >- + ${{ github.workflow }}-${{ github.ref_type }}- + ${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true - runs-on: ubuntu-latest +jobs: + test: strategy: matrix: - python-version: [ '3.10' ] - - name: Python ${{ matrix.python-version }} + python: ["3.10"] # , "3.11", "3.12", "3.13", "3.14" + platform: + - Linux-x64 + # - ubuntu-latest + # - macos-latest + # - windows-latest + runs-on: ${{ matrix.platform }} + name: Python ${{ matrix.python }}, ${{ matrix.platform }} steps: - - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest tox - # - name: Lint with flake8 - # run: | - # # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - # # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with tox - run: | - tox + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + id: setup-python + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox coverage + + - name: Run tests + run: >- + pipx run --python '${{ steps.setup-python.outputs.python-path }}' + tox + -- -rFEx --durations 10 --color yes --cov --cov-branch --cov-report=xml # pytest args + + - name: Check for codecov token availability + id: codecov-check + shell: bash + run: | + if [ ${{ secrets.CODECOV_TOKEN }} != '' ]; then + echo "codecov=true" >> $GITHUB_OUTPUT; + else + echo "codecov=false" >> $GITHUB_OUTPUT; + fi + + - name: Upload coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v5 + if: ${{ steps.codecov-check.outputs.codecov == 'true' }} + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + slug: ${{ github.repository }} + flags: ${{ matrix.platform }} - py${{ matrix.python }} diff --git a/tests/test_interpret.py b/tests/test_interpret.py index 485caa27..70fe0d6c 100644 --- a/tests/test_interpret.py +++ b/tests/test_interpret.py @@ -231,7 +231,7 @@ def test_scan_sequences(): 'fimo_p-value': [0.000244140625, 0.000244140625], 'matched_seq': ['CACGTG', 'TGCGTG'] }) - assert out.equals(expected) + pd.testing.assert_frame_equal(out, expected, atol=1e-3) # Allow reverse complement out = scan_sequences(seqs, motifs=meme_file, rc=True, pthresh=1e-3) @@ -248,7 +248,7 @@ def test_scan_sequences(): 'matched_seq': ['CACGTG', 'CACGTG', 'CACGCA', 'TGCGTG'] }) - assert out.equals(expected) + pd.testing.assert_frame_equal(out, expected, atol=1e-3) # Reverse complement with attributions attrs = get_attributions(model, seqs, method="inputxgradient") @@ -266,7 +266,7 @@ def test_scan_sequences(): 'site_attr_score': np.float32([0.0, 0.0, 0.009259258396923542, -0.009259259328246117]), 'motif_attr_score': [0.003703703731298441, 0.0, 0.0, -0.03549381507926434] }) - assert out.equals(expected) + pd.testing.assert_frame_equal(out, expected, atol=1e-3) def test_compare_motifs(): @@ -288,7 +288,7 @@ def test_compare_motifs(): 'fimo_score_ref': [11.60498046875, -2.9944558143615723], 'fimo_score_diff': [-26.253820657730103, 13.22646164894104] }) - assert out.equals(expected) + pd.testing.assert_frame_equal(out, expected, atol=1e-3) def test_run_tomtom(): diff --git a/tox.ini b/tox.ini index e3d04797..032f2c04 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,8 @@ description = Invoke pytest to run automated tests setenv = TOXINIDIR = {toxinidir} CONDA_EXE = mamba + WANDB_MODE = disabled + WANDB_API_KEY = dummy passenv = HOME SETUPTOOLS_*