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 src/common/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ def is_truthy(value: Optional[str]) -> bool:
if value is None:
return False
return value.strip().lower() in {"1", "true", "yes"}

7 changes: 3 additions & 4 deletions src/constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
Centralized constants for the SAMO project.
"""Centralized constants for the SAMO project.

This module contains all shared constants to avoid duplication across modules.
"""

import os

# Emotion model configuration
DEFAULT_EMOTION_MODEL_DIR = '/app/models/emotion-english-distilroberta-base'
EMOTION_MODEL_DIR = os.getenv('EMOTION_MODEL_DIR', DEFAULT_EMOTION_MODEL_DIR)
DEFAULT_EMOTION_MODEL_DIR = "/app/models/emotion-english-distilroberta-base"
EMOTION_MODEL_DIR = os.getenv("EMOTION_MODEL_DIR", DEFAULT_EMOTION_MODEL_DIR)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current use of os.getenv with a default value does not account for cases where the EMOTION_MODEL_DIR environment variable is set to an empty string. This would result in EMOTION_MODEL_DIR being an empty string, potentially causing unexpected behavior like writing to the current working directory. Using an or fallback would more robustly handle both unset and empty environment variables.

Suggested change
EMOTION_MODEL_DIR = os.getenv("EMOTION_MODEL_DIR", DEFAULT_EMOTION_MODEL_DIR)
EMOTION_MODEL_DIR = os.getenv("EMOTION_MODEL_DIR") or DEFAULT_EMOTION_MODEL_DIR

Loading