added script to monitor translation progress
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
from database import get_all, Data_table
|
||||||
|
from tqdm import tqdm
|
||||||
|
import time
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
def get_progress(con):
|
||||||
|
query = 'SELECT count(*) from data_table'
|
||||||
|
res = pd.read_sql_query(query, con)
|
||||||
|
total = res['count'][0]
|
||||||
|
query = 'SELECT count(*) from data_table where content_en is not null'
|
||||||
|
res = pd.read_sql_query(query, con)
|
||||||
|
progress = res['count'][0]
|
||||||
|
return progress, total
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
load_dotenv()
|
||||||
|
try:
|
||||||
|
with Data_table() as dt:
|
||||||
|
# continously update progress bar
|
||||||
|
progress, total = get_progress(dt.con)
|
||||||
|
with tqdm(total=total, initial=progress) as pbar:
|
||||||
|
while True:
|
||||||
|
pbar.n = progress
|
||||||
|
pbar.refresh()
|
||||||
|
time.sleep(1)
|
||||||
|
progress, total = get_progress(dt.con)
|
||||||
|
except Exception as e:
|
||||||
|
print(f'error occurred: {e}')
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('KeyboardInterrupt')
|
||||||
|
|
||||||
Reference in New Issue
Block a user