Skip to content

Commit

Permalink
Make the new Engine.counts() system pass all tests.
Browse files Browse the repository at this point in the history
Remove the old on-demand `.stats()` in favor of the `.counts()`-based
implementation.
  • Loading branch information
riccardomurri committed Mar 8, 2018
1 parent 03ce2e2 commit 5f6c67d
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions gc3libs/core.py
Expand Up @@ -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')
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit 5f6c67d

Please sign in to comment.