fix(ci): HF Space BUILD_ERROR 解消 + deploy 前後の検証多層化 - #583
Merged
Conversation
HF Space (ayousanz/piper-plus-demo) が BUILD_ERROR で起動不能だった。 README frontmatter sdk_version=6.9.0 と requirements.txt gradio==6.16.0 が drift し、 HF Spaces ビルダーが pip install gradio==6.9.0 -r requirements.txt を 1 コマンドで実行するため resolution conflict で exit 1 (HF API は "cache miss" という misleading なメッセージで 覆い隠していた)。 修正: - huggingface-space/README.md: sdk_version を 6.16.0 に同期 (即時復旧) - scripts/check_hf_space_gradio_sync.py: 両者の exact pin 一致を検査 する script を追加 (drift 時 exit 1 + 修正手順を提示) - .gitignore: 新 script を allowlist に追加 (check_*.py blanket ignore 対策) - .github/workflows/test-hf-space.yml: Layer 0 として gate を追加 (deps install 前に fail fast、 PR 段階で検出) - .github/workflows/deploy-huggingface.yml: upload_folder 直前にも 同 gate を追加 (web UI 編集 / force-push の last-line defense) 根本原因は Dependabot #551 (2026-06-06) が requirements.txt のみ gradio 6.14.0 → 6.16.0 に bump し README frontmatter を同期しなかった こと。 gate により同種 drift を CI で事前検知可能。
Contributor
Required status-check gate (deferred)Head SHA |
Contributor
Action SHA drift reportCollected pins (3 actions) — expected_total_pins=3
Summary: total=3, ok=3 |
There was a problem hiding this comment.
Pull request overview
This PR fixes a Hugging Face Space build failure caused by Gradio version drift between the Space README frontmatter (sdk_version) and huggingface-space/requirements.txt, and adds a CI gate to prevent this drift from reoccurring.
Changes:
- Sync
huggingface-space/README.mdsdk_versionto match the pinnedgradio==...inhuggingface-space/requirements.txt. - Add
scripts/check_hf_space_gradio_sync.pyto validate READMEsdk_version↔ requirements Gradio pin consistency. - Run the gate early in both the HF Space test workflow and the deploy workflow (pre-upload).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/check_hf_space_gradio_sync.py | New validation script to enforce Gradio version consistency between README frontmatter and requirements pin. |
| huggingface-space/README.md | Bumps sdk_version to match the pinned Gradio version used by the Space. |
| .gitignore | Ensures the new check_*.py gate script is not ignored. |
| .github/workflows/test-hf-space.yml | Adds a fail-fast “Layer 0” step to detect version drift during PR validation. |
| .github/workflows/deploy-huggingface.yml | Adds a pre-deploy drift gate as last-line defense before uploading Space files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR #583 初回 CI で pre-commit が 2 hook fail: 1. check-shebang-scripts-are-executable - scripts/check_hf_space_gradio_sync.py が shebang 付きで commit されたが git index の executable bit が 100644 のまま (Windows から add した時の既定動作) - 修正: git update-index --chmod=+x で 100755 に変更 2. artifact-retention-contract.toml gate (root cause: uv.lock drift) - 本 PR の .github/workflows/*.yml 変更が artifact-retention hook の file filter に match し hook が起動。 hook は uv run python ... で実行され、 uv が PR #582 (Super-MAS) で導入された [project.optional-dependencies] super-mas を uv.lock に未反映 と検出して auto-sync (super-monotonic-align git dep + provides- extras に super-mas を追加) - hook 自体は "aligned with all upload steps" を出して contract toml に変更なし。 uv.lock の方が "files were modified by this hook" として fail 判定された - 修正: 同期された uv.lock を commit (#582 マージ後の latent drift を解消、 本 PR の workflow 変更でたまたま surface した)
PR #583 で Copilot reviewer から指摘された 4 件 (すべて logic / correctness、 style noise ではない) を修正。 1. docstring と実装の exit code 不一致 (line 26) 旧: "exit 0 if both fields are absent" 実装: 片方 None でも errors.append → exit 1 → docstring を実装に揃え、 空 pin も malformed として exit 1 を明記 2. 空 sdk_version 値を silently OK 化 (line 58) `sdk_version:` (値なし) で `""` を返し main の `is None` チェックを bypass → drift 検出を skip → `value or None` で空文字を None に正規化、 統一的に malformed 扱い 3. 非 f-string で `{sdk_version}` がリテラル出力 (line 104) エラーメッセージの該当行に `f` prefix が抜けていた → f-string 化、 実値を埋め込んで debug 性向上 (例: `gradio[oauth,mcp]==6.9.0`) 4. deploy-huggingface.yml gate が setup-python の前 (line 53) script が `str | None` 等 Python 3.10+ 構文を使うのに runner 既定 `python3` (バージョン非保証) に依存 → Set up Python を Setup deployment 直後に移動し、 gate を後に配置。 後段の重複 setup-python step は削除、 `python3` を `python` に統一
28 tasks
PR #583 の sdk_version drift 修正に続く防御層追加。 既存検証では deploy upload 成功 = 0 exit で workflow が green になり、 HF Space が BUILD_ERROR / RUNTIME_ERROR / CONFIG_ERROR / NO_APP_FILE で起動失敗していても誰も気付かな かった (2026-06 incident の根本原因)。 追加内容: 1. scripts/check_hf_space_frontmatter.py (F1-F4 対策) README YAML frontmatter の schema gate: - 必須フィールド (title / sdk / sdk_version / app_file) の存在 - app_file が huggingface-space/ 配下に実在 - sdk が gradio / streamlit / docker / static のいずれか - YAML が parse 可能 ruff + manual テスト (F1/F2/F3/F4 全 fail シナリオ + 正常 PASS) で動作確認。 2. scripts/verify_hf_space_runtime.py (F5 対策、 universal safety net) upload_folder 完了後、 HfApi.get_space_runtime を ~10 min poll し RUNNING / RUNNING_BUILDING / APP_STARTING のいずれかに到達するか BUILD_ERROR / RUNTIME_ERROR 等で fail するかを検出。 タイムアウト時も fail (build hang を可視化)。 standalone 実行可能 (manual debug 用)。 3. test-hf-space.yml: Layer 0.5 (frontmatter) + Layer 2.1 (pip check) + Layer 5 を `import app` から `create_interface()` まで拡張 (gradio API breaking change を runtime 起動前に検知)。 4. deploy-huggingface.yml: Set up Python + pre-deploy frontmatter gate + post-deploy 10-min runtime verification。
31 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HF Space (
ayousanz/piper-plus-demo) が BUILD_ERROR で起動失敗していた症状を解消すると同時に、 同種事故の再発を構造的に防ぐ多層防御 (deploy 前 2 gate + CI Layer 0/0.5/2.1/5 + post-deploy runtime verification) を追加する。 既存 deploy ワークフローはupload_folder成功で 0 exit するため、 HF Space が BUILD_ERROR / RUNTIME_ERROR / CONFIG_ERROR / NO_APP_FILE に陥っていても workflow が green になっていたのが今回の事象の根本理由。Affected Components
Type
Risk Level
Contract Impact
変更内容
huggingface-space/README.mdのsdk_version: 6.9.0 → 6.16.0scripts/check_hf_space_gradio_sync.py(sdk_version drift gate)gradio==X.Y.Zexact pin の一致を検証scripts/check_hf_space_frontmatter.py(F1-F4 対策)scripts/verify_hf_space_runtime.py(F5、 universal safety net)HfApi.get_space_runtimeを ~10min poll、 RUNNING/RUNNING_BUILDING/APP_STARTING のいずれかに到達するか BUILD_ERROR 等で fail するかを判定。 standalone 実行可能test-hf-space.yml: Layer 0 (gradio sync) + Layer 0.5 (frontmatter)test-hf-space.yml: Layer 2.1 (pip check)pip installは warning だけ出して exit 0 のことがあり、 HF 側の本番 resolve が ResolutionImpossible になっても気付かないtest-hf-space.yml: Layer 5 強化import appだけでなくcreate_interface()まで実行し Gradio Blocks 構築を検証import時には現れず、 HF Space launch 時に RUNTIME_ERROR となるdeploy-huggingface.yml: Set up Python + pre-deploy 2 gate (gradio sync / frontmatter)deploy-huggingface.yml: post-deploy runtime verification (10 min poll).gitignore更新check_hf_space_*.py/verify_hf_space_*.pyの allowlist 追加uv.lock再生成uv sync時に lock drift を検知して fail設計判断
license:を検証しない: HF は accepted license リストを独自に更新するため、 こちら側で hardcode 検証すると Dependabot 由来の license bump で false-positive する。 BUILD_ERROR 寄与度も低いため省略。uv.lock修正を含めた理由: PR feat(train): Super-MAS Triton-GPU MAS accelerator (opt-in、 推論影響ゼロ) #582 (Super-MAS) merge 時に pyproject.toml の super-mas extra が lock に反映されておらず、 pre-commit が uv sync を走らせると drift が顕在化する。 本 PR は CI/CD 強化なので pre-commit 通過のため同梱が合理的。Test Plan
python scripts/check_hf_space_gradio_sync.py(現行 README で OK + drift injection で fail)python scripts/check_hf_space_frontmatter.py(現行 README で OK + 4 failure mode injection で全て exit 1)python scripts/verify_hf_space_runtime.py --help(usage 表示)unset HF_TOKEN; python scripts/verify_hf_space_runtime.py --space-id ayousanz/piper-plus-demo --timeout-seconds 5(rc=2 で usage error)test-hf-spacejob で Layer 0 / 0.5 / 2.1 / 5 拡張すべて PASSChecklist
Related Issues
なし (HF Space BUILD_ERROR の調査・再発防止として自発提案、 ユーザー指示「今後同じような問題が起きないように事前に hf のデプロイおよび動作保証を CI もしくはデプロイ前後で確認」 に対応)。