Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add readme_path to config for HF model cards #142

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/delphi/train/config/training_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class TrainingConfig:
# third party
wandb: Optional[WandbConfig] = None
out_repo_id: str
readme_path: str = field(
default="",
metadata={"help": "for HF model card"},
)

# debug
debug_config: DebugConfig = field(default_factory=DebugConfig)
3 changes: 3 additions & 0 deletions src/delphi/train/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import math
import os
import shutil
import time
from collections.abc import Generator
from dataclasses import asdict, dataclass, field
Expand Down Expand Up @@ -275,6 +276,8 @@ def save_results(
run_context_dict = asdict(run_context)
run_context_dict["device"] = str(run_context.device)
json.dump(run_context_dict, file, indent=2)
if config.readme_path:
shutil.copy(config.readme_path, os.path.join(results_path, "README.md"))
if config.out_repo_id:
api = HfApi()
api.create_repo(config.out_repo_id, exist_ok=True)
Expand Down
Loading