Skip to content

added openadapt.renew #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ performance

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

# MacOS file
.DS_Store
Copy link
Collaborator Author

@0dm 0dm May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always have to ignore the .DS_Store file on Mac 😅

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