mirror of https://gitlab.com/bashrc2/epicyon
Loading and saving fitness metrics
parent
4f38fd4e29
commit
2bd1bef5b4
10
daemon.py
10
daemon.py
|
@ -347,6 +347,7 @@ from context import getIndividualPostContext
|
||||||
from speaker import getSSMLbox
|
from speaker import getSSMLbox
|
||||||
from city import getSpoofedCity
|
from city import getSpoofedCity
|
||||||
from fitnessFunctions import fitnessPerformance
|
from fitnessFunctions import fitnessPerformance
|
||||||
|
from fitnessFunctions import fitnessThread
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
@ -16917,7 +16918,10 @@ def runDaemon(defaultReplyIntervalHours: int,
|
||||||
assert not scanThemesForScripts(baseDir)
|
assert not scanThemesForScripts(baseDir)
|
||||||
|
|
||||||
# fitness metrics
|
# fitness metrics
|
||||||
|
fitnessFilename = baseDir + '/accounts/fitness.json'
|
||||||
httpd.fitness = {}
|
httpd.fitness = {}
|
||||||
|
if os.path.isfile(fitnessFilename):
|
||||||
|
httpd.fitness = loadJson(fitnessFilename)
|
||||||
|
|
||||||
# initialize authorized fetch key
|
# initialize authorized fetch key
|
||||||
httpd.signingPrivateKeyPem = None
|
httpd.signingPrivateKeyPem = None
|
||||||
|
@ -17223,6 +17227,12 @@ def runDaemon(defaultReplyIntervalHours: int,
|
||||||
print('Creating shared item files directory')
|
print('Creating shared item files directory')
|
||||||
os.mkdir(baseDir + '/sharefiles')
|
os.mkdir(baseDir + '/sharefiles')
|
||||||
|
|
||||||
|
print('Creating fitness thread')
|
||||||
|
httpd.thrFitness = \
|
||||||
|
threadWithTrace(target=fitnessThread,
|
||||||
|
args=(baseDir, httpd.fitness), daemon=True)
|
||||||
|
httpd.thrFitness.start()
|
||||||
|
|
||||||
print('Creating cache expiry thread')
|
print('Creating cache expiry thread')
|
||||||
httpd.thrCache = \
|
httpd.thrCache = \
|
||||||
threadWithTrace(target=expireCache,
|
threadWithTrace(target=expireCache,
|
||||||
|
|
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
||||||
__module_group__ = "Core"
|
__module_group__ = "Core"
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
from utils import saveJson
|
||||||
|
|
||||||
|
|
||||||
def fitnessPerformance(startTime, fitnessState: {},
|
def fitnessPerformance(startTime, fitnessState: {},
|
||||||
|
@ -37,3 +38,13 @@ def fitnessPerformance(startTime, fitnessState: {},
|
||||||
print('FITNESS: performance/' + fitnessId + '/' +
|
print('FITNESS: performance/' + fitnessId + '/' +
|
||||||
watchPoint + '/' +
|
watchPoint + '/' +
|
||||||
str(fitnessState['performance'][fitnessId][watchPoint]))
|
str(fitnessState['performance'][fitnessId][watchPoint]))
|
||||||
|
|
||||||
|
|
||||||
|
def fitnessThread(baseDir: str, fitness: {}):
|
||||||
|
"""Thread used to save fitness function scores
|
||||||
|
"""
|
||||||
|
fitnessFilename = baseDir + '/accounts/fitness.json'
|
||||||
|
while True:
|
||||||
|
# every 10 mins
|
||||||
|
time.sleep(60 * 10)
|
||||||
|
saveJson(fitness, fitnessFilename)
|
||||||
|
|
1
tests.py
1
tests.py
|
@ -4530,6 +4530,7 @@ def _testFunctions():
|
||||||
'runNewswireWatchdog',
|
'runNewswireWatchdog',
|
||||||
'runFederatedSharesWatchdog',
|
'runFederatedSharesWatchdog',
|
||||||
'runFederatedSharesDaemon',
|
'runFederatedSharesDaemon',
|
||||||
|
'fitnessThread',
|
||||||
'threadSendPost',
|
'threadSendPost',
|
||||||
'sendToFollowers',
|
'sendToFollowers',
|
||||||
'expireCache',
|
'expireCache',
|
||||||
|
|
Loading…
Reference in New Issue