1
0

train.py 1.3 KB

1234567891011121314151617181920212223242526272829
  1. """train model"""
  2. import streamlit as st
  3. from sqlalchemy.sql import text
  4. def create_table(conn):
  5. with conn.session as s:
  6. s.execute(text('CREATE TABLE IF NOT EXISTS train (position TEXT, finger_model TEXT, trial_num INTEGER, start_time DATETIME, owner_name TEXT, virtual_feedback_rate FLOAT, model_path TEXT);'))
  7. s.commit()
  8. def get_trains(conn, sub_name):
  9. trains = conn.query('select * from train where owner_name = :owner', ttl=0.05, params={'owner': sub_name})
  10. return trains
  11. def create_train(conn, train_form):
  12. with conn.session as s:
  13. s.execute(
  14. text('INSERT INTO train (position, finger_model, trial_num, start_time, owner_name, virtual_feedback_rate, model_path) VALUES (:position, :finger_model, :trial_num, :start_time, :owner_name, :virtual_feedback_rate, :model_path);'),
  15. params=dict(position=train_form['position'],
  16. finger_model=train_form['finger_model'],
  17. trial_num=train_form['trial_num'],
  18. start_time=train_form['start_time'],
  19. owner_name=train_form['owner_name'],
  20. virtual_feedback_rate=train_form['virtual_feedback_rate'],
  21. model_path=train_form['model_path'])
  22. )
  23. s.commit()