Skill: guohongbin-git/mlops-validation-cn (version 1.0.0)

--- name: mlops-validation-cn version: 1.0.0 description: Rigorous validation with typing, linting, testing, and security license: MIT --- # MLOps Validation ✅ Automated quality and security checks. ## Features ### 1. Pre-commit Hooks 🔧 Setup automated checks: ```bash cp references/pre-commit-config.yaml ../your-project/.pre-commit-config.yaml cd ../your-project pre-commit install ``` Runs on every commit: - Ruff (linting + formatting) - MyPy (type checking) - Bandit (security) ### 2. Test Fixtures 🧪 Shared pytest setup: ```bash cp references/conftest.py ../your-project/tests/ ``` Provides fixtures: - `sample_df` - Test dataframe - `temp_dir` - Temporary directory - `sample_config` - Config dict - `train_test_split` - Pre-split data ## Quick Start ```bash # Copy pre-commit config cp references/pre-commit-config.yaml ./.pre-commit-config.yaml # Install hooks pre-commit install # Run manually pre-commit run --all-files # Setup test fixtures cp references/conftest.py tests/ # Run tests pytest tests/ -v --cov=src ``` ## Commands ```bash # Type check mypy src/ # Lint ruff check src/ tests/ # Format ruff format src/ tests/ # Test pytest tests/ --cov=src # Security scan bandit -r src/ ``` ## Author Converted from [MLOps Coding Course](https://github.com/MLOps-Courses/mlops-coding-skills) ## Changelog ### v1.0.0 (2026-02-18) - Initial OpenClaw conversion - Added pre-commit config - Added test fixtures

path: package.json
content: {
  "name": "mlops-validation-cn",
  "version": "1.0.0",
  "description": "MLOps Validation - Typing, linting, testing, and security scanning",
  "main": "SKILL.md",
  "keywords": [
    "mlops",
    "testing",
    "linting",
    "validation",
    "pytest",
    "ruff"
  ],
  "author": "money-maker-ai",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/MLOps-Courses/mlops-coding-skills"
  }
}


path: references/conftest.py
content: # Shared pytest fixtures
# Copy to tests/conftest.py

import pytest
import pandas as pd
import numpy as np
from pathlib import Path
import tempfile


@pytest.fixture
def sample_df():
    """Sample dataframe for testing"""
    np.random.seed(42)
    return pd.DataFrame({
        'feature_1': np.random.randn(100),
        'feature_2': np.random.randn(100),
        'target': np.random.randint(0, 2, 100)
    })


@pytest.fixture
def temp_dir():
    """Temporary directory for file tests"""
    with tempfile.TemporaryDirectory() as tmpdir:
        yield Path(tmpdir)


@pytest.fixture
def sample_config():
    """Sample configuration dict"""
    return {
        'batch_size': 32,
        'learning_rate': 0.001,
        'random_state': 42,
        'n_estimators': 100,
    }


@pytest.fixture
def train_test_split(sample_df):
    """Pre-split data for testing"""
    from sklearn.model_selection import train_test_split
    X = sample_df[['feature_1', 'feature_2']]
    y = sample_df['target']
    return train_test_split(X, y, test_size=0.2, random_state=42)


path: references/pre-commit-config.yaml
content: # Pre-commit configuration for MLOps projects
# Copy to .pre-commit-config.yaml

repos:
  # Ruff - Fast Python linter
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.3.0
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format

  # Bandit - Security linter
  - repo: https://github.com/PyCQA/bandit
    rev: 1.7.8
    hooks:
      - id: bandit
        args: [-r, src/]

  # General checks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files
        args: ['--maxkb=1000']
      - id: check-merge-conflict
      - id: debug-statements

  # MyPy - Type checking
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.9.0
    hooks:
      - id: mypy
        additional_dependencies: [pydantic]
        args: [--ignore-missing-imports]

  # Notebook checks (if using Jupyter)
  - repo: https://github.com/nbQA-dev/nbQA
    rev: 1.8.5
    hooks:
      - id: nbqa-ruff
      - id: nbqa-mypy


Security scan verdicts — ClawScan: clean | static analysis:  | VirusTotal: clean | SkillSpector: clean (LOW)