Skip to content

Commit

Permalink
ensure METRICS_FILE is a path
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodearnest committed Dec 18, 2023
1 parent 596532c commit 2cc2dc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions jobrunner/record_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import threading
import time
from collections import defaultdict
from pathlib import Path

from opentelemetry import trace

Expand Down Expand Up @@ -38,9 +39,10 @@ def get_connection(readonly=True):

# developer check against using memory dbs, which cannot be used with this
# function, as we need to set mode ourselves
assert not db_file.startswith(
assert isinstance(db_file, Path), "config.METRICS_FILE db must be file path"
assert not str(db_file).startswith(
"file:"
), "urls not supported for metrics db - must be path"
), "config.METRICS_FILE db must be file path, not url"

if readonly:
db = f"file:{db_file}?mode=ro"
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def metrics_db(monkeypatch, tmp_path, request):
It must be a file, not memory, because we use readonly connections.
"""
db_path = tmp_path / "metrics.db"
monkeypatch.setattr(config, "METRICS_FILE", str(db_path))
monkeypatch.setattr(config, "METRICS_FILE", db_path)
yield
record_stats.CONNECTION_CACHE.__dict__.clear()

Expand Down

0 comments on commit 2cc2dc3

Please sign in to comment.