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 lines567894 unmodified linesUserName = Literal["default"]SPACE_CONFIG: Dict[UserName, Config] = {"default": {"space_name": "example", "space_owner": "jy-raychen"}}4 unmodified lines56789101112131415161718192021224 unmodified linesUserName = Literal["default"]SPACE_CONFIG: Dict[UserName, Config] = {"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)123456789101112131415from typing import TypedDictclass Config(TypedDict):space_name: strspace_owner: strclass Space:name: strowner: strdef __init__(self, config: Config):self.name = config["space_name"]self.owner = config["space_owner"]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950from typing import TypedDictclass ReadMeConfig(TypedDict):title: stremoji: strcolor_from: strcolor_to: strsdk: strsdk_version: strapp_file: strpinned: boolclass ReadMe:title: stremoji: strcolor_from: strcolor_to: strsdk: strsdk_version: strapp_file: strpinned: strdef __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: strspace_owner: strspace_readme: ReadMeclass Space:name: strowner: strreadme: ReadMeConfigdef __init__(self, config: Config):self.name = config["space_name"]self.owner = config["space_owner"]self.readme = ReadMe(config["space_readme"])
19 unmodified lines202122232419 unmodified linesuses: actions/checkout@v4with:fetch-depth: '0'- name: Run deploy toolrun: python3 .github/tools/deploy_to_space.py --branch_name="${{ github.ref_name }}" --user_token="${{ secrets.HF_TOKEN }}"19 unmodified lines202122232425262728293031323319 unmodified linesuses: actions/checkout@v4with:fetch-depth: '0'- name: Update Repo README.mdrun: |python3 .github/tools/generate_readme.py > README.mdgit config --global user.email "github-actions[bot]@users.noreply.github.com"git config --global user.name "GitHub Actions[bot]"git add ./README.mdif [[ `git status --porcelain` ]]; thengit commit -m "[skip ci] update README.md"fi- name: Run deploy toolrun: 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