Skip to content

Contributing to MLPotion ๐Ÿค

Thank you for your interest in contributing to MLPotion! We love community contributions and want to make it as easy as possible.

Ways to Contribute ๐ŸŒŸ

1. Report Bugs ๐Ÿ›

Found a bug? Please open an issue with:

  • Clear description of the bug
  • Steps to reproduce
  • Expected vs actual behavior
  • Environment details (Python version, OS, framework versions)
  • Minimal reproducible example

2. Suggest Features ๐Ÿ’ก

Have an idea? Start a discussion or open an issue with:

  • Clear description of the feature
  • Use case and motivation
  • Example API (if applicable)

3. Submit Pull Requests ๐Ÿ”จ

We welcome code contributions! See below for guidelines.

4. Improve Documentation ๐Ÿ“–

Documentation improvements are always appreciated:

  • Fix typos or unclear explanations
  • Add examples
  • Improve API documentation
  • Write tutorials

5. Help Others ๐Ÿ™‹

  • Answer questions in Discussions
  • Help review pull requests
  • Share your MLPotion projects

Development Setup ๐Ÿ› ๏ธ

1. Fork and Clone

# Fork on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/MLPotion.git
cd MLPotion

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

3. Install Development Dependencies

# Install dependencies with Poetry (includes dev dependencies and all extras)
poetry install --with dev -E all

# Activate the virtual environment
poetry shell

4. Install Pre-commit Hooks

pre-commit install

Code Style ๐ŸŽจ

We use:

  • Black for code formatting
  • isort for import sorting
  • Ruff for linting
  • mypy for type checking

Run before committing:

# Format code
black mlpotion tests

# Sort imports
isort mlpotion tests

# Lint
ruff check mlpotion tests

# Type check
mypy mlpotion

Or just let pre-commit handle it:

pre-commit run --all-files

Testing ๐Ÿงช

Run All Tests

pytest

Run Specific Framework Tests

# TensorFlow only
pytest -m tensorflow

# PyTorch only
pytest -m pytorch

# Keras only
pytest -m keras

Run with Coverage

pytest --cov=mlpotion --cov-report=html

Write Tests

All new features need tests! Place tests in tests/ with the same structure as mlpotion/.

Example:

# tests/frameworks/tensorflow/test_loaders.py
import pytest
from mlpotion.frameworks.tensorflow import TFCSVDataLoader

def test_csv_loader_basic():
    """Test basic CSV loading."""
    loader = TFCSVDataLoader("test_data.csv", label_name="target")
    dataset = loader.load()

    assert dataset is not None
    # More assertions...

Pull Request Process ๐Ÿ”„

1. Create a Branch

git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix

2. Make Changes

  • Write clean, documented code
  • Follow existing patterns
  • Add tests for new features
  • Update documentation

3. Commit Changes

git add .
git commit -m "feat: add awesome feature"

Commit message format:

  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation
  • test: - Tests
  • refactor: - Code refactoring
  • style: - Code style changes
  • chore: - Maintenance

4. Push and Create PR

git push origin feature/your-feature-name

Then create a pull request on GitHub with:

  • Clear description of changes
  • Link to related issue (if any)
  • Screenshots (if UI changes)
  • Checklist of completed items

Project Structure ๐Ÿ“

mlpotion/
โ”œโ”€โ”€ core/                    # Framework-agnostic core
โ”‚   โ”œโ”€โ”€ protocols.py        # Protocol definitions
โ”‚   โ”œโ”€โ”€ results.py          # Result types
โ”‚   โ”œโ”€โ”€ config.py           # Configuration classes
โ”‚   โ””โ”€โ”€ exceptions.py       # Custom exceptions
โ”œโ”€โ”€ frameworks/              # Framework implementations
โ”‚   โ”œโ”€โ”€ tensorflow/         # TensorFlow components
โ”‚   โ”œโ”€โ”€ pytorch/            # PyTorch components
โ”‚   โ””โ”€โ”€ keras/              # Keras components
โ”œโ”€โ”€ integrations/            # Third-party integrations
โ”‚   โ””โ”€โ”€ zenml/              # ZenML integration
โ””โ”€โ”€ utils/                   # Utility functions

Adding a New Component ๐Ÿ†•

1. Define Protocol (if new)

# mlpotion/core/protocols.py
from typing import Protocol, TypeVar

DatasetT = TypeVar("DatasetT")

class NewComponent(Protocol[DatasetT]):
    """Protocol for new component type."""

    def do_something(self, dataset: DatasetT) -> DatasetT:
        """Do something with dataset."""
        ...

2. Implement for Each Framework

# mlpotion/frameworks/tensorflow/new_module.py
import tensorflow as tf

class TFNewComponent:
    """TensorFlow implementation."""

    def do_something(self, dataset: tf.data.Dataset) -> tf.data.Dataset:
        """Implementation for TensorFlow."""
        # Your code here
        return dataset

3. Add Tests

# tests/frameworks/tensorflow/test_new_module.py
def test_new_component():
    """Test new component."""
    component = TFNewComponent()
    result = component.do_something(dataset)
    assert result is not None

4. Document

# Add docstrings
class TFNewComponent:
    """TensorFlow implementation of NewComponent.

    This component does X, Y, and Z.

    Args:
        param1: Description
        param2: Description

    Example:
        ```python
        component = TFNewComponent(param1="value")
        result = component.do_something(dataset)
        ```
    """

Code Review Process ๐Ÿ‘€

  1. Automated Checks: CI must pass
  2. Code Review: At least one maintainer approval
  3. Documentation: Must be updated if needed
  4. Tests: Must pass and have good coverage
  5. Breaking Changes: Require discussion

Release Process ๐Ÿš€

  1. Version bump in pyproject.toml
  2. Update CHANGELOG.md
  3. Create release tag
  4. GitHub Actions publishes to PyPI

Questions? ๐Ÿ’ฌ

Code of Conduct ๐Ÿ“œ

Be respectful, inclusive, and collaborative. We're all here to make ML better!


Thank you for contributing to MLPotion! ๐Ÿ™
Built with โค๏ธ by the community for the community