Skip to content

Commit

Permalink
Merge pull request #207 from 0dm/clear-data
Browse files Browse the repository at this point in the history
added openadapt.renew
  • Loading branch information
abrichr authored Jun 16, 2023
2 parents bde3816 + 482ab56 commit 15a5cca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ performance

# Generated when adding editable dependencies in requirements.txt (-e)
src

# MacOS file
.DS_Store
2 changes: 1 addition & 1 deletion openadapt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def getenv_fallback(var_name):
locals()[key] = val

ROOT_DIRPATH = pathlib.Path(__file__).parent.parent.resolve()
DB_FPATH = ROOT_DIRPATH / DB_FNAME
DB_FPATH = ROOT_DIRPATH / DB_FNAME # type: ignore # noqa
DB_URL = f"sqlite:///{DB_FPATH}"
DIRNAME_PERFORMANCE_PLOTS = "performance"

Expand Down
8 changes: 4 additions & 4 deletions openadapt/scripts/reset_db.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import os
from subprocess import run, PIPE
from openadapt.config import getenv_fallback
from openadapt import config


def reset_db():
"""
The function clears the database by removing the database file and running a
database migration using Alembic.
"""
db = getenv_fallback("DB_FNAME")
if os.path.exists(db):
os.remove(db)

if os.path.exists(config.DB_FPATH):
os.remove(config.DB_FPATH)

# Prevents duplicate logging of config values by piping stderr and filtering the output.
result = run(["alembic", "upgrade", "head"], stderr=PIPE, text=True)
Expand Down

0 comments on commit 15a5cca

Please sign in to comment.