[MVQA] Add benchmark database schema 89/255989/2
authorKwang Son <k.son@samsung.com>
Fri, 26 Mar 2021 06:20:00 +0000 (15:20 +0900)
committerKwang Son <k.son@samsung.com>
Sun, 28 Mar 2021 23:24:56 +0000 (08:24 +0900)
Change-Id: I6d4ba715283f8960c9434e90207d736d659d22eb
Signed-off-by: Kwang Son <k.son@samsung.com>
script/mvqa/__init__.py
script/mvqa/db.py
script/mvqa/run.py [new file with mode: 0644]
script/mvqa_main.py

index 1f28b34..ff42b44 100644 (file)
@@ -1,3 +1,4 @@
 from .show import show_all
-__all__ = [show_all]
+from .run import run_bench
+__all__ = [show_all, run_bench]
 __version__ = 'latest'
index d6cdc45..6c58ffd 100644 (file)
@@ -44,7 +44,14 @@ def create():
             id integer PRIMARY KEY,
             dataset_id integer NOT NULL,
             testset_id integer NOT NULL,
-            date timestamp NOT NULL)''')
+            date timestamp DEFAULT CURRENT_TIMESTAMP,
+            target text NOT NULL)''')
+    conn.commit()
+    c.execute(
+        '''CREATE TABLE 'performance'(
+            id integer PRIMARY KEY,
+            benchmark_id integer NOT NULL,
+            data text)''')
     conn.commit()
     conn.close()
 
@@ -69,3 +76,28 @@ def print_testset_list():
     for row in ret:
         print(row)
     conn.close()
+
+
+def insert_benchmark(dataset_id, testset_id, target):
+    if not exist():
+        create()
+    conn = sqlite3.connect(DB_PATH)
+    c = conn.cursor()
+    benchmark_data = (dataset_id, testset_id, target)
+    c.execute(
+        'INSERT INTO benchmark(dataset_id, testset_id, target) VALUES (?,?,?)', benchmark_data)
+    id = c.lastrowid
+    conn.commit()
+    conn.close()
+    return id
+
+
+def insert_performance(bench_id, text):
+    if not exist():
+        create()
+    conn = sqlite3.connect(DB_PATH)
+    c = conn.cursor()
+    c.execute(
+        'INSERT INTO performance VALUES (null,?,?)', (bench_id, text))
+    conn.commit()
+    conn.close()
diff --git a/script/mvqa/run.py b/script/mvqa/run.py
new file mode 100644 (file)
index 0000000..8742baa
--- /dev/null
@@ -0,0 +1,18 @@
+import os
+from . import db
+import subprocess
+
+
+def run_bench(dataset_id, testset_id):
+    # check sdb
+    num_target = subprocess.check_output(
+        'sdb devices | grep -v "List" | wc -l', shell=True)
+    assert(int(num_target) == 1)
+    target_type = subprocess.check_output(
+        'sdb devices | tail -1 | cut -f 3', shell=True)
+    # check dataset is fit with testset
+    # check dataset is ready
+    bench_id = db.insert_benchmark(dataset_id, testset_id, target_type)
+    # insert result
+    for _ in range(5):
+        db.insert_performance(bench_id, "Pass, 1.5MB, 10s, ...")
index 0a55bf6..75d1782 100644 (file)
@@ -2,7 +2,6 @@ import argparse
 import mvqa
 import sys
 
-
 if __name__ == "__main__":
     if sys.version_info < (3, 0):
         print('use python3')
@@ -23,6 +22,6 @@ if __name__ == "__main__":
     if args.command == 'show':
         mvqa.show_all()
     elif args.command == 'run':
-        print('run')
+        mvqa.run_bench(args.dataset, args.testset)
     else:
         parser.print_help()