Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def startProxy(self):
logging_real.info('Starting MindsDB webserver ... ')
app = self.startWebServer()
print('aaaaaa')
logging_real.info('Starting MindsDB Logging websocket server on {config}'.format(config=config.LOGGING_WEBSOCKET_URL))
port = int(config.LOGGING_WEBSOCKET_URL.split(':')[-1])
sio = self.startWebSocketServer()
app = socketio.Middleware(sio, app)
# deploy as an eventlet WSGI server
#app.run()
eventlet.wsgi.server(eventlet.listen(('', port)), app)
def root():
print('aaaaa')
r = open('static/index.html')
vars_to_expose = ['WEBSOCKET_URL', 'LOGGING_WEBSOCKET_URL']
text = r.read()
config_vars = json.dumps({var_name: value for var_name, value in vars(config).items() if var_name in vars_to_expose})
text = text.format(ts_var=time.time(), config_vars=config_vars)
return text
def __init__(self):
self._mongo = MongoClient(CONFIG.MONGO_SERVER_HOST)
self._collection = self._mongo.mindsdb[self._entity_name]
self.setup()
def __init__(self):
self._mongo = TinyMongoClient(CONFIG.LOCALSTORE_PATH)
try:
self._collection = self._mongo.mindsdb[self._entity_name]
except:
logging.error('No collection will be found, db corrupted, truncating it')
shutil.rmtree(CONFIG.LOCALSTORE_PATH)
raise ValueError('MindsDB local document store corruped. No other way to put this, trained model data will be lost')
self.setup()
def __init__(self):
self._mongo = TinyMongoClient(CONFIG.LOCALSTORE_PATH)
try:
self._collection = self._mongo.mindsdb[self._entity_name]
except:
logging.error('No collection will be found, db corrupted, truncating it')
shutil.rmtree(CONFIG.LOCALSTORE_PATH)
raise ValueError('MindsDB local document store corruped. No other way to put this, trained model data will be lost')
self.setup()
def storeTorchObject(object, id = None):
if id is None:
# generate a random uuid
id = str(uuid.uuid1())
# create if it does not exist
if not os.path.exists(CONFIG.MINDSDB_STORAGE_PATH):
os.makedirs(CONFIG.MINDSDB_STORAGE_PATH)
# tmp files
tmp_file = CONFIG.MINDSDB_STORAGE_PATH + '/{id}.pt'.format(id=id)
if not os.path.exists(CONFIG.MINDSDB_STORAGE_PATH):
os.makedirs(CONFIG.MINDSDB_STORAGE_PATH)
torch.save(object, tmp_file)
return id, tmp_file
def arrayToFloatVariable(arr):
if CONFIG.USE_CUDA:
ret = Variable(torch.FloatTensor(arr))
ret = ret.cuda()
return ret
else:
return Variable(torch.FloatTensor(arr))