fix(ci): add HF_TOKEN diagnostic and grouped logging for ml build

- Verify HF_TOKEN exists before attempting download
- Group CI log output for readability
- Use os.environ['HF_TOKEN'] instead of .get() to fail fast

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-11 20:12:55 +00:00
co-authored by Claude
parent 7f17c19dc8
commit 04d2bebdfe
+26 -1
View File
@@ -47,8 +47,25 @@ jobs:
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
set -euo pipefail
# Diagnostic
echo "::group::Environment check"
if [ -z "${HF_TOKEN:-}" ]; then
echo "ERROR: HF_TOKEN secret is not set."
echo "Add it at: https://github.com/ATLAS-PJK-GM007/ZeaVis-Edu/settings/secrets/actions"
echo "Name: HF_TOKEN Value: your Hugging Face token"
exit 1
fi
echo "HF_TOKEN is set (length: ${#HF_TOKEN})"
echo "::endgroup::"
echo "::group::Install dependencies"
python -m pip install --upgrade pip
python -m pip install 'tensorflow>=2.13.0' 'tf2onnx>=1.16.1' 'onnx>=1.16.0' 'huggingface_hub'
echo "::endgroup::"
echo "::group::Download model from Hugging Face"
python -c "
from huggingface_hub import hf_hub_download
import os
@@ -56,13 +73,21 @@ jobs:
path = hf_hub_download(
repo_id='MythEclipse2737/corn-leaf-disease-classifier',
filename='best_model.keras',
token=os.environ.get('HF_TOKEN'),
token=os.environ['HF_TOKEN'],
local_dir='best_model',
)
print(f'Model downloaded to {path}')
"
echo "::endgroup::"
echo "::group::Export SavedModel + TFLite"
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
python save_model.py
echo "::endgroup::"
echo "::group::Export ONNX"
python convert_onnx.py
echo "::endgroup::"
- name: Log in to GHCR
uses: docker/login-action@v3