Fixed dev environment database setup
This commit is contained in:
+4
-2
@@ -19,8 +19,10 @@ RUN apt-get update && apt-get install -y \
|
|||||||
|
|
||||||
COPY aperisolve/ /aperisolve/
|
COPY aperisolve/ /aperisolve/
|
||||||
|
|
||||||
|
RUN mkdir -p /data
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -r /aperisolve/requirements.txt
|
RUN pip install --no-cache-dir -r /aperisolve/requirements.txt
|
||||||
|
|
||||||
RUN PYTHONPATH=/ python -c "from aperisolve.utils import create_crc_db; create_crc_db()"
|
RUN PYTHONPATH=/ python -c "from aperisolve.analyzers.utils import create_crc_db; create_crc_db()"
|
||||||
|
|
||||||
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "aperisolve.wsgi:application"]
|
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "aperisolve.wsgi:application"]
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import zlib
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
from .utils import update_data
|
from .utils import update_data, DB_PATH
|
||||||
|
|
||||||
|
|
||||||
# Full list of expected sizes
|
# Full list of expected sizes
|
||||||
EXPECTED_SIZES = [
|
EXPECTED_SIZES = [
|
||||||
@@ -188,7 +189,7 @@ def lookup_crc(crc_bytes: bytes, logs: List[str]) -> List[tuple[int, int]]:
|
|||||||
Queries the SQLite DB for the CRC and returns a list of (width, height) tuples.
|
Queries the SQLite DB for the CRC and returns a list of (width, height) tuples.
|
||||||
"""
|
"""
|
||||||
# Locate DB relative to this script file
|
# Locate DB relative to this script file
|
||||||
db_path = Path(__file__).parent / "ihdr_crcs.db"
|
db_path = Path(DB_PATH)
|
||||||
|
|
||||||
if not db_path.exists():
|
if not db_path.exists():
|
||||||
logs.append(f"Error: Database not found at {db_path}")
|
logs.append(f"Error: Database not found at {db_path}")
|
||||||
|
|||||||
@@ -64,10 +64,12 @@ def create_crc_db() -> None:
|
|||||||
if os.path.exists(DB_PATH):
|
if os.path.exists(DB_PATH):
|
||||||
print(f"Database already exists at {DB_PATH}. Skipping generation.")
|
print(f"Database already exists at {DB_PATH}. Skipping generation.")
|
||||||
return
|
return
|
||||||
db_filename = "ihdr_crcs.db"
|
|
||||||
|
|
||||||
# Connect to database
|
# Use the global DB_PATH variable so it writes to /data/ in Docker
|
||||||
conn = sqlite3.connect(db_filename)
|
# and /analyzers/ in local dev
|
||||||
|
print(f"Generating database at: {DB_PATH}")
|
||||||
|
conn = sqlite3.connect(DB_PATH)
|
||||||
|
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
# Optimization: Turn off safety checks for bulk insertion speed
|
# Optimization: Turn off safety checks for bulk insertion speed
|
||||||
|
|||||||
Reference in New Issue
Block a user