Joseph Pollack commited on
Commit
708960a
·
unverified ·
1 Parent(s): 9f8cd0c

attempts to replace autogenerated model card with template readme.md

Browse files
Files changed (1) hide show
  1. scripts/push_to_huggingface.py +14 -13
scripts/push_to_huggingface.py CHANGED
@@ -580,21 +580,22 @@ MIT License
580
  if results is None:
581
  results = self._load_training_results()
582
 
583
- # Create and upload model card
584
  model_card = self.create_model_card(training_config, results)
585
- model_card_path = Path("temp_model_card.md")
586
- with open(model_card_path, "w", encoding="utf-8") as f:
587
- f.write(model_card)
588
-
589
  try:
590
- upload_file(
591
- path_or_fileobj=str(model_card_path),
592
- path_in_repo="README.md",
593
- repo_id=self.repo_id,
594
- token=self.token
595
- )
596
- finally:
597
- model_card_path.unlink()
 
 
 
 
598
 
599
  # Upload model files
600
  if not self.upload_model_files():
 
580
  if results is None:
581
  results = self._load_training_results()
582
 
583
+ # Create model card and persist it inside the model directory as README.md
584
  model_card = self.create_model_card(training_config, results)
585
+ local_readme_path = self.model_path / "README.md"
 
 
 
586
  try:
587
+ with open(local_readme_path, "w", encoding="utf-8") as f:
588
+ f.write(model_card)
589
+ except Exception as e:
590
+ logger.warning(f"⚠️ Could not write README.md to model directory: {e}")
591
+
592
+ # Upload README.md from the model directory
593
+ upload_file(
594
+ path_or_fileobj=str(local_readme_path) if local_readme_path.exists() else model_card,
595
+ path_in_repo="README.md",
596
+ repo_id=self.repo_id,
597
+ token=self.token
598
+ )
599
 
600
  # Upload model files
601
  if not self.upload_model_files():