Skip to content
Open
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
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install -r backend/requirements.txt
pip install pytest pytest-cov
pip install flask-wtf bleach Pillow beautifulsoup4 "pydantic[email]"
pip install flask-wtf bleach Pillow beautifulsoup4 flask-caching "pydantic[email]"

- name: Run pytest
env:
Expand All @@ -57,10 +57,5 @@ jobs:
PYTHONPATH: ".:backend"
run: |
python -m pytest tests/ \
--ignore=tests/test_llm.py \
--ignore=tests/test_mood_improvements.py \
--ignore=tests/test_mood_cache_db.py \
--ignore=tests/test_category_cache.py \
--ignore=tests/test_env_validation.py \
--ignore=tests/test_purchase_links.py \
-v --tb=short --cov=backend
11 changes: 11 additions & 0 deletions backend/cache_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
except ImportError:
REDIS_AVAILABLE = False
REDIS_EXCEPTIONS = ()
try:
from flask_caching import Cache
except ImportError:
Cache = None

def with_redis_retry():
"""Retry decorator for Redis transient failures."""
Expand Down Expand Up @@ -193,6 +197,13 @@ def init_app(self, app):
else:
cache_config['CACHE_TYPE'] = 'SimpleCache'
logger.info("Using simple in-memory cache (not recommended for production)")

if Cache is None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Returning early here leaves self.cache unset. Downstream code that assumes self.cache exists may raise an AttributeError. Would it be safer to initialize a fallback cache implementation or explicitly set self.cache = None before returning?

logger.warning(
"flask-caching is not installed; caching is disabled. "
"Add flask-caching to requirements.txt."
)
return

self.cache = Cache()
self.cache.init_app(app, config=cache_config)
Expand Down
129 changes: 86 additions & 43 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,86 @@
Flask
flask-cors
Flask-JWT-Extended
Flask-Limiter
Flask-Migrate
Flask-SQLAlchemy
SQLAlchemy
numpy
pandas
scikit-learn
scipy
sentence-transformers
transformers
torch
tokenizers
huggingface_hub
safetensors
textblob
nltk
pydantic
python-dotenv
requests
Werkzeug
Jinja2
click
itsdangerous
MarkupSafe
joblib
threadpoolctl
typing_extensions
packaging
PyYAML
regex
tqdm
filelock
fsspec
networkx
sympy
textblob==0.19.0
tenacity
python-magic

flask-socketio==5.3.6
Flask

flask-cors

Flask-JWT-Extended

Flask-Limiter

Flask-Migrate

Flask-SQLAlchemy

SQLAlchemy

numpy

pandas

scikit-learn

scipy

sentence-transformers

transformers

torch

tokenizers

huggingface_hub

safetensors

textblob

nltk

pydantic

python-dotenv

requests

Werkzeug

Jinja2

click

itsdangerous

MarkupSafe

joblib

threadpoolctl

typing_extensions

packaging

PyYAML

regex

tqdm

filelock

fsspec

networkx

sympy

textblob==0.19.0
tenacity

python-magic


flask-socketio==5.3.6
beautifulsoup4
flask-caching
vaderSentiment
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@

# Stub out heavy optional packages so tests don't need GPU/model downloads
for _mod in [
# Windows / platform-specific
"magic",
"spine_generator",
# Mood analysis stack
"vaderSentiment",
"vaderSentiment.vaderSentiment",
# ML / NLP stack (already present, keeping for clarity)
"transformers", "sentence_transformers",
"nltk", "nltk.tokenize", "nltk.tokenize.api",
"nltk", "nltk.corpus", "nltk.tokenize", "nltk.tokenize.api",
"huggingface_hub", "safetensors", "tokenizers", "tqdm", "joblib",
"textblob", "textblob.blob", "textblob.base",
]:
Expand Down
Loading
Loading