def run_backtest(self): print("Execution Mode: Rabbit MQ") t = Timer() t.start() try: self._run_backtest() except KeyboardInterrupt as e: quit(0) t.end() print("Total Process Execution Taken:", str(t.get()) + "s")
def start( model="gpt2", interact=False, topK=10, feed="", seed=0, mod=1, logPath="Log", enableTimer=True, enableTests=False, runs=1, probablity=20, ): Log.setPath(logPath) feedPath = os.path.join("feed", "{}.txt".format(feed)) checks(model, topK, runs, feedPath, probablity) if enableTests: runTests() return if feedPath != "": inFile = open(feedPath, "r", encoding="utf8") text = inFile.read() inFile.close() totalRunTime = None if enableTimer: t1 = Timer(enableTimer, Log) totalRunTime = 0 Log.setLevel(2) out = list() for i in range(0, runs): Log.Info("STARTING RUN {}".format(i + 1)) Log.Trace( text= "Model: {} | Interact: {} | TopK: {} | Text Path: {} | Log Path: {} | Enable Timer: {} | Run Tests: {}" .format(model, interact, topK, feed, logPath, enableTimer, enableTests)) pyRead = pyReadability(model, interact, topK, seed, mod, probablity, Log) if enableTimer: t1.start() # starts pyRead to score the inputted text. If text == null enable interactive mode pyRead.start(text) runTime = -1 if enableTimer: t1.end() runTime = t1.result() totalRunTime += runTime Log.Info("Took {} Seconds to Score".format(runTime)) seed = pyRead.getSeed() totalWords, wordsEncoded = pyRead.getEncoder().wordsEncoded() percentEncoded = round(wordsEncoded / totalWords * 100, 2) out.append([ seed, totalWords, wordsEncoded, percentEncoded, pyRead.getNormScore(), pyRead.getUnNormScore(), runTime ]) Log.Info( "Words Encoded: {} | Total Words: {} | With a score of {}%".format( wordsEncoded, totalWords, pyRead.getNormScore())) Log.Info("Took {} Seconds to Run {} tests".format(totalRunTime, runs)) fields = [ 'seed', 'total words', 'words encoded', 'percent encoded', 'Norm Score', 'Unnorm Score' 'time' ] Log.csvWriter(feed, fields, out)