-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Alberto Veneri <[email protected]> Co-authored-by: Craig Macdonald <[email protected]>
- Loading branch information
1 parent
40e5d02
commit 4f89605
Showing
4 changed files
with
242 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9', '3.10'] | ||
java: [11] | ||
os: ['ubuntu-latest'] | ||
architecture: ['x64'] | ||
terrier: ['snapshot'] | ||
|
||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Setup java | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
architecture: ${{ matrix.architecture }} | ||
|
||
- name: Install Terrier snapshot | ||
if: matrix.terrier == '5.4-SNAPSHOT' | ||
run: | | ||
git clone https://github.com/terrier-org/terrier-core.git | ||
cd terrier-core | ||
mvn -B -DskipTests install | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install git+https://github.com/naver/splade.git | ||
pip install -r requirements.txt | ||
pip install --timeout=120 . | ||
pip install pytest | ||
- name: All unit tests | ||
env: | ||
TERRIER_VERSION: ${{ matrix.terrier }} | ||
run: | | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import unittest | ||
import pandas as pd | ||
import tempfile | ||
class TestBasic(unittest.TestCase): | ||
|
||
def setUp(self): | ||
import pyterrier as pt | ||
if not pt.started(): | ||
pt.init() | ||
import pyt_splade | ||
self.factory = pyt_splade.SpladeFactory(device='cpu') | ||
|
||
def test_scorer(self): | ||
df = self.factory.scorer()(pd.DataFrame([ | ||
{'qid': '0', 'query': 'chemical reactions', 'docno' : 'd1', 'text' : 'hello there'}, | ||
{'qid': '0', 'query': 'chemical reactions', 'docno' : 'd2', 'text' : 'chemistry society'}, | ||
{'qid': '1', 'query': 'hello', 'docno' : 'd1', 'text' : 'hello there'}, | ||
])) | ||
self.assertAlmostEqual(0., df['score'][0]) | ||
self.assertAlmostEqual(11.133593, df['score'][1], places=5) | ||
self.assertAlmostEqual(17.566324, df['score'][2], places=5) | ||
self.assertEqual('0', df['qid'][0]) | ||
self.assertEqual('0', df['qid'][1]) | ||
self.assertEqual('1', df['qid'][2]) | ||
self.assertEqual('d1', df['docno'][0]) | ||
self.assertEqual('d2', df['docno'][1]) | ||
self.assertEqual('d1', df['docno'][2]) | ||
self.assertEqual(1, df['rank'][0]) | ||
self.assertEqual(0, df['rank'][1]) | ||
self.assertEqual(0, df['rank'][2]) |