davanstrien HF Staff commited on
Commit
a7e4157
·
1 Parent(s): b366864

Fix dataset card push with whoami for repo ID resolution

Browse files
Files changed (1) hide show
  1. numarkdown-ocr.py +18 -5
numarkdown-ocr.py CHANGED
@@ -40,7 +40,7 @@ from datetime import datetime
40
 
41
  import torch
42
  from datasets import load_dataset
43
- from huggingface_hub import DatasetCard, login
44
  from PIL import Image
45
  from toolz import partition_all
46
  from tqdm.auto import tqdm
@@ -456,13 +456,26 @@ def main(
456
  split=split,
457
  )
458
 
459
- card = DatasetCard(card_content)
460
- card.push_to_hub(output_dataset, token=HF_TOKEN)
461
- logger.info("✅ Dataset card created and pushed!")
 
 
 
 
 
 
 
 
 
 
 
 
 
462
 
463
  logger.info("✅ OCR conversion complete!")
464
  logger.info(
465
- f"Dataset available at: https://huggingface.co/datasets/{output_dataset}"
466
  )
467
 
468
 
 
40
 
41
  import torch
42
  from datasets import load_dataset
43
+ from huggingface_hub import DatasetCard, HfApi, login
44
  from PIL import Image
45
  from toolz import partition_all
46
  from tqdm.auto import tqdm
 
456
  split=split,
457
  )
458
 
459
+ # Handle dataset card push with proper repo_id
460
+ full_repo_id = output_dataset
461
+ try:
462
+ card = DatasetCard(card_content)
463
+ # If output_dataset doesn't contain a username, get the current user's name
464
+ if "/" not in output_dataset:
465
+ api = HfApi(token=HF_TOKEN)
466
+ user_info = api.whoami()
467
+ full_repo_id = f"{user_info['name']}/{output_dataset}"
468
+ logger.info(f"Using full repo ID: {full_repo_id}")
469
+
470
+ card.push_to_hub(full_repo_id, token=HF_TOKEN)
471
+ logger.info("✅ Dataset card created and pushed!")
472
+ except Exception as e:
473
+ logger.warning(f"Could not push dataset card: {e}")
474
+ logger.info("Dataset was successfully created but card upload failed. You can add it manually.")
475
 
476
  logger.info("✅ OCR conversion complete!")
477
  logger.info(
478
+ f"Dataset available at: https://huggingface.co/datasets/{full_repo_id}"
479
  )
480
 
481