Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Add timezone support to DateTime columns and pre-commit hook

LearningCircuit705a04ec790d
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e91aa1340c..205ed5d5a0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -59,3 +59,9 @@ repos:
language: script
files: \.py$
description: "Ensure research_id is always treated as string/UUID, never as int"
+ - id: check-datetime-timezone
+ name: Check DateTime columns have timezone
+ entry: scripts/pre_commit/check_datetime_timezone.py
+ language: script
+ files: \.py$
+ description: "Ensure all SQLAlchemy DateTime columns have timezone=True"
diff --git a/scripts/pre_commit/check_datetime_timezone.py b/scripts/pre_commit/check_datetime_timezone.py
new file mode 100755
index 0000000000..da35452aa8
--- /dev/null
+++ b/scripts/pre_commit/check_datetime_timezone.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python3
+"""Pre-commit hook to check that all DateTime columns in SQLAlchemy models have timezone=True."""
+
+import ast
+import sys
+from pathlib import Path
+from typing import List, Tuple
+
+
+def check_datetime_columns(file_path: Path) -> List[Tuple[int, str]]:
+ """Check a Python file for DateTime columns without timezone=True.
+
+ Returns a list of (line_number, line_content) tuples for violations.
+ """
+ violations = []
+
+ try:
+ with open(file_path, "r") as f:
+ content = f.read()
+ lines = content.split("\n")
+ except Exception as e:
+ print(f"Error reading {file_path}: {e}", file=sys.stderr)
+ return violations
+
+ # Parse the AST to find Column definitions with DateTime
+ try:
+ tree = ast.parse(content)
+ except SyntaxError:
+ # Not valid Python, skip
+ return violations
+
+ for node in ast.walk(tree):
+ if isinstance(node, ast.Call):
+ # Check if this is a Column call
+ if isinstance(node.func, ast.Name) and node.func.id == "Column":
+ # Check if first argument is DateTime
+ if node.args and isinstance(node.args[0], ast.Call):
+ datetime_call = node.args[0]
+ if (
+ isinstance(datetime_call.func, ast.Name)
+ and datetime_call.func.id == "DateTime"
+ ):
+ # Check if timezone=True is present
+ has_timezone = False
+ for keyword in datetime_call.keywords:
+ if keyword.arg == "timezone":
+ has_timezone = True
+ break
+
+ if not has_timezone:
+ # Find the line number
+ line_num = node.lineno
+ if 0 <= line_num - 1 < len(lines):
+ violations.append(
+ (line_num, lines[line_num - 1].strip())
+ )
+
+ return violations
+
+
+def main():
+ """Main entry point for the pre-commit hook."""
+ files_to_check = sys.argv[1:]
+
+ if not files_to_check:
+ print("No files to check")
+ return 0
+
+ all_violations = []
+
+ for file_path_str in files_to_check:
+ file_path = Path(file_path_str)
+
+ # Only check Python files in database/models directories
+ if file_path.suffix == ".py" and (
+ "database/models" in str(file_path) or "models" in file_path.parts
+ ):
+ violations = check_datetime_columns(file_path)
+ if violations:
+ all_violations.append((file_path, violations))
+
+ if all_violations:
+ print("\n❌ DateTime columns without timezone=True found:\n")
+ for file_path, violations in all_violations:
+ print(f" {file_path}:")
+ for line_num, line_content in violations:
+ print(f" Line {line_num}: {line_content}")
+ print("\n Fix: Add timezone=True to all DateTime columns")
+ print(" Example: Column(DateTime(timezone=True), ...)\n")
+ return 1
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/src/local_deep_research/database/models/benchmark.py b/src/local_deep_research/database/models/benchmark.py
index 365d32bfab..c3058ea0ab 100644
--- a/src/local_deep_research/database/models/benchmark.py
+++ b/src/local_deep_research/database/models/benchmark.py
@@ -73,12 +73,17 @@ class BenchmarkRun(Base):
status = Column(
Enum(BenchmarkStatus), default=BenchmarkStatus.PENDING, nullable=False
)
- created_at = Column(DateTime, server_default=func.now(), nullable=False)
+ created_at = Column(
+ DateTime(timezone=True), server_default=func.now(), nullable=False
+ )
updated_at = Column(
- DateTime, server_default=func.now(), onupdate=func.now(), nullable=False
+ DateTime(timezone=True),
+ server_default=func.now(),
+ onupdate=func.now(),
+ nullable=False,
)
- start_time = Column(DateTime, nullable=True)
- end_time = Column(DateTime, nullable=True)
+ start_time = Column(DateTime(timezone=True), nullable=True)
+ end_time = Column(DateTime(timezone=True), nullable=True)
# Progress tracking
total_examples = Column(Integer, default=0, nullable=False)
@@ -156,8 +161,10 @@ class BenchmarkResult(Base):
grader_response = Column(Text, nullable=True)
# Timestamps
- created_at = Column(DateTime, server_default=func.now(), nullable=False)
- completed_at = Column(DateTime, nullable=True)
+ created_at = Column(
+ DateTime(timezone=True), server_default=func.now(), nullable=False
+ )
+ completed_at = Column(DateTime(timezone=True), nullable=True)
# Error handling
research_error = Column(Text, nullable=True)
@@ -204,16 +211,21 @@ class BenchmarkConfig(Base):
datasets_config = Column(JSON, nullable=False)
# Metadata
- created_at = Column(DateTime, server_default=func.now(), nullable=False)
+ created_at = Column(
+ DateTime(timezone=True), server_default=func.now(), nullable=False
+ )
updated_at = Column(
- DateTime, server_default=func.now(), onupdate=func.now(), nullable=False
+ DateTime(timezone=True),
+ server_default=func.now(),
+ onupdate=func.now(),
+ nullable=False,
)
is_default = Column(Boolean, default=False, nullable=False)
is_public = Column(Boolean, default=True, nullable=False)
# Usage tracking
usage_count = Column(Integer, default=0, nullable=False)
- last_used = Column(DateTime, nullable=True)
+ last_used = Column(DateTime(timezone=True), nullable=True)
# Performance data (if available)
best_accuracy = Column(Float, nullable=True)
@@ -244,7 +256,9 @@ class BenchmarkProgress(Base):
)
# Progress data
- timestamp = Column(DateTime, server_default=func.now(), nullable=False)
+ timestamp = Column(
+ DateTime(timezone=True), server_default=func.now(), nullable=False
+ )
completed_examples = Column(Integer, nullable=False)
total_examples = Column(Integer, nullable=False)
@@ -254,7 +268,7 @@ class BenchmarkProgress(Base):
# Performance metrics
processing_rate = Column(Float, nullable=True) # Examples per minute
- estimated_completion = Column(DateTime, nullable=True)
+ estimated_completion = Column(DateTime(timezone=True), nullable=True)
# Current status
current_dataset = Column(Enum(DatasetType), nullable=True)