From e53aef43fcc02603ff848f48133b6ce3de9db572 Mon Sep 17 00:00:00 2001 From: Michael Oviedo Date: Tue, 19 Nov 2024 20:11:10 +0000 Subject: [PATCH] remove print statements from aggregator tests Signed-off-by: Michael Oviedo --- osbenchmark/aggregator.py | 6 ++---- tests/aggregator_test.py | 13 +------------ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/osbenchmark/aggregator.py b/osbenchmark/aggregator.py index c9c22df2..98702b54 100644 --- a/osbenchmark/aggregator.py +++ b/osbenchmark/aggregator.py @@ -127,7 +127,6 @@ def build_aggregated_results(self): } for task, task_metrics in self.accumulated_results.items(): - iterations = self.accumulated_iterations.get(task, 1) aggregated_task_metrics = self.calculate_weighted_average(task_metrics, task) op_metric = { "task": task, @@ -201,10 +200,9 @@ def build_aggregated_results(self): def calculate_weighted_average(self, task_metrics: Dict[str, List[Any]], task_name: str) -> Dict[str, Any]: weighted_metrics = {} - num_executions = len(next(iter(task_metrics.values()))) - + # Get iterations for each test execution - iterations_per_execution = [self.accumulated_iterations[test_id][task_name] + iterations_per_execution = [self.accumulated_iterations[test_id][task_name] for test_id in self.test_executions.keys()] total_iterations = sum(iterations_per_execution) diff --git a/tests/aggregator_test.py b/tests/aggregator_test.py index 10bb54d8..4212e0ed 100644 --- a/tests/aggregator_test.py +++ b/tests/aggregator_test.py @@ -58,7 +58,6 @@ def test_count_iterations_for_each_op(aggregator): with patch('osbenchmark.workload.load_workload', return_value=mock_workload): aggregator.count_iterations_for_each_op(mock_test_execution) - print(f"accumulated_iterations: {aggregator.accumulated_iterations}") assert "test1" in aggregator.accumulated_iterations, "test1 not found in accumulated_iterations" assert "op1" in aggregator.accumulated_iterations["test1"], "op1 not found in accumulated_iterations for test1" assert aggregator.accumulated_iterations["test1"]["op1"] == 5 @@ -144,9 +143,7 @@ def test_aggregate(aggregator): patch.object(aggregator, 'count_iterations_for_each_op'), \ patch.object(aggregator, 'accumulate_results'), \ patch.object(aggregator, 'build_aggregated_results', return_value=mock_aggregated_results) as mock_build, \ - patch('osbenchmark.aggregator.FileTestExecutionStore') as mock_store_class, \ - patch('osbenchmark.utils.io.ensure_dir') as mock_ensure_dir, \ - patch('builtins.open', mock_open()) as mock_file: + patch('osbenchmark.aggregator.FileTestExecutionStore') as mock_store_class: mock_store = mock_store_class.return_value mock_store.store_aggregated_execution.side_effect = lambda x: print(f"Storing aggregated execution: {x}") @@ -159,17 +156,9 @@ def test_aggregate(aggregator): aggregator.aggregate() - print(f"mock_build called: {mock_build.called}") - print(f"mock_store.store_aggregated_execution called: {mock_store.store_aggregated_execution.called}") - assert mock_build.called, "build_aggregated_results was not called" mock_store.store_aggregated_execution.assert_called_once_with(mock_aggregated_results) - print(f"ensure_dir called: {mock_ensure_dir.called}") - print(f"ensure_dir call args: {mock_ensure_dir.call_args_list}") - print(f"open called: {mock_file.called}") - print(f"open call args: {mock_file.call_args_list}") - assert mock_store.store_aggregated_execution.called, "store_aggregated_execution was not called" def test_aggregated_results():