naver / sqlova

Apache License 2.0
632 stars 168 forks source link

dbengine #73

Open waghmareomkar opened 3 years ago

waghmareomkar commented 3 years ago

python3 train.py --seed 1 --bS 16 --accumulate_gradients 2 --bert_type_abb uS --fine_tune --lr 0.001 --lr_bert 0.00001 --max_seq_leng 222 --do_train
BERT-type: uncased_L-12_H-768_A-12 Batch_size = 32 BERT parameters: learning rate: 1e-05 Fine-tune BERT: True vocab size: 30522 hidden_size: 768 num_hidden_layer: 12 num_attention_heads: 12 hidden_act: gelu intermediate_size: 3072 hidden_dropout_prob: 0.1 attention_probs_dropout_prob: 0.1 max_position_embeddings: 512 type_vocab_size: 2 initializer_range: 0.02 Load pre-trained parameters. Seq-to-SQL: the number of final BERT layers to be used: 2 Seq-to-SQL: the size of hidden dimension = 100 Seq-to-SQL: LSTM encoding layer size = 2 Seq-to-SQL: dropout rate = 0.3 Seq-to-SQL: learning rate = 0.001 C:\Users\omkar waghmare\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\torch\nn\functional.py:1709: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.") Traceback (most recent call last): File "train.py", line 684, in acc_train, aux_out_train = train(train_loader, File "train.py", line 319, in train cnt_x1_list, g_ans, pr_ans = get_cnt_x_list(engine, tb, g_sc, g_sa, sql_i, pr_sc, pr_sa, pr_sql_i) File "D:\Northeastern courses\CS 6120\project\sqlova\sqlova\utils\utils_wikisql.py", line 1652, in get_cnt_x_list g_ans1 = engine.execute(tb[b]['id'], g_sc[b], g_sa[b], g_sql_i[b]['conds']) File "D:\Northeastern courses\CS 6120\project\sqlova\sqlnet\dbengine.py", line 29, in execute table_info = self.db.query('SELECT sql from sqlite_master WHERE tbl_name = :name', name=table_id).all()[0].sql.replace('\n','') File "C:\Users\omkar waghmare\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\records.py", line 61, in getattr return self[key] File "C:\Users\omkar waghmare\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\records.py", line 54, in getitem i = self.keys().index(key) AttributeError: 'RMKeyView' object has no attribute 'index'

i've already installed records 0.5.2

waghmareomkar commented 3 years ago

https://www.gitmemory.com/issue/kenreitz42/records/208/805342147 appaprently it can be solved using sqlalchemy 1.3, but that causes the time error.

Qile-Paul-Chen commented 3 years ago

I had the same issue when running evaluate_ws.py, and it was solved by installing sqlalchemy 1.3

simonjisu commented 3 years ago

I am working on SQLAlchemy==1.4.15 and records==0.5.3
Since the RMKeyView is no longer works as list type, it has no attribute like index and count. So typecast the RMKeyView object as list when calling self.keys() at Record.__getitem__ function in records.py file.

Maybe you might reinstall the records package with https://github.com/simonjisu/records.git Not tested yet in sqlova code, but tested like following:

from sqlalchemy.exc import ResourceClosedError, OperationalError

sql = """CREATE TABLE contacts (contact_id INTEGER PRIMARY KEY, first_name TEXT NOT NULL, last_name TEXT NOT NULL, email TEXT NOT NULL UNIQUE, phone TEXT NOT NULL UNIQUE)"""

db = records.Database(f"sqlite:///test.db")
try:
    db.query(sql)
except ResourceClosedError:
    print("Created")
except OperationalError:
    print("table already created")

res = db.query("SELECT sql FROM sqlite_master WHERE tbl_name = 'contacts';").all()[0].sql
res

Result:

'CREATE TABLE contacts (contact_id INTEGER PRIMARY KEY, first_name TEXT NOT NULL, last_name TEXT NOT NULL, email TEXT NOT NULL UNIQUE, phone TEXT NOT NULL UNIQUE)'
dsivakumar commented 2 years ago

I just used as_dict() method, like this

db.query("SELECT sql FROM sqlite_master WHERE tbl_name = 'contacts';").all()[0].as_dict()['sql']

KunalKartik02 commented 8 months ago

use SQLAlchemy version 1.3.18. The time error is fixed here.