Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-shields committed Dec 11, 2022
1 parent 99c54cf commit 3db2c9c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/uberjob/progress/_simple_progress_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class State:
def __init__(self, start_time):
self.section_scope_mapping = {}
self.running_count = 0
self._running_section_scopes = set()
self._running_scope_states = set()
self._prev_time = start_time

def increment_total(self, section, scope, amount: int):
Expand All @@ -95,7 +95,7 @@ def increment_total(self, section, scope, amount: int):
def increment_running(self, section, scope):
self.update_weighted_elapsed()
scope_state = self.section_scope_mapping[section][scope]
self._running_section_scopes.add(scope_state)
self._running_scope_states.add(scope_state)
scope_state.running += 1
self.running_count += 1

Expand All @@ -105,7 +105,7 @@ def increment_completed(self, section, scope):
scope_state.running -= 1
self.running_count -= 1
if not scope_state.running:
self._running_section_scopes.remove(scope_state)
self._running_scope_states.remove(scope_state)
scope_state.completed += 1

def increment_failed(self, section, scope):
Expand All @@ -114,15 +114,15 @@ def increment_failed(self, section, scope):
scope_state.running -= 1
self.running_count -= 1
if not scope_state.running:
self._running_section_scopes.remove(scope_state)
self._running_scope_states.remove(scope_state)
scope_state.failed += 1

def update_weighted_elapsed(self):
t = time.time()
if self.running_count:
elapsed = t - self._prev_time
multiplier = elapsed / self.running_count
for scope_state in self._running_section_scopes:
for scope_state in self._running_scope_states:
scope_state.weighted_elapsed += scope_state.running * multiplier
self._prev_time = t

Expand Down

0 comments on commit 3db2c9c

Please sign in to comment.