Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/cdelivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
backend \
docker \
requirements.txt \
docker-compose.yml \
.env_example

echo "Package contents:"
Expand Down
3 changes: 2 additions & 1 deletion backend/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path


# Utility functions for environment variable loading and logging setup
def load_project_env() -> Path | None:
for directory in (Path.cwd(), Path.cwd().parent, Path(__file__).resolve().parents[2]):
env_path = directory / ".env"
Expand All @@ -20,7 +21,7 @@ def load_project_env() -> Path | None:
return env_path
return None


# Simple logger setup for the project
def get_logger(name: str) -> logging.Logger:
logging.basicConfig(
level=os.getenv("LOG_LEVEL", "INFO"),
Expand Down
9 changes: 5 additions & 4 deletions backend/utils/metrics.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import time
from collections.abc import Callable
from typing import TypeVar

import psutil
from typing import TypeVar
from collections.abc import Callable


T = TypeVar("T")


# Utility functions for timing and resource usage metrics
def timed_call(fn: Callable[..., T], *args, **kwargs) -> tuple[T, float]:
start = time.time()
value = fn(*args, **kwargs)
return value, time.time() - start


# Capture current resource usage snapshot
def resource_snapshot() -> dict[str, float]:
process = psutil.Process()
memory = process.memory_info()
Expand All @@ -26,6 +26,7 @@ def resource_snapshot() -> dict[str, float]:
}


# Compute resource usage delta between two snapshots
def resource_delta(before: dict[str, float], after: dict[str, float]) -> dict[str, float]:
return {
"cpu_percent_before": before["cpu_percent"],
Expand Down
Loading