Usage
Command-line Interface
Analyze a single Python file:
ml_smell_detector analyze path/to/your/file.py
Analyze all Python files in a directory:
ml_smell_detector analyze path/to/your/directory
Save reports to a custom output directory:
ml_smell_detector analyze path/to/your/directory --output-dir reports/
Skip specific directories during analysis:
ml_smell_detector analyze path/to/your/directory --ignore tests notebooks __pycache__
Options
path— path to a.pyfile or a directory to analyze.--output-dir DIR— directory to write reports to (default:output/).--ignore DIR [DIR ...]— directory names to skip during analysis.
Output
The tool writes two report files to the output directory (default: output/):
analysis_report.txt— human-readable report grouped by file and detector categoryanalysis_report.csv— machine-readable CSV with columns:Framework,Smell/Checker Name,How to Fix,Benefits,File Path,Location,Count
Use Cases
Code Review: Automatically check for common ML code smells during code reviews.
Continuous Integration: Integrate into your CI/CD pipeline to catch potential issues early.
Education: Teach best practices in ML code to students or junior developers.
Refactoring: Identify areas of improvement in existing ML codebases.
Project Onboarding: Quickly assess the quality of ML code in a new project.
CI/CD Integration
Add to your GitHub Actions workflow:
- name: Run ML smell detector
run: |
pip install ml-code-smell-detector
ml_smell_detector analyze src/ --output-dir reports/
- name: Upload reports
uses: actions/upload-artifact@v3
with:
name: ml-smell-reports
path: reports/