def generateManagers(resultRoot, configSpace): ts = time.strftime("%Y%m%d-%H%M%S") basepath = os.path.join(resultRoot, "incomplete", ts) finalpath = os.path.join(resultRoot, ts) pointerpath = os.path.join(resultRoot, "latest") # Set up initial results directory maybeMakedirs(basepath) incomplete = os.path.join(basepath, "incomplete") file(incomplete, "w").close() prNotice(2, "Starting results in: %s" % basepath) # Walk configurations start = time.time() for n, config in enumerate(configSpace): # Show progress now = time.time() if n > 0 and start != now: print "Time so far: %s\tETA: %s" % \ (time.strftime("%H:%M:%S", time.gmtime(now - start)), time.strftime("%H:%M:%S", time.gmtime((now - start)*(len(configSpace) - n)/n))) # Construct result path path = basepath for (cfgName, cfgVal, cfgConst) in config._values(): if cfgConst: continue path = os.path.join(path, "%s-%s" % (cfgName, cfgVal)) prNotice(1, "*** Starting configuration %d/%d (%s) ***" % \ (n+1, len(configSpace), path[len(basepath):].lstrip("/"))) m = Manager() m += ResultPath(path, noTS = True) yield (m, config) # All configurations are complete os.unlink(incomplete) os.rename(basepath, finalpath) if os.path.exists(pointerpath): os.unlink(pointerpath) try: os.symlink(ts, pointerpath) except OSError, e: print ""
def generateManagers(resultRoot, configSpace): ts = time.strftime("%Y%m%d-%H%M%S") basepath = os.path.join(resultRoot, "incomplete", ts) finalpath = os.path.join(resultRoot, ts) pointerpath = os.path.join(resultRoot, "latest") # Set up initial results directory maybeMakedirs(basepath) incomplete = os.path.join(basepath, "incomplete") file(incomplete, "w").close() prNotice(2, "Starting results in: %s" % basepath) # Walk configurations start = time.time() for n, config in enumerate(configSpace): # Show progress now = time.time() if n > 0 and start != now: print "Time so far: %s\tETA: %s" % \ (time.strftime("%H:%M:%S", time.gmtime(now - start)), time.strftime("%H:%M:%S", time.gmtime((now - start)*(len(configSpace) - n)/n))) # Construct result path path = basepath for (cfgName, cfgVal, cfgConst) in config._values(): if cfgConst: continue path = os.path.join(path, "%s-%s" % (cfgName, cfgVal)) prNotice(1, "*** Starting configuration %d/%d (%s) ***" % \ (n+1, len(configSpace), path[len(basepath):].lstrip("/"))) m = Manager() m += ResultPath(path, noTS=True) yield (m, config) # All configurations are complete os.unlink(incomplete) os.rename(basepath, finalpath) if os.path.exists(pointerpath): os.unlink(pointerpath) try: os.symlink(ts, pointerpath) except OSError, e: print ""
def ensure(self): """Ensure that the result directory exists and return its path.""" maybeMakedirs(self.__path) return self.__path