Skip to content

Commit

Permalink
Fix file name
Browse files Browse the repository at this point in the history
  • Loading branch information
Microwave-WYB committed May 30, 2024
1 parent 32bf986 commit fdfafd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions phone_sensors/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def read_root() -> RedirectResponse:
def health_check() -> str:
"""Health check endpoint."""
try:
get_db_session()
get_redis_connection()
next(get_db_session())
next(get_redis_connection()).ping()
return "OK"
except Exception as e:
raise HTTPException(status_code=500, detail=f"Error: {e}") from e
Expand Down Expand Up @@ -72,7 +72,7 @@ async def upload(
status_code=400, detail="Missing file name, unable to determine file type."
)

file_path = Path(tempfile.gettempdir()) / file_name
file_path = Path(tempfile.gettempdir()) / Path(file_name).name
file_path.write_bytes(audio_data)

return submit_analyze_audio_job(redis_conn, file_path, status)
14 changes: 12 additions & 2 deletions phone_sensors/cli.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
"""Main entry point for the application."""

import logging
from multiprocessing import Process

import rich
import uvicorn
from rich.logging import RichHandler
from rq.worker_pool import WorkerPool
from sqlalchemy import create_engine

from phone_sensors.api import app
from phone_sensors.db import init_db
from phone_sensors.settings import get_redis_connection, get_settings

logging.basicConfig(
level=logging.INFO,
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler(rich_tracebacks=True)],
)

logger = logging.getLogger(__name__)


def main():
"""CLI entry point."""
settings = get_settings()
rich.print(settings)
logger.info(settings.model_dump())
engine = create_engine(str(settings.postgres_dsn))
init_db(engine)
api_process = Process(
Expand Down

0 comments on commit fdfafd2

Please sign in to comment.