(fix) correct sql query

This commit is contained in:
drupman
2023-08-06 23:09:43 -03:00
parent 4f5ea216cd
commit ce4d801eae

View File

@@ -14,6 +14,20 @@ class OptunaDBManager:
self.engine = create_engine(self.db_path, connect_args={'check_same_thread': False})
self.session_maker = sessionmaker(bind=self.engine)
@property
def status(self):
try:
with self.session_maker() as session:
query = 'SELECT * FROM trials WHERE state = "COMPLETE"'
completed_trials = pd.read_sql_query(query, session.connection())
if len(completed_trials) > 0:
# TODO: improve error handling, think what to do with other cases
return "OK"
else:
return "No records found in the trials table with completed state"
except Exception as e:
return f"Error: {str(e)}"
@property
def tables(self):
return self._get_tables()