rishiraj/autolgbm

OperationalError: database is locked

Opened this issue · 0 comments

import os
import pandas as pd
from pandas import read_csv
from autolgbm import AutoLGBM

os.chdir("//wsl.localhost/Ubuntu/home/mhrachov/algorithm testing/Side quest/Random seed/CropGBM/qtlmas")

traingeno = 'preprocessed/qtlmas_filter.geno'
trainphe = 'preprocessed/qtlmas_pheno_empty_na.phe'

traingeno_data = read_csv(traingeno, header=0, index_col=0)
trainphe_data = read_csv(trainphe, header=0, index_col=0).dropna(axis=0)
traingeno_data = traingeno_data.loc[trainphe_data.index.values, :]

combined_data = pd.concat([trainphe_data, traingeno_data], axis=1)
combined_data.to_csv('combined_data.csv')
# required parameters:
train_filename = 'combined_data.csv'
output = "output1"

# optional parameters
test_filename = None
task = None
idx = None
targets = ["phe"]
features = None
categorical_features = None
use_gpu = False
num_folds = 5
seed = 42
num_trials = 100
time_limit = 1200
fast = False

# Now its time to train the model!
algbm = AutoLGBM(
    train_filename=train_filename,
    output=output,
    test_filename=test_filename,
    task=task,
    idx=idx,
    targets=targets,
    features=features,
    categorical_features=categorical_features,
    use_gpu=use_gpu,
    num_folds=num_folds,
    seed=seed,
    num_trials=num_trials,
    time_limit=time_limit,
    fast=fast,
)
algbm.train()
....
some info messages
...
2023-08-09 14:51:32.758 | INFO     | autolgbm.autolgbm:_process_data:237 - Saving model config
2023-08-09 14:51:32.774 | INFO     | autolgbm.autolgbm:_process_data:241 - Saving encoders
Traceback (most recent call last):

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\base.py:1965 in _exec_single_context
    self.dialect.do_execute(

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\default.py:921 in do_execute
    cursor.execute(statement, parameters)

OperationalError: database is locked


The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  Cell In[53], line 17
    algbm.train()

  File ~\miniconda3\envs\GBM_project\lib\site-packages\autolgbm\autolgbm.py:247 in train
    best_params = train_model(self.model_config)

  File ~\miniconda3\envs\GBM_project\lib\site-packages\autolgbm\utils.py:206 in train_model
    study = optuna.create_study(

  File ~\miniconda3\envs\GBM_project\lib\site-packages\optuna\study\study.py:1136 in create_study
    storage = storages.get_storage(storage)

  File ~\miniconda3\envs\GBM_project\lib\site-packages\optuna\storages\__init__.py:31 in get_storage
    return _CachedStorage(RDBStorage(storage))

  File ~\miniconda3\envs\GBM_project\lib\site-packages\optuna\storages\_rdb\storage.py:183 in __init__
    models.BaseModel.metadata.create_all(self.engine)

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\sql\schema.py:5792 in create_all
    bind._run_ddl_visitor(

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\base.py:3239 in _run_ddl_visitor
    conn._run_ddl_visitor(visitorcallable, element, **kwargs)

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\base.py:2443 in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\sql\visitors.py:670 in traverse_single
    return meth(obj, **kw)

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\sql\ddl.py:901 in visit_metadata
    [t for t in tables if self._can_create_table(t)]

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\sql\ddl.py:901 in <listcomp>
    [t for t in tables if self._can_create_table(t)]

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\sql\ddl.py:866 in _can_create_table
    return not self.checkfirst or not self.dialect.has_table(

  File <string>:2 in has_table

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\reflection.py:88 in cache
    return fn(self, con, *args, **kw)

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\dialects\sqlite\base.py:2146 in has_table
    info = self._get_table_pragma(

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\dialects\sqlite\base.py:2761 in _get_table_pragma
    cursor = connection.exec_driver_sql(statement)

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\base.py:1774 in exec_driver_sql
    ret = self._execute_context(

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\base.py:1844 in _execute_context
    return self._exec_single_context(

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\base.py:1984 in _exec_single_context
    self._handle_dbapi_exception(

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\base.py:2339 in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\base.py:1965 in _exec_single_context
    self.dialect.do_execute(

  File ~\miniconda3\envs\GBM_project\lib\site-packages\sqlalchemy\engine\default.py:921 in do_execute
    cursor.execute(statement, parameters)

OperationalError: (sqlite3.OperationalError) database is locked
[SQL: PRAGMA main.table_info("studies")]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

Installation was in a clean environment. I don't know the cause nor how to solve.