Skip to content

Commit 4cd552d

Browse files
committed
backend: clean up unused code paths
1 parent 01f9799 commit 4cd552d

File tree

9 files changed

+24
-35
lines changed

9 files changed

+24
-35
lines changed

backend/app/auth.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""Authentication utilities for the Memory Tracker API."""
22

3-
from fastapi import Depends, HTTPException, status, Header
3+
from fastapi import Depends, Header
44
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
55
from sqlalchemy.ext.asyncio import AsyncSession
66
from typing import Annotated
7-
import logging
87

98
from . import models, crud
109
from .database import get_database

backend/app/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
All settings are loaded from environment variables with sensible defaults.
44
"""
55

6-
from typing import List, Optional, Union
6+
from typing import List
77
from pydantic_settings import BaseSettings
8-
from pydantic import field_validator
98
from functools import lru_cache
109

1110

backend/app/logging_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Logging utilities for sanitizing sensitive data."""
22

33
import re
4-
from typing import Any, Dict, List, Union
4+
from typing import Any, Dict, List
55

66
# Patterns for sensitive data
77
SENSITIVE_PATTERNS = [

backend/app/oauth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
import secrets
66
import logging
7-
from typing import Optional, Dict, Any
7+
from typing import Optional
88
from authlib.integrations.httpx_client import AsyncOAuth2Client
9-
from fastapi import HTTPException, Request
9+
from fastapi import HTTPException
1010
from pydantic import BaseModel
1111
from sqlalchemy.ext.asyncio import AsyncSession
1212

backend/app/routers/binaries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async def get_binaries(db: AsyncSession = Depends(get_database)):
1919

2020
try:
2121
binaries = await crud.get_binaries(db)
22-
logger.info(f"Successfully retrieved binaries", extra={"count": len(binaries)})
22+
logger.info("Successfully retrieved binaries", extra={"count": len(binaries)})
2323

2424
return [
2525
schemas.Binary(
@@ -34,7 +34,7 @@ async def get_binaries(db: AsyncSession = Depends(get_database)):
3434
for binary in binaries
3535
]
3636
except Exception as e:
37-
logger.error(f"Failed to fetch binaries", extra={"error": str(e)})
37+
logger.error("Failed to fetch binaries", extra={"error": str(e)})
3838
raise HTTPException(status_code=500, detail="Failed to fetch binaries")
3939

4040

backend/app/routers/commits.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ async def get_commits(
2020
db: AsyncSession = Depends(get_database),
2121
):
2222
logger = get_logger("api.commits")
23-
logger.info(f"Fetching commits", extra={"skip": skip, "limit": limit})
23+
logger.info("Fetching commits", extra={"skip": skip, "limit": limit})
2424

2525
try:
2626
commits = await crud.get_commits(db, skip=skip, limit=limit)
27-
logger.info(f"Successfully retrieved commits", extra={"count": len(commits)})
27+
logger.info("Successfully retrieved commits", extra={"count": len(commits)})
2828

2929
return [
3030
schemas.Commit(
@@ -41,23 +41,23 @@ async def get_commits(
4141
for commit in commits
4242
]
4343
except Exception as e:
44-
logger.error(f"Failed to fetch commits", extra={"error": str(e)})
44+
logger.error("Failed to fetch commits", extra={"error": str(e)})
4545
raise HTTPException(status_code=500, detail="Failed to fetch commits")
4646

4747

4848
@router.get("/commits/{sha}", response_model=schemas.Commit)
4949
async def get_commit(sha: str, db: AsyncSession = Depends(get_database)):
5050
logger = get_logger("api.commits")
51-
logger.info(f"Fetching commit by SHA", extra={"sha": sha})
51+
logger.info("Fetching commit by SHA", extra={"sha": sha})
5252

5353
try:
5454
commit = await crud.get_commit_by_sha(db, sha=sha)
5555
if commit is None:
56-
logger.warning(f"Commit not found", extra={"sha": sha})
56+
logger.warning("Commit not found", extra={"sha": sha})
5757
raise HTTPException(status_code=404, detail="Commit not found")
5858

5959
logger.info(
60-
f"Successfully retrieved commit",
60+
"Successfully retrieved commit",
6161
extra={
6262
"sha": commit.sha[:8],
6363
"author": commit.author,
@@ -79,7 +79,7 @@ async def get_commit(sha: str, db: AsyncSession = Depends(get_database)):
7979
except HTTPException:
8080
raise
8181
except Exception as e:
82-
logger.error(f"Failed to fetch commit", extra={"sha": sha, "error": str(e)})
82+
logger.error("Failed to fetch commit", extra={"sha": sha, "error": str(e)})
8383
raise HTTPException(status_code=500, detail="Failed to fetch commit")
8484

8585

backend/scripts/init_db.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Add the parent directory to the path so we can import from app
1212
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
1313

14-
from app.database import create_tables, drop_tables, get_database
14+
from app.database import get_database
1515
from app import crud
1616
from app.config import get_settings
1717

@@ -65,14 +65,6 @@ async def init_database():
6565
try:
6666
# Import models to ensure they're registered
6767
from app.models import (
68-
AdminUser,
69-
AdminSession,
70-
AuthToken,
71-
Commit,
72-
Binary,
73-
Environment,
74-
Run,
75-
BenchmarkResult,
7668
Base,
7769
)
7870
from app.database import create_database_engine
@@ -128,7 +120,6 @@ async def reset_database():
128120
Base,
129121
)
130122
from app.database import create_database_engine
131-
from sqlalchemy.ext.asyncio import create_async_engine
132123

133124
# Create a fresh engine with current settings
134125
engine = create_database_engine()

backend/scripts/populate_db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ async def populate_database(database_url: Optional[str] = None):
379379
await db.flush()
380380
print(f"✅ Created {len(binary_objects)} new binaries")
381381
else:
382-
print(f"✅ All binaries already exist")
382+
print("✅ All binaries already exist")
383383

384384
# Use all binaries (existing + new) for runs
385385
all_binary_objects = existing_binaries + binary_objects
@@ -404,7 +404,7 @@ async def populate_database(database_url: Optional[str] = None):
404404
await db.flush()
405405
print(f"✅ Created {len(environment_objects)} new environments")
406406
else:
407-
print(f"✅ All environments already exist")
407+
print("✅ All environments already exist")
408408

409409
# Use all environments (existing + new) for runs
410410
all_environment_objects = existing_environments + environment_objects
@@ -487,7 +487,7 @@ async def populate_database(database_url: Optional[str] = None):
487487
# Commit everything at once
488488
await db.commit()
489489

490-
print(f"\n🎉 Database populated successfully!")
490+
print("\n🎉 Database populated successfully!")
491491
print(f" - {len(commit_objects)} commits (100 per Python version)")
492492
print(
493493
f" - {len(binary_objects)} new binaries ({len(all_binary_objects)} total)"

backend/scripts/populate_simple_data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
1616

1717
from app.database import AsyncSessionLocal
18-
from app import models, schemas, crud
18+
from app import models, schemas
1919

2020

2121
# Mock data generators
@@ -403,7 +403,7 @@ async def populate_database():
403403
# Commit everything at once
404404
await db.commit()
405405

406-
print(f"\n🎉 Database populated with OBVIOUS TEST DATA!")
406+
print("\n🎉 Database populated with OBVIOUS TEST DATA!")
407407
print(f" - {len(commit_objects)} commits (2 per Python version)")
408408
print(f" - {len(binary_objects)} binaries (default, debug, nogil)")
409409
print(f" - {len(environment_objects)} environments (gcc-11, clang-14)")
@@ -413,10 +413,10 @@ async def populate_database():
413413
print(
414414
f" - {len(result_objects)} benchmark results (3 benchmarks per run)"
415415
)
416-
print(f"\n📊 MEMORY VALUES FOR VERIFICATION:")
417-
print(f" Benchmark A: Default=1MB, Debug=1.5MB, NoGIL=0.8MB")
418-
print(f" Benchmark B: Default=2MB, Debug=3MB, NoGIL=1.6MB")
419-
print(f" Benchmark C: Default=10MB, Debug=15MB, NoGIL=8MB")
416+
print("\n📊 MEMORY VALUES FOR VERIFICATION:")
417+
print(" Benchmark A: Default=1MB, Debug=1.5MB, NoGIL=0.8MB")
418+
print(" Benchmark B: Default=2MB, Debug=3MB, NoGIL=1.6MB")
419+
print(" Benchmark C: Default=10MB, Debug=15MB, NoGIL=8MB")
420420

421421
except Exception as e:
422422
print(f"❌ Error populating database: {e}")

0 commit comments

Comments
 (0)