[Ezbench-dev] [PATCH 2/3] smartezbench: move "commits" to ["tasks"]["user"]["commits"]

Martin Peres martin.peres at linux.intel.com
Wed Mar 15 13:44:47 UTC 2017


---
 python-modules/ezbench/smartezbench.py | 35 +++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/python-modules/ezbench/smartezbench.py b/python-modules/ezbench/smartezbench.py
index e256c8f..aea406a 100644
--- a/python-modules/ezbench/smartezbench.py
+++ b/python-modules/ezbench/smartezbench.py
@@ -300,6 +300,17 @@ class SmartEzbench:
             self.state['version'] = 1
             upgraded = True
 
+        if version == 1:
+            self.__log(Criticality.II, "state: v1 -> v2: move commits to tasks->user")
+            self.state['version'] = 2
+
+            # Create a new hierarchie for tasks
+            self.state['tasks'] = dict()
+            self.state['tasks']['user'] = dict()
+            self.state['tasks']['user']['commits'] = self.state['commits']
+            del self.state['commits']
+            upgraded = True
+
         if upgraded:
             self.__save_state()
 
@@ -517,10 +528,11 @@ class SmartEzbench:
         if scm is not None:
             commit = scm.full_version_name(commit)
 
+        commits = self.state['tasks']['user']['commits']
         if rounds is None:
-            return self.state['commits'][commit]['tests'][test]['rounds']
+            return commits[commit]['tests'][test]['rounds']
 
-        return self.__task_tree_add_test__(self.state['commits'], commit, test, rounds)
+        return self.__task_tree_add_test__(commits, commit, test, rounds)
 
         # If the state was DONE, set it back to RUN
         if self.__running_mode_unlocked__(check_running=False) == RunningMode.DONE:
@@ -558,18 +570,19 @@ class SmartEzbench:
         else:
             at_least = int(at_least)
 
-        if commit not in self.state['commits']:
-            self.state['commits'][commit] = dict()
-            self.state['commits'][commit]["tests"] = dict()
+        commits = self.state['tasks']['user']['commits']
+        if commit not in commits:
+            commits[commit] = dict()
+            commits[commit]["tests"] = dict()
 
-        if test not in self.state['commits'][commit]['tests']:
-            self.state['commits'][commit]['tests'][test] = dict()
-            self.state['commits'][commit]['tests'][test]['rounds'] = 0
+        if test not in commits[commit]['tests']:
+            commits[commit]['tests'][test] = dict()
+            commits[commit]['tests'][test]['rounds'] = 0
 
-        to_add = at_least - self.state['commits'][commit]['tests'][test]['rounds']
+        to_add = at_least - commits[commit]['tests'][test]['rounds']
 
         if to_add > 0:
-            self.state['commits'][commit]['tests'][test]['rounds'] += to_add
+            commits[commit]['tests'][test]['rounds'] += to_add
             return to_add
         else:
             return 0
@@ -735,7 +748,7 @@ class SmartEzbench:
                 events_str.append(str(event))
 
             # Walk down the report and get rid of every run that has already been made!
-            task_tree = copy.deepcopy(state['commits'])
+            task_tree = copy.deepcopy(self.state['tasks']['user']['commits'])
 
             for commit in report.commits:
                 for result in commit.results.values():
-- 
2.11.1



More information about the Ezbench-dev mailing list