From b1e31a4352ff45a73b66cd771c09c808d0e3e90e Mon Sep 17 00:00:00 2001 From: Daniel Shields Date: Sun, 11 Dec 2022 12:45:45 -0600 Subject: [PATCH 1/3] small implification to simple progress observer --- src/uberjob/progress/_simple_progress_observer.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/uberjob/progress/_simple_progress_observer.py b/src/uberjob/progress/_simple_progress_observer.py index 31483df..1a2b641 100644 --- a/src/uberjob/progress/_simple_progress_observer.py +++ b/src/uberjob/progress/_simple_progress_observer.py @@ -96,7 +96,7 @@ def increment_running(self, section, scope): self.update_weighted_elapsed() scope_state = self.section_scope_mapping[section][scope] if not scope_state.running: - self._running_section_scopes.add((section, scope)) + self._running_section_scopes.add(scope_state) scope_state.running += 1 self.running_count += 1 @@ -106,7 +106,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((section, scope)) + self._running_section_scopes.remove(scope_state) scope_state.completed += 1 def increment_failed(self, section, scope): @@ -115,7 +115,7 @@ def increment_failed(self, section, scope): scope_state.running -= 1 self.running_count -= 1 if not scope_state.running: - self._running_section_scopes.remove((section, scope)) + self._running_section_scopes.remove(scope_state) scope_state.failed += 1 def update_weighted_elapsed(self): @@ -123,8 +123,7 @@ def update_weighted_elapsed(self): if self.running_count: elapsed = t - self._prev_time multiplier = elapsed / self.running_count - for section, scope in self._running_section_scopes: - scope_state = self.section_scope_mapping[section][scope] + for scope_state in self._running_section_scopes: scope_state.weighted_elapsed += scope_state.running * multiplier self._prev_time = t From 99c54cf3198894a836dce466567bf8fb421af156 Mon Sep 17 00:00:00 2001 From: Daniel Shields Date: Sun, 11 Dec 2022 12:48:03 -0600 Subject: [PATCH 2/3] update --- src/uberjob/progress/_simple_progress_observer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uberjob/progress/_simple_progress_observer.py b/src/uberjob/progress/_simple_progress_observer.py index 1a2b641..8b653a6 100644 --- a/src/uberjob/progress/_simple_progress_observer.py +++ b/src/uberjob/progress/_simple_progress_observer.py @@ -95,8 +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] - if not scope_state.running: - self._running_section_scopes.add(scope_state) + self._running_section_scopes.add(scope_state) scope_state.running += 1 self.running_count += 1 From 3db2c9c199bb6253c9d6d4f0d5841ad8fbd8f9b5 Mon Sep 17 00:00:00 2001 From: Daniel Shields Date: Sun, 11 Dec 2022 12:52:38 -0600 Subject: [PATCH 3/3] update --- src/uberjob/progress/_simple_progress_observer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uberjob/progress/_simple_progress_observer.py b/src/uberjob/progress/_simple_progress_observer.py index 8b653a6..eaa1c8a 100644 --- a/src/uberjob/progress/_simple_progress_observer.py +++ b/src/uberjob/progress/_simple_progress_observer.py @@ -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): @@ -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 @@ -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): @@ -114,7 +114,7 @@ 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): @@ -122,7 +122,7 @@ def update_weighted_elapsed(self): 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