MathewKasbarian commited on
Commit
767f9c4
·
1 Parent(s): 280468b

fix(annotator): autosave dir probe crashed on shallow paths (HF Space /app)

Browse files

parents[2] raises IndexError when app.py sits near the filesystem root —
guard it. deploy_space.py now re-splits the subtree on every run and uses
get_token() (HfFolder was removed from huggingface_hub).

Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -410,20 +410,21 @@ _LABEL_DISPLAY_DPI = 100 # the Review tab canvas coordinate space
410
  # annotation change is checkpointed to disk so a browser refresh/crash loses
411
  # nothing. Files go to a staging dir, NOT the canonical labels dir — the
412
  # canonical ground truth is only ever written via merge_labels.py.
413
- _REPO_WORKING_SET = Path(__file__).resolve().parents[2] / "data" / "working_set"
414
-
415
-
416
  def _resolve_autosave_dir():
417
  env = os.environ.get("FACADE_AUTOSAVE_DIR")
418
  if env:
419
  p = Path(env)
420
  p.mkdir(parents=True, exist_ok=True)
421
  return p
422
- if _REPO_WORKING_SET.is_dir():
423
- p = _REPO_WORKING_SET / "autosave"
 
 
 
 
424
  p.mkdir(parents=True, exist_ok=True)
425
  return p
426
- return None # HF Space / standalone — autosave off
427
 
428
 
429
  _AUTOSAVE_DIR = _resolve_autosave_dir()
 
410
  # annotation change is checkpointed to disk so a browser refresh/crash loses
411
  # nothing. Files go to a staging dir, NOT the canonical labels dir — the
412
  # canonical ground truth is only ever written via merge_labels.py.
 
 
 
413
  def _resolve_autosave_dir():
414
  env = os.environ.get("FACADE_AUTOSAVE_DIR")
415
  if env:
416
  p = Path(env)
417
  p.mkdir(parents=True, exist_ok=True)
418
  return p
419
+ try:
420
+ working_set = Path(__file__).resolve().parents[2] / "data" / "working_set"
421
+ except IndexError: # app sits near filesystem root (HF Space: /app/app.py)
422
+ return None
423
+ if working_set.is_dir():
424
+ p = working_set / "autosave"
425
  p.mkdir(parents=True, exist_ok=True)
426
  return p
427
+ return None # standalone checkout — autosave off
428
 
429
 
430
  _AUTOSAVE_DIR = _resolve_autosave_dir()