tao-shen Claude Opus 4.6 commited on
Commit
228e377
·
1 Parent(s): ebd3783

fix: remove all stderr redirects so HF log API captures output

Browse files

Reverted to original pattern: no redirects in background subshell,
let Python stderr flow naturally to container stderr for HF capture.
Sync daemon now also appends to /var/log/huggingrun.log directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

scripts/entrypoint.sh CHANGED
@@ -59,7 +59,7 @@ try:
59
  except:
60
  api.create_repo(repo_id=repo, repo_type='dataset', private=True)
61
  print(f'[entrypoint] Created dataset: {repo}', flush=True)
62
- " 2>&1 | tee -a "$LOGFILE" >&2 || log "[entrypoint] WARNING: Could not verify dataset"
63
  else
64
  log "[entrypoint] WARNING: persistence disabled (no token/repo)"
65
  fi
@@ -74,12 +74,12 @@ log "[entrypoint] Wrote /etc/huggingrun.env"
74
 
75
  # Background: init (download + restore) then start sync-loop
76
  # This runs AFTER services start so HF doesn't timeout
77
- # IMPORTANT: do NOT redirect stderr (2>&1) HF captures stderr for runtime logs
78
  (
79
- log "[entrypoint:bg] Starting init in background ..."
80
- python3 -u /opt/git_sync_daemon.py init 2>&1 | tee -a "$LOGFILE" >&2
81
- log "[entrypoint:bg] Init done, starting sync-loop ..."
82
- python3 -u /opt/git_sync_daemon.py sync-loop 2>&1 | tee -a "$LOGFILE" >&2
83
  ) &
84
  BG_PID=$!
85
  log "[entrypoint] Background init+sync PID=${BG_PID}"
 
59
  except:
60
  api.create_repo(repo_id=repo, repo_type='dataset', private=True)
61
  print(f'[entrypoint] Created dataset: {repo}', flush=True)
62
+ " 2>&1 || echo "[entrypoint] WARNING: Could not verify dataset" >&2
63
  else
64
  log "[entrypoint] WARNING: persistence disabled (no token/repo)"
65
  fi
 
74
 
75
  # Background: init (download + restore) then start sync-loop
76
  # This runs AFTER services start so HF doesn't timeout
77
+ # NO redirects here stderr must flow to container stderr for HF log API
78
  (
79
+ echo "[entrypoint:bg] Starting init in background ..." >&2
80
+ python3 -u /opt/git_sync_daemon.py init
81
+ echo "[entrypoint:bg] Init done, starting sync-loop ..." >&2
82
+ exec python3 -u /opt/git_sync_daemon.py sync-loop
83
  ) &
84
  BG_PID=$!
85
  log "[entrypoint] Background init+sync PID=${BG_PID}"
ubuntu-server/git_sync_daemon.py CHANGED
@@ -41,9 +41,17 @@ UPLOAD_IGNORE = [
41
  ]
42
 
43
 
 
 
44
  def log(msg):
45
  ts = time.strftime("%H:%M:%S", time.gmtime())
46
- print(f"[sync {ts}] {msg}", file=sys.stderr, flush=True)
 
 
 
 
 
 
47
 
48
 
49
  def run(cmd, cwd=None):
 
41
  ]
42
 
43
 
44
+ LOGFILE = "/var/log/huggingrun.log"
45
+
46
  def log(msg):
47
  ts = time.strftime("%H:%M:%S", time.gmtime())
48
+ line = f"[sync {ts}] {msg}"
49
+ print(line, file=sys.stderr, flush=True)
50
+ try:
51
+ with open(LOGFILE, "a") as f:
52
+ f.write(line + "\n")
53
+ except Exception:
54
+ pass
55
 
56
 
57
  def run(cmd, cwd=None):