Skip to content

Commit

Permalink
Debug CI failures
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayP13 committed Dec 25, 2023
1 parent 3e47369 commit 3f61037
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ jobs:
with:
path: .venv/prod
key: test-venv-prod-${{ runner.os }}-${{ hashFiles('src/requirements-dev.txt', 'src/requirements-test.txt', 'src/requirements.txt', 'src/requirements-cpu.txt', 'src/requirements-accelerator-device.txt') }}
- name: PYVERSION
run: python3 --version
- name: SUDO PYVERSION
run: sudo -H -E env "PATH=$PATH" python3 --version
- name: Run tests
run: sudo -H -E env "PATH=$PATH" ./run.sh -vvvv --durations=0 --junitxml=./test.xml --maxfail=2
env:
Expand Down
16 changes: 8 additions & 8 deletions src/tests/embedders/test_embedders.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def test_run(self, create_datadreamer):
results = model.run(texts=["A test sentence.", "Another test sentence."])
assert isinstance(results, list)
assert len(results[0]) == 768
assert results[0][0] == pytest.approx(0.042875204)
assert results[1][0] == pytest.approx(0.027576972)
assert results[0][0] == pytest.approx(0.042875204, 0.0001)
assert results[1][0] == pytest.approx(0.027576972, 0.0001)

# Simple test with instruction
model = SentenceTransformersEmbedder("all-mpnet-base-v2")
Expand All @@ -47,8 +47,8 @@ def test_run(self, create_datadreamer):
)
assert isinstance(results, list)
assert len(results[0]) == 768
assert results[0][0] == pytest.approx(0.005033156)
assert results[1][0] == pytest.approx(0.011253911)
assert results[0][0] == pytest.approx(0.005033156, 0.0001)
assert results[1][0] == pytest.approx(0.011253911, 0.0001)

# Test truncate
with pytest.raises(ValueError):
Expand Down Expand Up @@ -82,8 +82,8 @@ def test_instructor_embedding(self, create_datadreamer):
)
assert isinstance(results, list)
assert len(results[0]) == 768
assert results[0][0] == pytest.approx(-0.017620174)
assert results[1][0] == pytest.approx(-0.008969681)
assert results[0][0] == pytest.approx(-0.017620174, 0.0001)
assert results[1][0] == pytest.approx(-0.008969681, 0.0001)


class TestParallelEmbedder:
Expand All @@ -101,8 +101,8 @@ def test_run(self, create_datadreamer):
)
assert isinstance(results, list)
assert len(results[0]) == 768
assert results[0][0] == pytest.approx(0.042875204)
assert results[1][0] == pytest.approx(0.027576972)
assert results[0][0] == pytest.approx(0.042875204, 0.0001)
assert results[1][0] == pytest.approx(0.027576972, 0.0001)

# Test return_generator=True
results = parallel_model.run(
Expand Down
60 changes: 48 additions & 12 deletions src/tests/retrievers/test_retrievers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ def test_index(self, create_datadreamer, caplog):
{
"indices": [1, 0],
"texts": ["Cats have fur.", "Dogs bark loudly."],
"scores": [pytest.approx(0.81670237), pytest.approx(0.1688818)],
"scores": [
pytest.approx(0.81670237, 0.0001),
pytest.approx(0.1688818, 0.0001),
],
},
{
"indices": [2, 1],
"texts": ["Steve Jobs founded Apple.", "Cats have fur."],
"scores": [pytest.approx(0.7169484), pytest.approx(0.1270127)],
"scores": [
pytest.approx(0.7169484, 0.0001),
pytest.approx(0.1270127, 0.0001),
],
},
]
logs = [rec.message for rec in caplog.records]
Expand Down Expand Up @@ -116,12 +122,18 @@ def test_index(self, create_datadreamer, caplog):
{
"indices": [2, 1],
"texts": ["Steve Jobs founded Apple.", "Cats have fur."],
"scores": [pytest.approx(0.7169484), pytest.approx(0.1270127)],
"scores": [
pytest.approx(0.7169484, 0.0001),
pytest.approx(0.1270127, 0.0001),
],
},
{
"indices": [1, 0],
"texts": ["Cats have fur.", "Dogs bark loudly."],
"scores": [pytest.approx(0.81670237), pytest.approx(0.1688818)],
"scores": [
pytest.approx(0.81670237, 0.0001),
pytest.approx(0.1688818, 0.0001),
],
},
]
logs = [rec.message for rec in caplog.records]
Expand Down Expand Up @@ -159,12 +171,18 @@ def test_in_memory_index(self, create_datadreamer, caplog):
{
"indices": [1, 0],
"texts": ["Cats have fur.", "Dogs bark loudly."],
"scores": [pytest.approx(0.81670237), pytest.approx(0.1688818)],
"scores": [
pytest.approx(0.81670237, 0.0001),
pytest.approx(0.1688818, 0.0001),
],
},
{
"indices": [2, 1],
"texts": ["Steve Jobs founded Apple.", "Cats have fur."],
"scores": [pytest.approx(0.7169484), pytest.approx(0.1270127)],
"scores": [
pytest.approx(0.7169484, 0.0001),
pytest.approx(0.1270127, 0.0001),
],
},
]
logs = [rec.message for rec in caplog.records]
Expand All @@ -185,12 +203,18 @@ def test_in_memory_index(self, create_datadreamer, caplog):
{
"indices": [2, 1],
"texts": ["Steve Jobs founded Apple.", "Cats have fur."],
"scores": [pytest.approx(0.7169484), pytest.approx(0.1270127)],
"scores": [
pytest.approx(0.7169484, 0.0001),
pytest.approx(0.1270127, 0.0001),
],
},
{
"indices": [1, 0],
"texts": ["Cats have fur.", "Dogs bark loudly."],
"scores": [pytest.approx(0.81670237), pytest.approx(0.1688818)],
"scores": [
pytest.approx(0.81670237, 0.0001),
pytest.approx(0.1688818, 0.0001),
],
},
]
logs = [rec.message for rec in caplog.records]
Expand Down Expand Up @@ -225,12 +249,18 @@ def test_run(self, create_datadreamer):
{
"indices": [1, 0],
"texts": ["Cats have fur.", "Dogs bark loudly."],
"scores": [pytest.approx(0.84728813), pytest.approx(0.70916176)],
"scores": [
pytest.approx(0.84728813, 0.0001),
pytest.approx(0.70916176, 0.0001),
],
},
{
"indices": [2, 0],
"texts": ["Steve Jobs founded Apple.", "Dogs bark loudly."],
"scores": [pytest.approx(0.8433093), pytest.approx(0.570959)],
"scores": [
pytest.approx(0.8433093, 0.0001),
pytest.approx(0.570959, 0.0001),
],
},
]

Expand Down Expand Up @@ -289,12 +319,18 @@ def test_run(self, create_datadreamer):
{
"indices": [1, 0],
"texts": ["Cats have fur.", "Dogs bark loudly."],
"scores": [pytest.approx(0.81670237), pytest.approx(0.1688818)],
"scores": [
pytest.approx(0.81670237, 0.0001),
pytest.approx(0.1688818, 0.0001),
],
},
{
"indices": [2, 1],
"texts": ["Steve Jobs founded Apple.", "Cats have fur."],
"scores": [pytest.approx(0.7169484), pytest.approx(0.1270127)],
"scores": [
pytest.approx(0.7169484, 0.0001),
pytest.approx(0.1270127, 0.0001),
],
},
]

Expand Down

0 comments on commit 3f61037

Please sign in to comment.