human_evaluator / HF_FIX_SUMMARY.md
iyadsultan's picture
Switch session storage from filesystem to in-memory for HF Spaces compatibility, eliminating permission issues. Update relevant environment variable logging and adjust documentation to reflect changes in session management.
371c595

HF Spaces Data Persistence Fix

Problem

The application was using /tmp/human_notes_evaluator for data storage, which is ephemeral on HF Spaces and gets cleared between requests/restarts.

Solution Applied

  1. Forced persistent DATA_DIR: Changed from environment-dependent to forced persistent location

    DATA_DIR = os.path.join(os.getcwd(), 'data')  # Always use ./data/
    
  2. Added startup logging: Clear messages showing which directory is being used

    IMPORTANT: Using DATA_DIR = /path/to/your/space/data
    
  3. Fixed session storage: Switched from filesystem to in-memory sessions for HF compatibility

    # Removed filesystem session config that caused permission errors
    app.config['SESSION_PERMANENT'] = False  # Simple in-memory sessions
    
  4. Enhanced debugging: Added /hf-debug route to diagnose HF-specific issues

Expected Result

  • Data will now persist in ./data/ directory
  • Evaluations saved to ./data/evaluations.csv
  • Sessions stored in-memory (HF Spaces compatible)
  • Documents loaded from ./data/documents.csv

How to Verify on HF

  1. Push these changes to HF Spaces
  2. Check startup logs - should show DATA_DIR = /path/to/space/data
  3. Visit /hf-debug route to see system info
  4. Test evaluation submission and check results persistence

Key Files Changed

  • app.py - Main DATA_DIR fix and logging
  • DEPLOYMENT.md - Deployment instructions
  • requirements.txt - Dependencies
  • .gitignore - Exclude data files

Debug Routes

  • /debug - Full application debug info
  • /hf-debug - HF Spaces specific debugging

Next Steps

  1. Commit and push to HF Spaces
  2. Check startup logs for DATA_DIR confirmation
  3. Upload documents.csv to the space
  4. Test evaluation workflow
  5. Use debug routes if issues persist