-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a595cff
commit efdaf85
Showing
7 changed files
with
139 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ output/ | |
output2/ | ||
logs/ | ||
op_*/ | ||
autotrain.db | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sqlite3 | ||
|
||
|
||
class AutoTrainDB: | ||
def __init__(self, db_path): | ||
self.db_path = db_path | ||
self.conn = sqlite3.connect(db_path) | ||
self.c = self.conn.cursor() | ||
self.create_jobs_table() | ||
|
||
def create_jobs_table(self): | ||
self.c.execute( | ||
"""CREATE TABLE IF NOT EXISTS jobs | ||
(id INTEGER PRIMARY KEY, pid INTEGER)""" | ||
) | ||
self.conn.commit() | ||
|
||
def add_job(self, pid): | ||
sql = f"INSERT INTO jobs (pid) VALUES ({pid})" | ||
self.c.execute(sql) | ||
self.conn.commit() | ||
|
||
def get_running_jobs(self): | ||
self.c.execute("""SELECT pid FROM jobs""") | ||
running_pids = self.c.fetchall() | ||
running_pids = [pid[0] for pid in running_pids] | ||
return running_pids | ||
|
||
def delete_job(self, pid): | ||
sql = f"DELETE FROM jobs WHERE pid={pid}" | ||
self.c.execute(sql) | ||
self.conn.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters