SKILL·642CFB

orchestrate-ml-pipeline

pjt222
更新于 1 month ago
8 次查看
26
3
26
在 GitHub 上查看
其他aiautomationdata

关于

This Claude Skill orchestrates end-to-end machine learning pipelines using Prefect or Airflow, handling DAG construction, task dependencies, scheduling, and retry logic. It integrates with MLflow, DVC, and feature stores for production workflows. Use it for automating multi-step ML processes from data ingestion to deployment, including periodic retraining and failure recovery.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/orchestrate-ml-pipeline

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Orchestrate ML Pipeline

See Extended Examples for complete configuration files and templates.

Build and orchestrate end-to-end machine learning pipelines with dependency management, scheduling, and monitoring.

When to Use

  • Automating multi-step ML workflows from data ingestion to deployment
  • Scheduling periodic model retraining on fresh data
  • Coordinating distributed data processing and training tasks
  • Implementing complex dependencies between ML pipeline stages
  • Managing retry logic and failure recovery
  • Monitoring pipeline execution and alerting on failures
  • Orchestrating feature engineering, training, evaluation, and deployment
  • Building reproducible ML workflows across environments

Inputs

  • Required: ML pipeline components (data ingestion, preprocessing, training, evaluation)
  • Required: Orchestration framework choice (Prefect, Airflow, Kubeflow)
  • Required: Python environment with orchestration library installed
  • Optional: Kubernetes cluster for distributed execution
  • Optional: MLflow tracking server for experiment logging
  • Optional: DVC for data versioning
  • Optional: Slack/email for alerting
  • Optional: Monitoring infrastructure (Prometheus, Grafana)

Procedure

Step 1: Choose and Install Orchestration Framework

Select appropriate framework and set up infrastructure.

# Option 1: Prefect (modern, Pythonic, simpler)
pip install prefect
pip install prefect-aws prefect-dask prefect-docker

# Start Prefect server (local development)
prefect server start

# Or use Prefect Cloud (managed)
# ... (see EXAMPLES.md for complete implementation)

Docker Compose for Airflow:

# docker-compose.airflow.yml
version: '3.8'

x-airflow-common: &airflow-common
  image: apache/airflow:2.8.0
  environment:
    AIRFLOW__CORE__EXECUTOR: CeleryExecutor
    AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
# ... (see EXAMPLES.md for complete implementation)

Got: Orchestration framework installed, web UI accessible (Prefect at http://localhost:4200, Airflow at http://localhost:8080), database initialized, scheduler running.

If fail: Check port availability (netstat -tulpn | grep 8080), verify database connection, ensure Redis running for Celery, check Python version compatibility (Airflow requires ≥3.8), verify Docker daemon for containerized setup, inspect logs for initialization errors.

Step 2: Build ML Pipeline with Prefect

Create Prefect flow with tasks for each pipeline stage.

# prefect_ml_pipeline.py
from prefect import flow, task
from prefect.tasks import task_input_hash
from datetime import timedelta
import pandas as pd
import mlflow
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
# ... (see EXAMPLES.md for complete implementation)

Deploy and schedule:

# deploy_prefect.py
from prefect.deployments import Deployment
from prefect.server.schemas.schedules import CronSchedule
from prefect_ml_pipeline import ml_training_pipeline

# Create deployment with schedule
deployment = Deployment.build_from_flow(
    flow=ml_training_pipeline,
# ... (see EXAMPLES.md for complete implementation)

Got: Prefect flow executes all tasks in correct order, task failures trigger retries automatically, successful runs show green in UI, MLflow logs experiments, model registered and deployed.

If fail: Check task dependencies defined correctly, verify MLflow server accessible, ensure data source paths correct, check for circular dependencies, verify task timeout limits, inspect Prefect logs for detailed errors, check resource availability (memory/CPU).

Step 3: Build ML Pipeline with Airflow

Create Airflow DAG for production ML workflow.

# dags/ml_training_dag.py
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.providers.docker.operators.docker import DockerOperator
from airflow.utils.dates import days_ago
from datetime import datetime, timedelta
import mlflow
import pandas as pd
# ... (see EXAMPLES.md for complete implementation)

Got: DAG appears in Airflow UI, scheduled runs execute on time, task failures trigger retries and alerts, XCom passes data between tasks, MLflow integration logs experiments.

If fail: Check DAG file syntax (python dags/ml_training_dag.py), verify imports available in Airflow environment, ensure XCom not exceeding size limits (use file paths for large data), check email configuration for alerts, verify scheduler running, inspect task logs in Airflow UI.

Step 4: Implement Advanced Features

Add dynamic DAGs, branching, and parallel execution.

# advanced_pipeline.py (Prefect)
from prefect import flow, task
from prefect.task_runners import DaskTaskRunner, ConcurrentTaskRunner
import time

@task
def process_shard(shard_id: int, data: list) -> dict:
    """Process data shard in parallel."""
# ... (see EXAMPLES.md for complete implementation)

Airflow branching:

# Airflow branching with BranchPythonOperator
from airflow.operators.python import BranchPythonOperator

def check_data_quality(**context):
    """Decide which branch to take."""
    data_path = context['ti'].xcom_pull(key='data_path')
    df = pd.read_csv(data_path)

# ... (see EXAMPLES.md for complete implementation)

Got: Parallel tasks execute concurrently (faster pipeline), conditional branches execute based on logic, dynamic task generation works, Dask cluster distributes work.

If fail: Check Dask cluster configured and accessible, verify task_runner specified, ensure branching returns valid task IDs, check for resource contention with parallel tasks, verify conditional logic correctness.

Step 5: Integrate Monitoring and Alerting

Add comprehensive monitoring and failure notifications.

# monitoring_integration.py
from prefect.blocks.notifications import SlackWebhook
from prefect import flow, task, get_run_logger
from prefect.context import FlowRunContext

@task(on_failure=[notify_failure])
def critical_task():
    """Task with failure notification."""
# ... (see EXAMPLES.md for complete implementation)

Airflow monitoring with sensors:

# Airflow SLA and monitoring
from airflow.sensors.base import BaseSensorOperator
from airflow.utils.decorators import apply_defaults

default_args = {
    'sla': timedelta(hours=4),  # Alert if task exceeds 4 hours
    'on_failure_callback': slack_alert_failure,
    'on_success_callback': slack_alert_success,
# ... (see EXAMPLES.md for complete implementation)

Got: Slack/email notifications sent on failures, SLA violations trigger alerts, custom metrics tracked, logs aggregated in monitoring system.

If fail: Verify Slack webhook configured correctly, check email SMTP settings, ensure notification blocks loaded properly, verify SLA values reasonable, check for network issues blocking notifications.

Step 6: Implement CI/CD for Pipelines

Version control and automate pipeline deployments.

# .github/workflows/deploy-pipeline.yml
name: Deploy ML Pipeline

on:
  push:
    branches: [main]
    paths:
      - 'pipelines/**'
# ... (see EXAMPLES.md for complete implementation)

Got: Pipeline tests pass before deployment, automated deployment to production, team notified on successful deployment, pipeline versioning tracked in Git.

If fail: Check test coverage and failures, verify Prefect Cloud credentials, ensure deployment script handles errors, check Slack webhook configuration, inspect CI logs for deployment errors.

Validation

  • Orchestration framework installed and running
  • Pipeline DAG defined with correct dependencies
  • All tasks execute in proper order
  • Retry logic functions correctly on failures
  • Scheduled runs execute on time
  • MLflow integration logs experiments
  • DVC integration versions data
  • Parallel tasks execute concurrently
  • Conditional branches work correctly
  • Monitoring and alerting functional
  • CI/CD pipeline deploys automatically
  • Pipeline reproducible across environments

Pitfalls

  • Circular dependencies: Task A depends on B, B depends on A — carefully design DAG structure, use Airflow/Prefect validators
  • Memory leaks: Long-running tasks accumulate memory — set task timeouts, monitor resource usage, restart workers periodically
  • XCom size limits: Passing large data via XCom — use file paths or external storage (S3) instead of direct serialization
  • Timezone confusion: Schedule runs at wrong times — always use UTC, explicitly set timezone in schedule
  • Missing retries: Tasks fail permanently on transient errors — configure retries with exponential backoff
  • Tight coupling: Tasks directly depend on implementation details — use clear interfaces, pass parameters explicitly
  • No idempotency: Re-running tasks causes duplicates or errors — design tasks to be idempotent (safe to retry)
  • Poor error handling: Failures do not provide useful context — add detailed logging, capture exceptions properly
  • Resource contention: Parallel tasks overwhelm resources — limit concurrency, set resource quotas
  • Version conflicts: Different tasks need incompatible dependencies — use Docker containers for task isolation

Related Skills

  • track-ml-experiments - Integrate MLflow tracking into pipeline tasks
  • version-ml-data - Use DVC for data versioning in pipelines
  • build-feature-store - Materialize features as pipeline task
  • deploy-ml-model-serving - Add deployment as final pipeline stage
  • deploy-to-kubernetes - Run orchestrated pipelines on Kubernetes

GitHub 仓库

pjt222/agent-almanac
路径: i18n/caveman-lite/skills/orchestrate-ml-pipeline
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams
FAQ

Frequently asked questions

What is the orchestrate-ml-pipeline skill?

orchestrate-ml-pipeline is a Claude Skill by pjt222. Skills package instructions and resources that Claude loads on demand, so Claude can perform orchestrate-ml-pipeline-related tasks without extra prompting.

How do I install orchestrate-ml-pipeline?

Use the install commands on this page: add orchestrate-ml-pipeline to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.

What category does orchestrate-ml-pipeline belong to?

orchestrate-ml-pipeline is in the Other category, tagged ai, automation and data.

Is orchestrate-ml-pipeline free to use?

Yes. orchestrate-ml-pipeline is listed on AIMCP and free to install. It runs inside Claude, so no separate service account is required to use the skill itself.

相关推荐技能

llamaguard
其他

LlamaGuard是Meta推出的7-8B参数内容审核模型,专门用于过滤LLM的输入和输出内容。它能检测六大安全风险类别(暴力/仇恨、性内容、武器、违禁品、自残、犯罪计划),准确率达94-95%。开发者可通过HuggingFace、vLLM或Sagemaker快速部署,并能与NeMo Guardrails集成实现自动化安全防护。

查看技能
cost-optimization
其他

这个Claude Skill帮助开发者优化云成本,通过资源调整、标记策略和预留实例来降低AWS、Azure和GCP的开支。它适用于减少云支出、分析基础设施成本或实施成本治理策略的场景。关键功能包括提供成本可视化、资源规模调整指导和定价模型优化建议。

查看技能
sports-betting-analyzer
其他

该Skill为开发者提供体育博彩数据分析工具,可分析盘口、大小球和特殊投注,识别价值投注机会。它整合历史数据和情景统计,生成包含时间戳的结构化Markdown报告。适用于需要快速获取博彩市场洞察的娱乐或教育类应用开发。

查看技能
quantizing-models-bitsandbytes
其他

这个Skill使用bitsandbytes库量化大语言模型,能在GPU内存有限时通过8位或4位量化减少50-75%内存占用,同时保持精度损失最小。它支持INT8、NF4、FP4等多种量化格式,可与HuggingFace Transformers无缝集成,适用于需要部署更大模型或加速推理的场景。还提供QLoRA训练和8位优化器支持,让开发者能轻松实现高效模型压缩。

查看技能