From 8fbf1ead9ebe6b3e21d536092169d3e6d2f9acb6 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Mon, 4 Nov 2019 09:24:37 +0100 Subject: [PATCH] Refresh backend only hit_id change --- sorteerhoed/central_management.py | 34 ++++++++++++++++++++++--------- www/backend.html | 24 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/sorteerhoed/central_management.py b/sorteerhoed/central_management.py index baecde6..f44922b 100644 --- a/sorteerhoed/central_management.py +++ b/sorteerhoed/central_management.py @@ -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( diff --git a/www/backend.html b/www/backend.html index f8e297b..62b24dc 100644 --- a/www/backend.html +++ b/www/backend.html @@ -3,7 +3,7 @@ - + @@ -28,5 +28,27 @@ + + +