Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Nov 24, 2024
1 parent 56fd9f9 commit edd0df6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/app_sana.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
DEMO_PORT = int(os.getenv("DEMO_PORT", "15432"))
os.environ["GRADIO_EXAMPLES_CACHE"] = "./.gradio/cache"
COUNTER_DB = os.getenv('COUNTER_DB', '.count.db')
COUNTER_DB = os.getenv("COUNTER_DB", ".count.db")

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

Expand Down Expand Up @@ -117,22 +117,22 @@

def open_db():
db = sqlite3.connect(COUNTER_DB)
db.execute('CREATE TABLE IF NOT EXISTS counter(app CHARS PRIMARY KEY UNIQUE, value INTEGER)')
db.execute('INSERT OR IGNORE INTO counter(app, value) VALUES("Sana", 0)')
db.execute("CREATE TABLE IF NOT EXISTS counter(app CHARS PRIMARY KEY UNIQUE, value INTEGER)")
db.execute("INSERT OR IGNORE INTO counter(app, value) VALUES(\"Sana\", 0)")
return db


def read_inference_count():
with open_db() as db:
cur = db.execute('SELECT value FROM counter WHERE app="Sana"')
cur = db.execute("SELECT value FROM counter WHERE app=\"Sana\"")
db.commit()
return cur.fetchone()[0]


def write_inference_count(count):
count = max(0, int(count))
with open_db() as db:
db.execute(f'UPDATE counter SET value=value+{count} WHERE app="Sana"')
db.execute(f"UPDATE counter SET value=value+{count} WHERE app=\"Sana\"")
db.commit()


Expand Down

0 comments on commit edd0df6

Please sign in to comment.