adf0d17497
publish / version_or_publish (push) Waiting to run
storybook-build / changes (push) Waiting to run
storybook-build / :storybook-build (push) Blocked by required conditions
Sync Gradio Skills to Hugging Face / sync-skills (push) Waiting to run
functional / changes (push) Waiting to run
functional / build-frontend (push) Blocked by required conditions
functional / functional-test-SSR=false (push) Blocked by required conditions
functional / functional-reload (push) Blocked by required conditions
functional / functional-test-SSR=true (push) Blocked by required conditions
hygiene / hygiene-test (push) Waiting to run
python / changes (push) Waiting to run
python / build (push) Blocked by required conditions
python / test-ubuntu-latest-flaky (push) Blocked by required conditions
python / test-ubuntu-latest-not-flaky (push) Blocked by required conditions
python / test-windows-latest-flaky (push) Blocked by required conditions
python / test-windows-latest-not-flaky (push) Blocked by required conditions
js / changes (push) Waiting to run
js / js-test (push) Blocked by required conditions
docs-build / changes (push) Waiting to run
docs-build / docs-build (push) Blocked by required conditions
docs-build / website-build (push) Blocked by required conditions
92 lines
2.6 KiB
Python
92 lines
2.6 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import pathlib
|
|
|
|
from huggingface_hub import upload_folder
|
|
|
|
|
|
def copy_js_code(root: str | pathlib.Path, hf_token: str | None = None):
|
|
NOT_COMPONENT = [
|
|
"app",
|
|
"node_modules",
|
|
"storybook",
|
|
"playwright-report",
|
|
"workbench",
|
|
"tooltils",
|
|
"component-test",
|
|
"core",
|
|
"spa",
|
|
]
|
|
print("COPYING JS CODE TO gradio/_frontend_code/")
|
|
version = json.load(open(pathlib.Path(root) / "gradio" / "package.json"))["version"]
|
|
for entry in (pathlib.Path(root) / "js").iterdir():
|
|
if (
|
|
entry.is_dir()
|
|
and not str(entry.name).startswith("_")
|
|
and str(entry.name) not in NOT_COMPONENT
|
|
):
|
|
print("entry:", entry)
|
|
upload_folder(
|
|
repo_id="gradio/frontend",
|
|
repo_type="dataset",
|
|
folder_path=str(entry),
|
|
path_in_repo=f"{version}/{entry.name}",
|
|
ignore_patterns=[
|
|
"CHANGELOG*",
|
|
"README.md",
|
|
"*/node_modules/*", # Matches content within node_modules folders
|
|
"*.test.*",
|
|
"*.stories.*",
|
|
"*.spec.*",
|
|
".svelte-kit/*",
|
|
"dist/**",
|
|
],
|
|
allow_patterns=[
|
|
"*.ts",
|
|
"*.svelte",
|
|
"*.json",
|
|
"**/*.ts",
|
|
"**/*.svelte",
|
|
"**/*.json",
|
|
],
|
|
token=hf_token,
|
|
)
|
|
upload_folder(
|
|
repo_id="gradio/frontend",
|
|
repo_type="dataset",
|
|
folder_path=str(pathlib.Path(root) / "client" / "js"),
|
|
path_in_repo=f"{version}/client",
|
|
ignore_patterns=[
|
|
"CHANGELOG*",
|
|
"README.md",
|
|
"*/node_modules/*", # Matches content within node_modules folders
|
|
"*.test.*",
|
|
"*.stories.*",
|
|
"*.spec.*",
|
|
".svelte-kit/*",
|
|
"dist/**",
|
|
],
|
|
allow_patterns=[
|
|
"*.ts",
|
|
"*.svelte",
|
|
"*.json",
|
|
"**/*.ts",
|
|
"**/*.svelte",
|
|
"**/*.json",
|
|
],
|
|
token=hf_token,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description="Sync Frontend code to dataset")
|
|
parser.add_argument("hf_token", type=str, help="HF API token")
|
|
args = parser.parse_args()
|
|
|
|
current_dir = pathlib.Path(__file__).parent.resolve()
|
|
|
|
copy_js_code((current_dir / "..").resolve(), hf_token=args.hf_token)
|