iyadsultan commited on
Commit
d21edc9
·
1 Parent(s): 865d0a6

Refactor session management in evaluation process to remove forced persistence

Browse files

Eliminate the use of permanent sessions during document navigation actions, simplifying session handling. Update comments for clarity on session configuration.

Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -18,9 +18,8 @@ DATA_DIR = os.environ.get('DATA_DIR', '/tmp/human_notes_evaluator')
18
  app = Flask(__name__)
19
  app.secret_key = os.environ.get('SECRET_KEY', 'your-secret-key-here') # Gets from env or uses default
20
 
21
- # Configure session to use signed cookies instead of filesystem (better for HF Spaces)
22
  app.config['SESSION_PERMANENT'] = False
23
- app.config['SESSION_USE_SIGNER'] = True
24
 
25
  # Constants
26
  CRITERIA = [
@@ -430,7 +429,6 @@ def evaluate():
430
  documents = load_documents()
431
  if jump_to >= 1 and jump_to <= len(documents):
432
  session['current_document_index'] = jump_to # Store as 1-based index
433
- session.permanent = True # Force session to be saved
434
  print(f"DEBUG JUMP: Setting document index to {jump_to}")
435
  log_error(f"JUMP: Setting document index to {jump_to}")
436
  else:
@@ -511,7 +509,6 @@ def evaluate():
511
  current_index = session.get('current_document_index', 1)
512
  new_index = current_index + 1
513
  session['current_document_index'] = new_index
514
- session.permanent = True # Force session to be saved
515
  print(f"DEBUG SKIP: Moved from document {current_index} to {new_index}")
516
  log_error(f"SKIP: Moved from document {current_index} to {new_index}")
517
 
@@ -567,7 +564,6 @@ def evaluate():
567
  # Move to next document
568
  new_index = current_index + 1
569
  session['current_document_index'] = new_index
570
- session.permanent = True # Force session to be saved
571
  print(f"DEBUG SUBMIT: Moved from document {current_index} to {new_index}")
572
  log_error(f"SUBMIT: Moved from document {current_index} to {new_index}")
573
 
 
18
  app = Flask(__name__)
19
  app.secret_key = os.environ.get('SECRET_KEY', 'your-secret-key-here') # Gets from env or uses default
20
 
21
+ # Configure session
22
  app.config['SESSION_PERMANENT'] = False
 
23
 
24
  # Constants
25
  CRITERIA = [
 
429
  documents = load_documents()
430
  if jump_to >= 1 and jump_to <= len(documents):
431
  session['current_document_index'] = jump_to # Store as 1-based index
 
432
  print(f"DEBUG JUMP: Setting document index to {jump_to}")
433
  log_error(f"JUMP: Setting document index to {jump_to}")
434
  else:
 
509
  current_index = session.get('current_document_index', 1)
510
  new_index = current_index + 1
511
  session['current_document_index'] = new_index
 
512
  print(f"DEBUG SKIP: Moved from document {current_index} to {new_index}")
513
  log_error(f"SKIP: Moved from document {current_index} to {new_index}")
514
 
 
564
  # Move to next document
565
  new_index = current_index + 1
566
  session['current_document_index'] = new_index
 
567
  print(f"DEBUG SUBMIT: Moved from document {current_index} to {new_index}")
568
  log_error(f"SUBMIT: Moved from document {current_index} to {new_index}")
569