Skip to content

Commit 06e15fe

Browse files
jeremymanningclaude
andcommitted
Add debug output to HuggingFace API validation
Adds comprehensive debugging to help troubleshoot HuggingFace token validation issues: - Shows API response status code and error messages - Displays user info returned by API - Compares expected vs actual usernames - Captures and displays any exceptions This will help diagnose whether token issues are API-related, token-related, or username mismatches. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6b0b003 commit 06e15fe

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

clustrix/notebook_magic.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,10 +2097,35 @@ def _test_huggingface_connectivity(self, config):
20972097
"https://huggingface.co/api/whoami", headers=headers, timeout=10
20982098
)
20992099

2100+
# Debug: Print response details for troubleshooting
2101+
if hasattr(self, "status_output"):
2102+
with self.status_output:
2103+
print(
2104+
f"🔍 Debug: HuggingFace API response status: {response.status_code}"
2105+
)
2106+
if response.status_code != 200:
2107+
print(f"🔍 Debug: Response text: {response.text[:200]}...")
2108+
21002109
if response.status_code == 200:
21012110
user_info = response.json()
2111+
2112+
# Debug: Print user info for troubleshooting
2113+
if hasattr(self, "status_output"):
2114+
with self.status_output:
2115+
print(f"🔍 Debug: User info keys: {list(user_info.keys())}")
2116+
print(
2117+
f"🔍 Debug: User name from API: '{user_info.get('name', 'NOT_FOUND')}'"
2118+
)
2119+
if hf_username:
2120+
print(f"🔍 Debug: Expected username: '{hf_username}'")
2121+
21022122
# Verify username if provided
21032123
if hf_username and user_info.get("name") != hf_username:
2124+
if hasattr(self, "status_output"):
2125+
with self.status_output:
2126+
print(
2127+
f"🔍 Debug: Username mismatch - API: '{user_info.get('name')}', Expected: '{hf_username}'"
2128+
)
21042129
return False
21052130
return True
21062131

@@ -2109,7 +2134,11 @@ def _test_huggingface_connectivity(self, config):
21092134
except ImportError:
21102135
print("ℹ️ requests library not available for HuggingFace testing")
21112136
return False
2112-
except Exception:
2137+
except Exception as e:
2138+
# Debug: Print exception details
2139+
if hasattr(self, "status_output"):
2140+
with self.status_output:
2141+
print(f"🔍 Debug: Exception during HuggingFace test: {str(e)}")
21132142
return False
21142143

21152144
def _on_test_config(self, button):

0 commit comments

Comments
 (0)