Mlops validation
Guide to implement rigorous validation layers including static analysis, automated testing, structured logging, and security scanning.From its SKILL.md
npx -y skills add MLOps-Courses/mlops-coding-skills --skill mlops-validationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 20 stars20 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
- runs commandsInstructs the agent to run 4 commands, including `ruff check` and 3 more.
SKILL.md
3.1 KB, 786 tokens by cl100k_base, as published. Nobody here has run it
MLOps Validation
Goal
To ensure software quality, reliability, and security through automated validation layers. This skill enforces Strict Typing (ty), Unified Linting (ruff), Comprehensive Testing (pytest), and Structured Logging (loguru).
Prerequisites
- Language: Python
- Manager:
uv - Context: Ensuring code quality before merge/deploy.
Instructions
1. Static Analysis (Typing & Linting)
Catch errors before they run.
- Typing:
- Tool:
ty(Astral type checker; pre-1.0, pin a compatible range). The mandated checker — do not usemypy. - Rule: No
Any(unless absolutely necessary). Fully typed function signatures. - DataFrames: Use
panderaschemas to validate DataFrame structures/types. - Classes: Use
pydanticfor data modeling and runtime validation.
- Tool:
- Linting & Formatting:
- Tool:
ruff(replaces black, isort, pylint, flake8). - Rule: Zero tolerance for linter errors. Use
noqasparingly and with justification. - Config: Centralize in
pyproject.toml.
- Tool:
2. Testing Strategy
Verify behavior and prevent regressions.
-
Tool:
pytest. -
Structure: Mirror
src/intests/.src/pkg/mod.py -> tests/test_mod.py -
Fixtures: Use
tests/conftest.pyfor shared setup (mock data, temp paths). -
Coverage: Aim for high coverage (>80%) on core business logic. Use
pytest-cov. -
Pattern: Use Given-When-Then in comments.
def test_pipeline_execution(input_data): # Given: Valid input data # When: The pipeline processes the data # Then: The output content matches expectations
3. Structured Logging
Enable observability and debugging.
- Tool:
loguru(replacing stdliblogging). - Format: Use structured logging (JSON) in production for queryability.
- Levels:
DEBUG: Low-level tracing (payloads, internal state).INFO: Key business events (Job started, Model saved).ERROR: Actionable failures (with stack traces).
- Context: Include context (Job ID, Model Version) in logs.
4. Security
Protect the supply chain and runtime.
- Code Scanning: Enable Ruff
S(flake8-bandit) rules to detect unsafe patterns (e.g.,eval,yaml.load) — this replaces standalonebandit. - Dependencies: Run
pip-audit(and/orGitHub Dependabot) to patch vulnerable packages. - Secret Scanning: Run
gitleaksto keep credentials out of the code and git history. - Secrets: NEVER log secrets. Sanitize outputs.
Self-Correction Checklist
- Type Safety: Does
typass without errors? - Lint Cleanliness: Does
ruff checkpass? - Test Discovery: Does
pytestsuccessfully find modules insrc/? - Log Format: Are production logs serializing to JSON?
- Security: Do Ruff
Srules,pip-audit, andgitleakspass?
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.