def run(self): try: logging.debug('upload ' + str(self.upload_id) + ' start') pipe_listener = PipeListener(self.__pipe, self.on_pipe_data) pipe_listener.start() self.state = 'login' elog = ELog(self.elog_type) self.__raise_for_cancel() if elog.login(self.login_data): self.__raise_for_cancel() self.state = 'upload' if elog.upload(self.file, self.params, callback=self.upload_callback,\ cancel_event=self.__cancel_event): self.state = 'success' else: self.state = 'upload failed' else: self.state = 'login failed' except CancelledError: self.state = 'cancelled' except Exception: self.state = 'internal error' logging.exception('Upload thread error') finally: self.__pipe.send(self.state)
def test_upload(): accounts = DB.execute("select * from accounts where login = %(login)s", {'login': LOGIN}, keys=True) for account in accounts: elog_type = account['elog'] elog = ELog(elog_type) assert elog.login(account['login_data']) if elog_type in DATA: elog.upload(FILE, DATA[elog_type], upload_callback)
def log_train_metrics(self, loss, acc, completed_batch, worker=0): acc = acc/100.0 self.gs += 1 with EMetrics.open() as em: em.record(EMetrics.TEST_GROUP,completed_batch,{'loss': loss, 'accuracy': acc}) with ELog.open() as log: log.recordTrain("Train", completed_batch, self.gs, loss, acc, worker)
def account(): """checks login data and returns user data with token""" req_data = request.get_json() account_key = splice_params(req_data, 'login', 'elog') if request.method == 'POST': elog = ELog(account_key['elog']) status = False try: status = bool(elog.login(req_data['login_data'])) except Exception: logging.exception(req_data['elog'] + ' login error') account_data = splice_params(req_data, 'login_data') account_data['status'] = status if not DB.param_upsert('accounts', account_key, account_data): raise Exception('Account update or creation failed') return jsonify({'status': status}) else: if not DB.param_delete('accounts', account_key): raise Exception('Account delete failed') return ok_response()
def log_message(self, message): with ELog.open() as log: log.recordText(message)
def log_test_metrics(self, loss, acc, completed_batch, worker=0): acc = acc / 100.0 with ELog.open() as log: log.recordTest("Test", loss, acc, worker)