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.isScanning = threading.Event()
|
||||
self.scanLock = threading.Lock()
|
||||
self.notPaused = threading.Event()
|
||||
|
||||
|
||||
def loadConfig(self, filename, args):
|
||||
with open(filename, 'r') as fp:
|
||||
self.logger.debug('Load config from {}'.format(filename))
|
||||
self.config = yaml.safe_load(fp)
|
||||
|
||||
if args.no_plotter:
|
||||
self.config['dummy_plotter'] = True
|
||||
self.config['for_real'] = args.for_real
|
||||
self.configFile = filename
|
||||
self.args = args
|
||||
|
||||
self.reloadConfig()
|
||||
|
||||
varDb = os.path.join(
|
||||
# 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.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)
|
||||
def start(self):
|
||||
self.isRunning.set()
|
||||
self.notPaused.set()
|
||||
|
||||
try:
|
||||
|
||||
|
@ -272,6 +279,11 @@ class CentralManagement():
|
|||
self.expireCurrentHit() # expire hit if it is there
|
||||
|
||||
self.server.statusPage.reset()
|
||||
self.reloadConfig() # reload new config values if they are set
|
||||
|
||||
# self.notPaused.wait()
|
||||
|
||||
|
||||
self.currentHit = self.store.createHIT()
|
||||
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))
|
||||
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.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(
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="backend.css" />
|
||||
<meta http-equiv="refresh" content="20">
|
||||
<!-- <meta http-equiv="refresh" content="20">-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -28,5 +28,27 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</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>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue