util/guid.py merged into ec.py that is the only one using it
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 4 Nov 2015 15:57:22 +0000 (16:57 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 4 Nov 2015 15:59:13 +0000 (16:59 +0100)
all-tests6 does all-tests2 and then all-tests3

all-tests
src/nepi/execution/ec.py
src/nepi/util/guid.py [deleted file]

index 404f82a..5ede05d 100755 (executable)
--- a/all-tests
+++ b/all-tests
 # cannot safely be run together; need to check the nepi exp_ids
 # used more closely
 
+DIRNAME=$(dirname $0)
 COMMAND=$(basename $0)
 
+if echo $COMMAND | grep -q 6; then
+    $DIRNAME/all-tests2; $DIRNAME/all-tests3; exit
+fi
+
 PYTHON=python
 version=2
 echo $COMMAND | grep -q 3 && { PYTHON=python3; version=3; }
@@ -21,6 +26,7 @@ hash=$(git log -n 1 | head -1 | sed -e 's,commit ,,' -e 's,\(........\).*,\1,')
 
 # compute output file name
 output="zz.$hash.py$version"
+latest="zz.latest.py$version"
 
 # if there is any pending change, use another name
 is_pristine=""
@@ -54,6 +60,9 @@ function all_tests () {
 # the current code for analyzing the output is very basic
 # this needs to be checked manually for some time
 
+# create a 'latest' symlink
+ln -f -s $output $latest
+
 all_tests >& $output
 retcod=$?
 
index c403d79..f282ac6 100644 (file)
@@ -18,7 +18,6 @@
 
 from six import next
 
-from nepi.util import guid
 from nepi.util.parallel import ParallelRun
 from nepi.util.timefuncs import tnow, tdiffsec, stabsformat, tsformat 
 from nepi.execution.resource import ResourceFactory, ResourceAction, \
@@ -103,6 +102,23 @@ class ECState(object):
     RELEASED = 3
     TERMINATED = 4
 
+# historical note: this class used to be in util/guid.py but is used only here
+# FIXME: This class is not thread-safe. Should it be made thread-safe?
+class GuidGenerator(object):
+    def __init__(self):
+        self._last_guid = 0
+
+    # historical note: this used to be called `next`
+    # which confused 2to3 - and me - while it has
+    # nothing to do at all with the iteration protocol
+    def generate(self, guid = None):
+        if guid == None:
+            guid = self._last_guid + 1
+
+        self._last_guid = self._last_guid if guid <= self._last_guid else guid
+
+        return guid
+
 class ExperimentController(object):
     """
     .. note::
@@ -225,7 +241,7 @@ class ExperimentController(object):
         self._persist = persist
 
         # generator of globally unique ids
-        self._guid_generator = guid.GuidGenerator()
+        self._guid_generator = GuidGenerator()
         
         # Resource managers
         self._resources = dict()
@@ -242,7 +258,7 @@ class ExperimentController(object):
         self._groups = dict()
 
         # generator of globally unique id for groups
-        self._group_id_generator = guid.GuidGenerator()
+        self._group_id_generator = GuidGenerator()
 
         # Flag to stop processing thread
         self._stop = False
@@ -590,7 +606,7 @@ class ExperimentController(object):
         """
         # Get next available guid
         # xxx_next_hiccup
-        guid = self._guid_generator.next(guid)
+        guid = self._guid_generator.generate(guid)
         
         # Instantiate RM
         rm = ResourceFactory.create(rtype, self, guid)
@@ -989,7 +1005,7 @@ class ExperimentController(object):
         if not group:
             new_group = True
             # xxx_next_hiccup
-            group = self._group_id_generator.next()
+            group = self._group_id_generator.generate()
 
         if group not in self._groups:
             self._groups[group] = []
diff --git a/src/nepi/util/guid.py b/src/nepi/util/guid.py
deleted file mode 100644 (file)
index 4585211..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-#    NEPI, a framework to manage network experiments
-#    Copyright (C) 2013 INRIA
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License version 2 as
-#    published by the Free Software Foundation;
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
-
-# FIXME: This class is not thread-safe. 
-# Should it be made thread-safe?
-class GuidGenerator(object):
-    def __init__(self):
-        self._last_guid = 0
-
-    # xxx_next_hiccup - this is used as a plain function, and only in ec.py
-    def next(self, guid = None):
-        if guid == None:
-            guid = self._last_guid + 1
-
-        self._last_guid = self._last_guid if guid <= self._last_guid else guid
-
-        return guid
-