trohrbaugh commited on
Commit
c93a7ed
Β·
verified Β·
1 Parent(s): 99cd6c3

DNA-017: startup+per-scan logging diagnostics, flush every 1min

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -23,6 +23,7 @@ from scan import scan, inspect_gguf, KNOWN_BASES
23
  import os as _os, json as _json, datetime as _dt
24
  from pathlib import Path as _Path
25
  _SCAN_LOGGER = None
 
26
  try:
27
  _log_token = _os.environ.get("LOG_TOKEN")
28
  if _log_token:
@@ -31,11 +32,15 @@ try:
31
  _LOG_FILE = _LOG_DIR / "scans.jsonl"
32
  _SCAN_LOGGER = CommitScheduler(
33
  repo_id="RadicalNotionAI/modeldna-scan-log", repo_type="dataset",
34
- folder_path=str(_LOG_DIR), every=10, token=_log_token,
35
  path_in_repo="data", squash_history=False,
36
  )
37
- except Exception:
 
 
 
38
  _SCAN_LOGGER = None
 
39
 
40
  def log_scan(model_id: str, result: dict) -> None:
41
  if _SCAN_LOGGER is None:
@@ -57,8 +62,9 @@ def log_scan(model_id: str, result: dict) -> None:
57
  with _SCAN_LOGGER.lock:
58
  with open(_LOG_FILE, "a") as fh:
59
  fh.write(_json.dumps(rec) + "\n")
60
- except Exception:
61
- pass
 
62
 
63
  # ── Discovery: find derivatives that may not attribute properly ────────────
64
 
 
23
  import os as _os, json as _json, datetime as _dt
24
  from pathlib import Path as _Path
25
  _SCAN_LOGGER = None
26
+ _LOG_FILE = None
27
  try:
28
  _log_token = _os.environ.get("LOG_TOKEN")
29
  if _log_token:
 
32
  _LOG_FILE = _LOG_DIR / "scans.jsonl"
33
  _SCAN_LOGGER = CommitScheduler(
34
  repo_id="RadicalNotionAI/modeldna-scan-log", repo_type="dataset",
35
+ folder_path=str(_LOG_DIR), every=1, token=_log_token,
36
  path_in_repo="data", squash_history=False,
37
  )
38
+ print("[DNA-017] scan logging ENABLED -> RadicalNotionAI/modeldna-scan-log (flush every 1 min)", flush=True)
39
+ else:
40
+ print("[DNA-017] scan logging DISABLED: LOG_TOKEN env var not set/empty", flush=True)
41
+ except Exception as _e:
42
  _SCAN_LOGGER = None
43
+ print(f"[DNA-017] scan logging DISABLED: scheduler init failed: {_e!r}", flush=True)
44
 
45
  def log_scan(model_id: str, result: dict) -> None:
46
  if _SCAN_LOGGER is None:
 
62
  with _SCAN_LOGGER.lock:
63
  with open(_LOG_FILE, "a") as fh:
64
  fh.write(_json.dumps(rec) + "\n")
65
+ print(f"[DNA-017] logged scan: {model_id} ({rec['confidence']}/{rec['risk_band']})", flush=True)
66
+ except Exception as _e:
67
+ print(f"[DNA-017] log_scan failed for {model_id}: {_e!r}", flush=True)
68
 
69
  # ── Discovery: find derivatives that may not attribute properly ────────────
70