Spaces:
Sleeping
Sleeping
Sync Space from GitHub 52ee7a4cdf673b3293c5db2cf0880e08b11fdb4b
Browse files
scripts/build_ddinter_db.py
CHANGED
|
@@ -35,6 +35,7 @@ logger = logging.getLogger("build_ddinter_db")
|
|
| 35 |
USER_AGENT = "pillchecker-ddinter-build"
|
| 36 |
|
| 37 |
_REQUIRED_CSV_COLUMNS = {"DDInterID_A", "Drug_A", "DDInterID_B", "Drug_B", "Level"}
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
def compute_csv_sha256(path: Path) -> str:
|
|
@@ -459,7 +460,7 @@ def cmd_build(args: argparse.Namespace) -> int:
|
|
| 459 |
def sanity_check(
|
| 460 |
db_path: Path,
|
| 461 |
*,
|
| 462 |
-
min_rows: int =
|
| 463 |
sentinel: tuple[str, str] = ("Warfarin", "Aspirin"),
|
| 464 |
expected_severity: str = "Major",
|
| 465 |
previous_size_bytes: int | None,
|
|
@@ -571,7 +572,7 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
| 571 |
|
| 572 |
p_check = sub.add_parser("sanity-check", help="Validate emitted SQLite")
|
| 573 |
p_check.add_argument("--db-path", required=True)
|
| 574 |
-
p_check.add_argument("--min-rows", type=int, default=
|
| 575 |
p_check.add_argument("--sentinel", nargs=2, default=["Warfarin", "Aspirin"])
|
| 576 |
p_check.add_argument("--expected-severity", default="Major")
|
| 577 |
p_check.add_argument("--previous-size-bytes", type=int, default=None)
|
|
|
|
| 35 |
USER_AGENT = "pillchecker-ddinter-build"
|
| 36 |
|
| 37 |
_REQUIRED_CSV_COLUMNS = {"DDInterID_A", "Drug_A", "DDInterID_B", "Drug_B", "Level"}
|
| 38 |
+
DEFAULT_MIN_INTERACTION_ROWS = 100_000
|
| 39 |
|
| 40 |
|
| 41 |
def compute_csv_sha256(path: Path) -> str:
|
|
|
|
| 460 |
def sanity_check(
|
| 461 |
db_path: Path,
|
| 462 |
*,
|
| 463 |
+
min_rows: int = DEFAULT_MIN_INTERACTION_ROWS,
|
| 464 |
sentinel: tuple[str, str] = ("Warfarin", "Aspirin"),
|
| 465 |
expected_severity: str = "Major",
|
| 466 |
previous_size_bytes: int | None,
|
|
|
|
| 572 |
|
| 573 |
p_check = sub.add_parser("sanity-check", help="Validate emitted SQLite")
|
| 574 |
p_check.add_argument("--db-path", required=True)
|
| 575 |
+
p_check.add_argument("--min-rows", type=int, default=DEFAULT_MIN_INTERACTION_ROWS)
|
| 576 |
p_check.add_argument("--sentinel", nargs=2, default=["Warfarin", "Aspirin"])
|
| 577 |
p_check.add_argument("--expected-severity", default="Major")
|
| 578 |
p_check.add_argument("--previous-size-bytes", type=int, default=None)
|
tests/test_build_ddinter_db.py
CHANGED
|
@@ -211,6 +211,11 @@ def test_sanity_check_fails_if_size_drift_too_large(tmp_path: Path):
|
|
| 211 |
assert ok is False
|
| 212 |
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
# --- Severity conflict detection ---
|
| 215 |
|
| 216 |
def test_severity_conflict_warns_and_keeps_first(tmp_path: Path, caplog):
|
|
|
|
| 211 |
assert ok is False
|
| 212 |
|
| 213 |
|
| 214 |
+
def test_sanity_check_cli_default_row_floor_tracks_current_ddinter_release():
|
| 215 |
+
args = build_ddinter_db._build_parser().parse_args(["sanity-check", "--db-path", "data/ddinter.db"])
|
| 216 |
+
assert args.min_rows == 100_000
|
| 217 |
+
|
| 218 |
+
|
| 219 |
# --- Severity conflict detection ---
|
| 220 |
|
| 221 |
def test_severity_conflict_warns_and_keeps_first(tmp_path: Path, caplog):
|