Skip to content

Commit 2641906

Browse files
authored
fix failing test test_pipeline_with_documents (#506)
#505 did not work out as expected, so we need to try again. Note that this test fails **only on the main branch CI**, since it is (was) marked as `slow`. unfortunately, I can not reproduce locally. TODO: - [x] temporarily make `test_pipeline_with_documents` not slow to run it in PR CI: does not fail here either - [x] investigate further - [ ] make `test_pipeline_with_documents` slow again
1 parent 3f6fab0 commit 2641906

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/test_pipeline.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ def mock_model(monkeypatch, documents, prepared_taskmodule):
9191
@pytest.mark.slow
9292
@pytest.mark.parametrize("inplace", [False, True])
9393
def test_pipeline_with_document(documents, prepared_taskmodule, mock_model, inplace):
94-
document = documents[1]
94+
# make a copy to ensure original documents are not modified in non-inplace mode
95+
document = documents[1].copy()
96+
assert len(document.entities.predictions) == 0, "Document should not have predictions yet"
97+
9598
pipeline = PyTorchIEPipeline(model=mock_model, taskmodule=prepared_taskmodule, device=-1)
9699

97100
returned_document = pipeline(document, inplace=inplace)
@@ -111,6 +114,10 @@ def test_pipeline_with_document(documents, prepared_taskmodule, mock_model, inpl
111114
def test_pipeline_with_documents(documents, prepared_taskmodule, mock_model, inplace):
112115
# make a copy to ensure original documents are not modified in non-inplace mode
113116
documents = [doc.copy() for doc in documents]
117+
assert all(
118+
len(doc.entities.predictions) == 0 for doc in documents
119+
), "Documents should not have predictions yet"
120+
114121
pipeline = PyTorchIEPipeline(model=mock_model, taskmodule=prepared_taskmodule, device=-1)
115122

116123
returned_documents = pipeline(documents, inplace=inplace)

0 commit comments

Comments
 (0)