# --- Part 5.1: Project Structure ---
p51 = """# Project Structure (Create these files manually)

PRAC_5/
│── ml-cicd-project/
│   ├── .github/
│   │   └── workflows/
│   │       └── ci.yml
│   │
│   ├── tests/
│   │   └── test_model.py
│   │
│   ├── train.py
│   ├── requirements.txt
│   ├── README.md
│   └── model.pkl   # (generated after training)
"""

# --- Part 5.2: requirements.txt ---
p52 = """# File: requirements.txt

pandas
scikit-learn
pytest
joblib
"""

# --- Part 5.3: .github/workflows/ci.yml ---
p53 = """# File: .github/workflows/ci.yml

name: ML CI Pipeline

on:
  push:
    branches: [ "main" ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v3

    - name: Setup Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.10'

    - name: Install dependencies
      run: |
        pip install -r requirements.txt

    - name: Train Model
      run: |
        python train.py

    - name: Run Tests
      run: |
        pytest
"""

# --- Part 5.4: train.py ---
p54 = """# File: train.py

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
import joblib

print("Training started..")

def train_model():
    data = load_iris()
    X = data.data
    y = data.target

    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

    model = RandomForestClassifier()
    model.fit(X_train, y_train)

    accuracy = model.score(X_test, y_test)
    print(f"Model Accuracy: {accuracy}")

    joblib.dump(model, "model.pkl")

if __name__ == "__main__":
    train_model()
"""

# --- Part 5.5: tests/test_model.py ---
p55 = """# File: tests/test_model.py

import os

def test_model_exists():
    assert os.path.exists("model.pkl"), "Model file not found!"
"""

# --- Part 5.6: README.md ---
p56 = """# File: README.md

# MLOps Project – Practical 5

This project demonstrates GitHub CI/CD pipeline using GitHub Actions.

## How to run

1. Train model:
python train.py

2. Run tests:
pytest

3. Setup CI:
mkdir -p .github/workflows
Create ci.yml file

4. Push code to GitHub:
git add .
git commit -m "initial commit"
git push origin main
"""