From 5f6c67d5c57b82180bced82a7954b1f5f50c7f27 Mon Sep 17 00:00:00 2001 From: Riccardo Murri Date: Mon, 5 Feb 2018 12:31:05 +0100 Subject: [PATCH] Make the new `Engine.counts()` system pass all tests. Remove the old on-demand `.stats()` in favor of the `.counts()`-based implementation. --- gc3libs/core.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/gc3libs/core.py b/gc3libs/core.py index 7b110b3b..a339460c 100755 --- a/gc3libs/core.py +++ b/gc3libs/core.py @@ -1466,7 +1466,7 @@ def transitioned(self, task, from_state, to_state): self._update(task, from_state, -1) self._update(task, to_state, +1) """ - stats_to_increment = ['total', to_state] + stats_to_increment = [to_state] if to_state == 'TERMINATED': if task.execution.returncode == 0: stats_to_increment.append('ok') @@ -2045,8 +2045,8 @@ def counts(self, only=Task): : param class only: Restrict counting to tasks of these classes. """ - assert only in self._counts - return dictproxy(self._counts[only]) + assert only in self._counts.totals + return dictproxy(self._counts.totals[only]) def stats(self, only=None): @@ -2057,17 +2057,6 @@ def stats(self, only=None): This is deprecated since GC3Pie version 2.5. """ - result = defaultdict(int) - for task in self.iter_tasks(only): - state = task.execution.state - result[state] += 1 - result['total'] += 1 - if state == 'TERMINATED': - if task.execution.exitcode == 0: - result['ok'] += 1 - else: - result['failed'] += 1 - return result warn("Deprecated method `Engine.stats()` called" " -- please use `Engine.counts()` instead", DeprecationWarning, stacklevel=2)