gheinrich commited on
Commit
c0dc5d2
·
1 Parent(s): 8d7976d

Remove account/org info dump from startup logs

Browse files

Drop the whoami-based Hub access check; keep only the masked token-present log.

Files changed (1) hide show
  1. app.py +0 -39
app.py CHANGED
@@ -97,45 +97,6 @@ IMAGE_GUARD_MODEL_ID = os.getenv("IMAGE_GUARD_MODEL_ID", DEFAULT_IMAGE_GUARD_MOD
97
  IMAGE_GUARD_THRESHOLD = float(
98
  os.getenv("IMAGE_GUARD_THRESHOLD", str(DEFAULT_IMAGE_GUARD_THRESHOLD))
99
  )
100
-
101
-
102
- def _log_hub_access() -> None:
103
- """Log which account the token maps to and whether it can see MODEL_ID."""
104
- if not HF_TOKEN:
105
- return
106
- try:
107
- from huggingface_hub import HfApi, whoami
108
-
109
- try:
110
- me = whoami(token=HF_TOKEN)
111
- orgs = [o.get("name") for o in me.get("orgs", [])]
112
- print(
113
- f"HF token belongs to '{me.get('name')}' (orgs: {orgs or 'none'}).",
114
- flush=True,
115
- )
116
- except Exception as exc: # noqa: BLE001
117
- print(f"WARNING: token whoami failed: {exc}", flush=True)
118
- return
119
-
120
- try:
121
- info = HfApi().model_info(MODEL_ID, token=HF_TOKEN)
122
- print(
123
- f"Access OK: '{MODEL_ID}' is reachable (private={info.private}).",
124
- flush=True,
125
- )
126
- except Exception as exc: # noqa: BLE001
127
- print(
128
- f"ERROR: token cannot access '{MODEL_ID}': "
129
- f"{type(exc).__name__}. The token's owner must have read access to "
130
- "this private repo (a 'pull access' scope is not enough if the "
131
- "account/org lacks access).",
132
- flush=True,
133
- )
134
- except Exception as exc: # noqa: BLE001
135
- print(f"WARNING: hub access check skipped: {exc}", flush=True)
136
-
137
-
138
- _log_hub_access()
139
  IMAGE_GUARD_OFFLOAD_T2I = os.getenv("IMAGE_GUARD_OFFLOAD_T2I", "0") == "1"
140
  # Opt-out: guard runs by default; set ENABLE_IMAGE_GUARD=0 or uncheck the UI box to disable.
141
  DEFAULT_ENABLE_IMAGE_GUARD = os.getenv("ENABLE_IMAGE_GUARD", "1") == "1"
 
97
  IMAGE_GUARD_THRESHOLD = float(
98
  os.getenv("IMAGE_GUARD_THRESHOLD", str(DEFAULT_IMAGE_GUARD_THRESHOLD))
99
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  IMAGE_GUARD_OFFLOAD_T2I = os.getenv("IMAGE_GUARD_OFFLOAD_T2I", "0") == "1"
101
  # Opt-out: guard runs by default; set ENABLE_IMAGE_GUARD=0 or uncheck the UI box to disable.
102
  DEFAULT_ENABLE_IMAGE_GUARD = os.getenv("ENABLE_IMAGE_GUARD", "1") == "1"