How to Validate Data Before Training in GitHub Actions
Run schema, null, and range checks as a gate before training so a broken dataset fails CI instead of producing a broken model.
Add a validation step that checks the dataset schema, null rates, and value ranges (with pandas assertions or a tool like Great Expectations). Make it a dependency of the training job so training never starts on invalid data.
Steps
- Load the dataset and assert the expected columns and dtypes.
- Check null rates and value ranges against thresholds.
- Gate the training job on the validation job with
needs:.
Workflow
.github/workflows/ci.yml
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install pandas
- name: Validate dataset
run: |
python - <<'PY'
import pandas as pd
df = pd.read_parquet("data/train.parquet")
assert set(["text", "label"]).issubset(df.columns)
assert df["label"].notna().mean() == 1.0
assert df["label"].between(0, 4).all()
PY
train:
needs: validate
runs-on: [self-hosted, gpu]
steps:
- run: python train.py --max-steps 1Gotchas
- Validate before any GPU step so bad data fails on a cheap CPU runner.
- Version the expected schema with the data so the checks evolve together.
Related guides
How to Pull DVC-Tracked Data in GitHub ActionsFetch DVC-tracked datasets and models in GitHub Actions with dvc pull against a remote, authenticated by a se…
How to Smoke-Test Training With One Step in GitHub ActionsRun a fast training smoke test in GitHub Actions that executes a single step on tiny data, catching shape and…