cfahlgren1 HF Staff commited on
Commit
1846b49
·
verified ·
1 Parent(s): f461000

Update hub-stats.py

Browse files
Files changed (1) hide show
  1. hub-stats.py +11 -6
hub-stats.py CHANGED
@@ -28,6 +28,15 @@ load_dotenv()
28
  CACHE_DIR = ".hf_cache"
29
  os.makedirs(CACHE_DIR, exist_ok=True)
30
 
 
 
 
 
 
 
 
 
 
31
  ENDPOINT_CONFIGS = {
32
  "models": {
33
  "limit": 1000,
@@ -144,7 +153,6 @@ def process_dataframe(df, endpoint):
144
  None
145
  )
146
 
147
- # Handle gated column - convert to string to handle mixed types
148
  if "gated" in df.columns:
149
  df["gated"] = df["gated"].astype(str)
150
 
@@ -245,7 +253,7 @@ async def create_parquet_files(skip_upload=False):
245
  print(f"✓ {endpoint}: {len(df):,} rows -> {output_file}")
246
 
247
  if not skip_upload:
248
- upload_to_hub(output_file)
249
 
250
  elapsed = time.time() - start_time
251
  return created_files, elapsed
@@ -280,10 +288,7 @@ def recreate_from_jsonl():
280
  print(f"✓ {endpoint}: {len(df):,} rows -> {output_file}")
281
 
282
 
283
- def upload_to_hub(file_path):
284
- api = HfApi()
285
- repo_id = "cfahlgren1/hub-stats"
286
-
287
  try:
288
  api.upload_file(
289
  path_or_fileobj=file_path,
 
28
  CACHE_DIR = ".hf_cache"
29
  os.makedirs(CACHE_DIR, exist_ok=True)
30
 
31
+ api = HfApi()
32
+ USER_ID = api.whoami()["name"]
33
+ REPO_ID = f"{USER_ID}/hub-stats"
34
+
35
+ print(f"🚀 Hugging Face Hub Stats Collector")
36
+ print(f"📊 Dataset will be uploaded to: {REPO_ID}")
37
+ print(f"👤 User: {USER_ID}")
38
+ print("-" * 50)
39
+
40
  ENDPOINT_CONFIGS = {
41
  "models": {
42
  "limit": 1000,
 
153
  None
154
  )
155
 
 
156
  if "gated" in df.columns:
157
  df["gated"] = df["gated"].astype(str)
158
 
 
253
  print(f"✓ {endpoint}: {len(df):,} rows -> {output_file}")
254
 
255
  if not skip_upload:
256
+ upload_to_hub(output_file, REPO_ID)
257
 
258
  elapsed = time.time() - start_time
259
  return created_files, elapsed
 
288
  print(f"✓ {endpoint}: {len(df):,} rows -> {output_file}")
289
 
290
 
291
+ def upload_to_hub(file_path, repo_id):
 
 
 
292
  try:
293
  api.upload_file(
294
  path_or_fileobj=file_path,