Skip to content

Commit

Permalink
add deep validator for pipeline result
Browse files Browse the repository at this point in the history
  • Loading branch information
djkhl committed Jun 27, 2024
1 parent eda6965 commit cbbeae7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion logprep/framework/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ class PipelineResult:
"""Result object to be returned after processing the event.
It contains all generated data and includes errors and warnings."""

results: List[ProcessorResult] = attrs.field(validator=attrs.validators.instance_of(list))
results: List[ProcessorResult] = attrs.field(
validator=[
attrs.validators.instance_of(list),
attrs.validators.deep_iterable(
member_validator=attrs.validators.instance_of(ProcessorResult)
),
]
)

def __iter__(self):
return iter(self.results)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/framework/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_not_empty_documents_are_stored_in_the_output(self, _):

def test_empty_documents_are_not_stored_in_the_output(self, _):
self.pipeline.process_event = mock.MagicMock(
side_effect=lambda x: (x.clear() or [ProcessorResult(name="")])
side_effect=lambda x: x.clear() or [ProcessorResult(name="")]
)
self.pipeline._setup()
self.pipeline._input.get_next.return_value = ({"message": "test"}, None)
Expand Down

0 comments on commit cbbeae7

Please sign in to comment.