Skip to main content

A comprehensive linter for healthy Kubeflow Pipelines with advanced analysis and auto-fix capabilities

Project description

๐Ÿฉบ kfp-doctor

A comprehensive linter for healthy Kubeflow Pipelines with advanced analysis and auto-fix capabilities.

Python 3.8+ License: MIT

๐ŸŒŸ Key Features in v1.0.0

  • ๐Ÿ”ง Auto-fix capabilities - Automatically fix common pipeline issues
  • ๐Ÿ“Š Advanced analysis - Performance, cost, and complexity analysis
  • ๐ŸŽฏ Smart config generation - Environment-specific configurations
  • ๐Ÿ’ฐ Cost estimation - Per-component cost analysis and optimization
  • โšก Performance insights - Bottleneck detection and runtime estimation
  • ๐ŸŽจ Rich UI enhancements - Progress indicators, detailed reporting

๐Ÿš€ Features

Core Linting (10 Comprehensive Checks)

  • โœ… Resource validation - Missing/excessive CPU and memory requests
  • ๐Ÿ”’ Security checks - Privileged containers, root users, hardcoded secrets
  • ๐Ÿท๏ธ Image best practices - Latest tags, registry validation
  • ๐Ÿ›ก๏ธ Reliability - Retry policies, resource limits
  • ๐Ÿ“Š Pipeline structure - Unused components, dependency analysis

Advanced Analysis

  • ๐Ÿ’ฐ Cost Analysis - Hourly/daily/monthly cost estimation with optimization suggestions
  • โšก Performance Insights - Bottleneck detection, resource imbalance identification
  • ๐Ÿ“ˆ Complexity Metrics - Pipeline complexity scoring and dependency analysis
  • ๐ŸŽฏ Runtime Estimation - Predicted execution time based on resource allocation

Automation Features

  • ๐Ÿ”ง Auto-fix - Automatically resolve common issues like missing resources, security contexts
  • ๐ŸŽฏ Smart Config Generation - Environment-specific configurations (dev/staging/prod)
  • ๐Ÿ“‹ Template System - Pre-built configurations for different use cases
  • ๐Ÿ”„ Pipeline Analysis - Intelligent config recommendations based on your pipeline

Developer Experience

  • ๐ŸŽจ Rich Console UI - Beautiful tables, progress indicators, color-coded output
  • ๐Ÿ“Š Multiple Output Formats - Console, JSON, YAML for CI/CD integration
  • ๐Ÿ” Verbose Mode - Real-time check execution visibility
  • ๐Ÿ’ก Comprehensive Help - Built-in documentation and examples

๐Ÿ“ฆ Installation

pip install kfp-doctor

๐ŸŽฏ Quick Start

1. Basic Pipeline Check

# Check your pipeline
kfp-doctor check my-pipeline.yaml

# Verbose mode with real-time progress
kfp-doctor check my-pipeline.yaml --verbose

2. Generate Optimal Configuration

# Generate config for your environment
kfp-doctor generate-config --template production

# Smart config based on your pipeline
kfp-doctor generate-config --analyze-pipeline my-pipeline.yaml

3. Auto-fix Common Issues

# Preview what would be fixed
kfp-doctor fix my-pipeline.yaml --dry-run

# Apply fixes with backup
kfp-doctor fix my-pipeline.yaml --backup

4. Advanced Analysis

# Performance and cost analysis
kfp-doctor analyze my-pipeline.yaml --include-cost --include-performance

# Export analysis results
kfp-doctor analyze my-pipeline.yaml --output json --output-file analysis.json

๐Ÿ› ๏ธ Commands

check - Pipeline Linting

Comprehensive pipeline validation with 10 built-in checks.

kfp-doctor check pipeline.yaml [OPTIONS]

Options:
  --config, -c PATH           Custom configuration file
  --output, -o FORMAT        Output format: console, json, yaml
  --output-file PATH         Save results to file
  --fail-on LEVEL           When to exit with error: error, warning, never
  --verbose, -v              Show detailed check execution
  --dry-run                  Preview what would be checked

analyze - Advanced Analysis

Performance, cost, and complexity analysis with optimization insights.

kfp-doctor analyze pipeline.yaml [OPTIONS]

Options:
  --include-cost             Include detailed cost analysis
  --include-performance      Include performance insights
  --output FORMAT           Output format: console, json, yaml
  --output-file PATH        Save analysis to file

Sample Output:

๐Ÿ“Š Pipeline Complexity Analysis
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Metric            โ”ƒ  Value  โ”ƒ Assessment โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Total Components  โ”‚    3    โ”‚            โ”‚
โ”‚ Dependency Depth  โ”‚    3    โ”‚            โ”‚
โ”‚ Max Parallelism   โ”‚    3    โ”‚            โ”‚
โ”‚ Complexity Score  โ”‚   3.0   โ”‚   Simple   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ’ฐ Cost Analysis
โ”Œโ”€ Cost Summary โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ๐Ÿ’ต Estimated Cost per Hour: $0.1495               โ”‚
โ”‚ ๐Ÿ“… Estimated Cost per Day: $3.59                  โ”‚
โ”‚ ๐Ÿ“… Estimated Cost per Month: $107.64              โ”‚
โ”‚ ๐ŸŽฏ Optimization Potential: $0.0299/hour           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

fix - Auto-fix Issues

Automatically resolve common pipeline issues.

kfp-doctor fix pipeline.yaml [OPTIONS]

Options:
  --output-file, -o PATH     Write fixed pipeline to file
  --dry-run                  Show what would be fixed
  --backup                   Create backup of original file

Auto-fix Capabilities:

  • โœ… Add missing resource requests and limits
  • โœ… Fix security contexts (disable privileged, set runAsUser)
  • โœ… Update image tags from :latest to specific versions
  • โœ… Add retry policies for reliability
  • โœ… Convert hardcoded secrets to secretKeyRef

generate-config - Configuration Generator

Create optimal configurations for different environments.

kfp-doctor generate-config [OPTIONS]

Options:
  --template, -t NAME        Template: development, staging, production, security-focused, cost-optimized
  --output-file, -o PATH     Output file (default: .kfp-doctor.yaml)
  --analyze-pipeline PATH    Analyze pipeline to suggest optimal config
  --list-templates          Show available templates

Available Templates:

  • ๐Ÿ”ง development - Relaxed settings for development
  • โš–๏ธ staging - Balanced settings for staging
  • ๐Ÿญ production - Strict settings for production
  • ๐Ÿ”’ security-focused - Maximum security settings
  • ๐Ÿ’ฐ cost-optimized - Resource efficiency focused

list-checks - Check Documentation

View all available checks with descriptions and configuration.

kfp-doctor list-checks

help - Comprehensive Help

Feature overview, examples, and quick start guide.

kfp-doctor help --examples

โš™๏ธ Configuration

Basic Configuration

Create .kfp-doctor.yaml in your project root:

checks:
  MISSING_RESOURCES:
    enabled: true
    severity: ERROR
  LATEST_IMAGE_TAG:
    enabled: true
    severity: ERROR
  EXCESSIVE_RESOURCES:
    enabled: true
    severity: WARNING
    max_cpu: "8"
    max_memory: "16Gi"
  INSECURE_IMAGE_REGISTRY:
    enabled: true
    severity: ERROR
    allowed_registries:
      - "gcr.io/your-project"
      - "docker.io/library"

Environment-Specific Configs

Generate optimized configurations for different environments:

# Development environment (relaxed)
kfp-doctor generate-config --template development

# Production environment (strict)
kfp-doctor generate-config --template production

# Security-focused environment
kfp-doctor generate-config --template security-focused

๐Ÿ”„ CI/CD Integration

GitHub Actions

- name: Lint Kubeflow Pipeline
  run: |
    pip install kfp-doctor
    kfp-doctor check compiled-pipeline.yaml --output json --fail-on error

GitLab CI

lint-pipeline:
  script:
    - pip install kfp-doctor
    - kfp-doctor check compiled-pipeline.yaml --fail-on error
  artifacts:
    reports:
      junit: pipeline-report.xml

๐Ÿ“Š All Available Checks

Check Description Configurable
MISSING_RESOURCES Ensures all components have CPU and memory requests โœ…
MISSING_LIMITS Ensures components have resource limits โœ…
EXCESSIVE_RESOURCES Warns about over-provisioned resources โœ…
LATEST_IMAGE_TAG Warns against using :latest image tags โœ…
NO_RETRY_POLICY Checks for retry policies โœ…
PRIVILEGED_CONTAINER Detects privileged containers โœ…
RUN_AS_ROOT Warns about root user execution โœ…
HARDCODED_SECRET Identifies hardcoded secrets โœ…
UNUSED_COMPONENT Finds unused pipeline components โœ…
INSECURE_IMAGE_REGISTRY Validates image registries โœ…

๐Ÿ“ˆ Example Workflows

Development Workflow

# 1. Generate development config
kfp-doctor generate-config --template development

# 2. Check pipeline during development
kfp-doctor check pipeline.yaml --verbose

# 3. Auto-fix common issues
kfp-doctor fix pipeline.yaml --backup

# 4. Analyze performance
kfp-doctor analyze pipeline.yaml --include-performance

Production Deployment

# 1. Generate production config
kfp-doctor generate-config --template production

# 2. Strict production check
kfp-doctor check pipeline.yaml --config .kfp-doctor.yaml --fail-on error

# 3. Cost analysis before deployment
kfp-doctor analyze pipeline.yaml --include-cost --output-file cost-report.json

๐Ÿค Contributing

We welcome contributions! Please see our contributing guidelines.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Built for the Kubeflow community
  • Inspired by pipeline best practices and production experience
  • Designed for developer productivity and operational excellence

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kfp_doctor-1.0.0.tar.gz (71.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kfp_doctor-1.0.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file kfp_doctor-1.0.0.tar.gz.

File metadata

  • Download URL: kfp_doctor-1.0.0.tar.gz
  • Upload date:
  • Size: 71.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for kfp_doctor-1.0.0.tar.gz
Algorithm Hash digest
SHA256 45eab2b77d49881b74b0a1f6b3cef0cd465a96026bf2baaf102f27761b8ed2f7
MD5 36bbb17958d48fc09e6cd2d080957097
BLAKE2b-256 b6eb2f1074911d2e2c46dd96120c9886534278885b054987fa343aed6503dffe

See more details on using hashes here.

File details

Details for the file kfp_doctor-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kfp_doctor-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for kfp_doctor-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13e4646cccbb8bdfb6df1ac9b6136e8b05e85ad077014e8675439e1ac1ce5f5e
MD5 7e43d18f41271c202b7f67ff7d253274
BLAKE2b-256 2941992f48c84d30713cf52f15059682d3d38ec93573cf4001ee5f4951f3a63e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page