feat(common): add get_repo_dir function and corresponding tests #41
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
|
from pathlib import Path
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
|
|
||||||
from python.logging_config import configure_logger as _configure_logger
|
from python.logging_config import configure_logger as _configure_logger
|
||||||
@@ -11,6 +12,11 @@ from python.logging_config import configure_logger as _configure_logger
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_repo_dir() -> Path:
|
||||||
|
"""Return the repository root directory."""
|
||||||
|
return Path(__file__).resolve().parents[1]
|
||||||
|
|
||||||
|
|
||||||
def configure_logger(level: str = "INFO") -> None:
|
def configure_logger(level: str = "INFO") -> None:
|
||||||
"""Configure the logger."""
|
"""Configure the logger."""
|
||||||
_configure_logger(level)
|
_configure_logger(level)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from typing import Annotated
|
|||||||
|
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
from python.common import configure_logger
|
from python.common import configure_logger, get_repo_dir
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ class Config:
|
|||||||
|
|
||||||
image_tag = "whisper-transcribe:latest"
|
image_tag = "whisper-transcribe:latest"
|
||||||
model_volume = "whisper-models"
|
model_volume = "whisper-models"
|
||||||
repo_root = Path(__file__).resolve().parents[3]
|
repo_root = get_repo_dir()
|
||||||
dockerfile = Path(__file__).resolve().parent / "Dockerfile"
|
dockerfile = Path(__file__).resolve().parent / "Dockerfile"
|
||||||
huggingface_cache = "/root/.cache/huggingface"
|
huggingface_cache = "/root/.cache/huggingface"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,14 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from python.common import bash_wrapper, utcnow
|
from python.common import bash_wrapper, get_repo_dir, utcnow
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_repo_dir() -> None:
|
||||||
|
"""test_get_repo_dir."""
|
||||||
|
repo_dir = get_repo_dir()
|
||||||
|
assert (repo_dir / "pyproject.toml").is_file()
|
||||||
|
assert (repo_dir / "python" / "common.py").is_file()
|
||||||
|
|
||||||
|
|
||||||
def test_utcnow() -> None:
|
def test_utcnow() -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user