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

--- name: mlops-industrialization-cn version: 1.0.0 description: Transform prototypes into distributable Python packages license: MIT --- # MLOps Industrialization 🏭 Convert notebooks to production packages. ## Features ### 1. Package Structure Generator 📦 Create `src/` layout: ```bash ./scripts/create-package.sh my_package ``` Creates: ``` src/my_package/ ├── __init__.py ├── io/ # I/O operations ├── domain/ # Pure business logic └── application/ # Orchestration ``` ### 2. Three-Layer Architecture 🏗️ **Domain (Pure)** - No I/O, no side effects - Feature transformations - Pure functions or immutable objects **I/O (Impure)** - External interactions - Load data, save models - Classes for state management **Application** - Wire Domain + I/O - Training loops, inference ## Quick Start ```bash # Create package structure ./scripts/create-package.sh my_ml_package # Add CLI entrypoint to pyproject.toml: # [project.scripts] # train = "my_ml_package.application.train:main" ``` ## Key Files Generated files: - `src/my_package/domain/features.py` - Feature engineering - `src/my_package/io/data.py` - Data loading/saving - `src/my_package/application/train.py` - Training pipeline ## 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 package generator

path: package.json
content: {
  "name": "mlops-industrialization-cn",
  "version": "1.0.0",
  "description": "MLOps Industrialization - Transform prototypes into distributable packages",
  "main": "SKILL.md",
  "scripts": {
    "create": "./scripts/create-package.sh"
  },
  "keywords": [
    "mlops",
    "packaging",
    "production",
    "python",
    "src-layout"
  ],
  "author": "money-maker-ai",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/MLOps-Courses/mlops-coding-skills"
  }
}


path: scripts/create-package.sh
content: #!/bin/bash
# Generate src package structure

set -e

PACKAGE_NAME="${1:-my_package}"
PACKAGE_DIR="${PACKAGE_NAME//-/_}"

echo "🏗️  Creating package structure: $PACKAGE_NAME"

# Create directories
mkdir -p "src/$PACKAGE_DIR"/{io,domain,application}
mkdir -p tests

# Create __init__.py files
touch "src/$PACKAGE_DIR/__init__.py"
touch "src/$PACKAGE_DIR/io/__init__.py"
touch "src/$PACKAGE_DIR/domain/__init__.py"
touch "src/$PACKAGE_DIR/application/__init__.py"
touch "tests/__init__.py"

# Create sample module
cat > "src/$PACKAGE_DIR/domain/features.py" << 'EOF'
"""Feature engineering - Pure functions only"""

from typing import Any
import pandas as pd


def transform_features(df: pd.DataFrame, config: dict[str, Any]) -> pd.DataFrame:
    """Transform raw features into ML features.
    
    Args:
        df: Raw input dataframe
        config: Feature configuration
        
    Returns:
        Transformed dataframe
    """
    # Add feature transformations here
    return df
EOF

# Create sample I/O module
cat > "src/$PACKAGE_DIR/io/data.py" << 'EOF'
"""Data I/O operations"""

from pathlib import Path
import pandas as pd


def load_data(path: Path) -> pd.DataFrame:
    """Load data from disk.
    
    Args:
        path: Path to data file
        
    Returns:
        Loaded dataframe
    """
    if path.suffix == ".parquet":
        return pd.read_parquet(path)
    return pd.read_csv(path)


def save_data(df: pd.DataFrame, path: Path) -> None:
    """Save data to disk.
    
    Args:
        df: Dataframe to save
        path: Output path
    """
    path.parent.mkdir(parents=True, exist_ok=True)
    df.to_parquet(path, index=False)
EOF

# Create sample application module
cat > "src/$PACKAGE_DIR/application/train.py" << 'EOF'
"""Training orchestration"""

from pathlib import Path
import pandas as pd
from pydantic import BaseModel

from ..io.data import load_data, save_data
from ..domain.features import transform_features


class TrainingConfig(BaseModel):
    """Training configuration"""
    data_path: Path
    output_path: Path
    random_state: int = 42


def train(config: TrainingConfig) -> None:
    """Run training pipeline.
    
    Args:
        config: Training configuration
    """
    # Load
    df = load_data(config.data_path)
    
    # Transform
    df = transform_features(df, config.model_dump())
    
    # Train (add your model here)
    
    # Save
    save_data(df, config.output_path)
EOF

echo "✅ Package structure created!"
echo ""
echo "Next steps:"
echo "  - Edit src/$PACKAGE_DIR/domain/features.py"
echo "  - Add your model logic"
echo "  - Register CLI in pyproject.toml"


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