Spaces:
Runtime error
Runtime error
Ray Chen commited on
Commit ·
4112a5c
1
Parent(s): d809b84
change: update README.md by GitHub Actions
Browse filesFiles changed (4)
4 unmodified lines567889101112131415161718192021224 unmodified linesUserName = Literal["default"]
SPACE_CONFIG: Dict[UserName, Config] = { "default": {"space_name": "example", "space_owner": "jy-raychen"} "default": { "space_name": "example", "space_owner": "jy-raychen", "space_readme": { "title": "Hugging Face Maintain", "emoji": "🏢", "color_from": "blue", "color_to": "indigo", "sdk": "gradio", "sdk_version": "4.36.0", "app_file": "app.py", "pinned": False, }, }}1234567891011121314151617181920212223242526272829import sys
from config import SPACE_CONFIGfrom model import ReadMe, Space
DEFAULT_USER = "jy-raychen"
def readme_template(readme: ReadMe): return f"""---title: {readme.title}emoji: {readme.emoji}colorFrom: {readme.color_from}colorTo: {readme.color_to}sdk: {readme.sdk}sdk_version: {readme.sdk_version}app_file: {readme.app_file}pinned: {readme.pinned}---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference"""
if __name__ == "__main__": space = Space(SPACE_CONFIG["default"])
readme = readme_template(space.readme) print(readme) sys.exit(0)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950from typing import TypedDict
class ReadMeConfig(TypedDict): title: str emoji: str color_from: str color_to: str sdk: str sdk_version: str app_file: str pinned: bool
class ReadMe: title: str emoji: str color_from: str color_to: str sdk: str sdk_version: str app_file: str pinned: str
def __init__(self, readme_config: ReadMeConfig): self.title = readme_config["title"] self.emoji = readme_config["emoji"] self.color_from = readme_config["color_from"] self.color_to = readme_config["color_to"] self.sdk = readme_config["sdk"] self.sdk_version = readme_config["sdk_version"] self.app_file = readme_config["app_file"] self.pinned = str(readme_config["pinned"]).lower()
class Config(TypedDict): space_name: str space_owner: str space_readme: ReadMe
class Space: name: str owner: str readme: ReadMeConfig
def __init__(self, config: Config): self.name = config["space_name"] self.owner = config["space_owner"] self.readme = ReadMe(config["space_readme"])19 unmodified lines202122232425262728293031323319 unmodified lines uses: actions/checkout@v4 with: fetch-depth: '0' - name: Update Repo README.md run: | python3 .github/tools/generate_readme.py > README.md git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "GitHub Actions[bot]" git add ./README.md if [[ `git status --porcelain` ]]; then git commit -m "[skip ci] update README.md" fi - name: Run deploy tool run: python3 .github/tools/deploy_to_space.py --branch_name="${{ github.ref_name }}" --user_token="${{ secrets.HF_TOKEN }}".github/tools/config.py+14-1
.github/tools/generate_readme.pyAdded+29
.github/tools/model.py+35
.github/workflows/deploy-to-space.yaml+9