Refresh backend only hit_id change
This commit is contained in:
parent
260c184a36
commit
8fbf1ead9e
2 changed files with 47 additions and 11 deletions
|
@ -38,16 +38,14 @@ class CentralManagement():
|
||||||
self.isRunning = threading.Event()
|
self.isRunning = threading.Event()
|
||||||
self.isScanning = threading.Event()
|
self.isScanning = threading.Event()
|
||||||
self.scanLock = threading.Lock()
|
self.scanLock = threading.Lock()
|
||||||
|
self.notPaused = threading.Event()
|
||||||
|
|
||||||
|
|
||||||
def loadConfig(self, filename, args):
|
def loadConfig(self, filename, args):
|
||||||
with open(filename, 'r') as fp:
|
self.configFile = filename
|
||||||
self.logger.debug('Load config from {}'.format(filename))
|
self.args = args
|
||||||
self.config = yaml.safe_load(fp)
|
|
||||||
|
|
||||||
if args.no_plotter:
|
self.reloadConfig()
|
||||||
self.config['dummy_plotter'] = True
|
|
||||||
self.config['for_real'] = args.for_real
|
|
||||||
|
|
||||||
varDb = os.path.join(
|
varDb = os.path.join(
|
||||||
# self.config['storage_dir'],
|
# self.config['storage_dir'],
|
||||||
|
@ -56,13 +54,22 @@ class CentralManagement():
|
||||||
self.store = HITStore.Store(varDb, logLevel=logging.DEBUG if self.debug else logging.INFO)
|
self.store = HITStore.Store(varDb, logLevel=logging.DEBUG if self.debug else logging.INFO)
|
||||||
|
|
||||||
self.logger.debug(f"Loaded configuration: {self.config}")
|
self.logger.debug(f"Loaded configuration: {self.config}")
|
||||||
# self.amazon =
|
|
||||||
# self.server
|
def reloadConfig(self):
|
||||||
|
# reload config settings
|
||||||
|
with open(self.configFile, 'r') as fp:
|
||||||
|
self.logger.debug('Load config from {}'.format(self.configFile))
|
||||||
|
self.config = yaml.safe_load(fp)
|
||||||
|
|
||||||
|
if self.args.no_plotter:
|
||||||
|
self.config['dummy_plotter'] = True
|
||||||
|
self.config['for_real'] = self.args.for_real
|
||||||
|
|
||||||
|
|
||||||
# self.panopticon = Panopticon(self, self.config, self.voiceStorage)
|
# self.panopticon = Panopticon(self, self.config, self.voiceStorage)
|
||||||
def start(self):
|
def start(self):
|
||||||
self.isRunning.set()
|
self.isRunning.set()
|
||||||
|
self.notPaused.set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -272,6 +279,11 @@ class CentralManagement():
|
||||||
self.expireCurrentHit() # expire hit if it is there
|
self.expireCurrentHit() # expire hit if it is there
|
||||||
|
|
||||||
self.server.statusPage.reset()
|
self.server.statusPage.reset()
|
||||||
|
self.reloadConfig() # reload new config values if they are set
|
||||||
|
|
||||||
|
# self.notPaused.wait()
|
||||||
|
|
||||||
|
|
||||||
self.currentHit = self.store.createHIT()
|
self.currentHit = self.store.createHIT()
|
||||||
self.store.currentHit = self.currentHit
|
self.store.currentHit = self.currentHit
|
||||||
|
|
||||||
|
@ -280,7 +292,9 @@ class CentralManagement():
|
||||||
question = open(self.config['amazon']['task_xml'], mode='r').read().replace("{HIT_NR}",str(self.currentHit.id))
|
question = open(self.config['amazon']['task_xml'], mode='r').read().replace("{HIT_NR}",str(self.currentHit.id))
|
||||||
estimatedHitDuration = self.store.getEstimatedHitDuration()
|
estimatedHitDuration = self.store.getEstimatedHitDuration()
|
||||||
|
|
||||||
fee = max(.25, (self.config['hour_rate_aim']/3600.) * estimatedHitDuration)
|
|
||||||
|
# set minimum rate, if they take longer we increase the pay
|
||||||
|
fee = max(self.config['minimum_fee'], (self.config['hour_rate_aim']/3600.) * estimatedHitDuration)
|
||||||
self.currentHit.fee = fee
|
self.currentHit.fee = fee
|
||||||
self.logger.info(f"Based on average duration of {estimatedHitDuration} fee should be {fee}/hit to get hourly rate of {self.config['hour_rate_aim']}")
|
self.logger.info(f"Based on average duration of {estimatedHitDuration} fee should be {fee}/hit to get hourly rate of {self.config['hour_rate_aim']}")
|
||||||
new_hit = self.mturk.create_hit(
|
new_hit = self.mturk.create_hit(
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="stylesheet" type="text/css" href="backend.css" />
|
<link rel="stylesheet" type="text/css" href="backend.css" />
|
||||||
<meta http-equiv="refresh" content="20">
|
<!-- <meta http-equiv="refresh" content="20">-->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -28,5 +28,27 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src='/worker_specs/reconnecting-websocket.min.js'></script>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
|
||||||
|
let ws = new ReconnectingWebSocket('ws://localhost:8888/status/ws')
|
||||||
|
|
||||||
|
|
||||||
|
ws.addEventListener('open', () => {
|
||||||
|
// ws.send('hi server')
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
ws.addEventListener('message', (event) => {
|
||||||
|
console.log('message: ' + event.data)
|
||||||
|
|
||||||
|
let data = JSON.parse(event.data)
|
||||||
|
if(data.property === 'hit_id') {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue