Skip to content

Commit a23f42c

Browse files
committed
ensure that predictions are empty before passing to the pipeline
1 parent 3f71746 commit a23f42c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/test_pipeline.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def mock_model(monkeypatch, documents, prepared_taskmodule):
9292
def test_pipeline_with_document(documents, prepared_taskmodule, mock_model, inplace):
9393
# make a copy to ensure original documents are not modified in non-inplace mode
9494
document = documents[1].copy()
95+
assert len(document.entities.predictions) == 0, "Document should not have predictions yet"
96+
9597
pipeline = PyTorchIEPipeline(model=mock_model, taskmodule=prepared_taskmodule, device=-1)
9698

9799
returned_document = pipeline(document, inplace=inplace)
@@ -110,6 +112,10 @@ def test_pipeline_with_document(documents, prepared_taskmodule, mock_model, inpl
110112
def test_pipeline_with_documents(documents, prepared_taskmodule, mock_model, inplace):
111113
# make a copy to ensure original documents are not modified in non-inplace mode
112114
documents = [doc.copy() for doc in documents]
115+
assert all(
116+
len(doc.entities.predictions) == 0 for doc in documents
117+
), "Documents should not have predictions yet"
118+
113119
pipeline = PyTorchIEPipeline(model=mock_model, taskmodule=prepared_taskmodule, device=-1)
114120

115121
returned_documents = pipeline(documents, inplace=inplace)

0 commit comments

Comments
 (0)