Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 1.79 KB

File metadata and controls

71 lines (50 loc) · 1.79 KB

Create a Plugin Inline

Add feature groups directly to your existing project without creating a separate package.

When to Use This

  • You want to keep plugins in your main project
  • You don't need to share the plugin as a separate package
  • Quick prototyping or project-specific features

Step 1: Add Plugin Folder

Create a folder structure in your project:

my-project/
├── src/
│   └── my_app/
├── my_features/                  # Your mloda plugins
│   ├── __init__.py
│   └── scoring/
│       ├── __init__.py
│       ├── customer.py
│       └── tests/
│           └── test_customer.py
├── pyproject.toml
└── tests/

Step 2: Implement FeatureGroup

# my_features/scoring/customer.py
from mloda.provider import FeatureGroup

class CustomerScoring(FeatureGroup):
    """Customer scoring calculations."""

    @classmethod
    def calculate_feature(cls, data, features):
        return {"customer_score": 100}

Step 3: Use Your Plugin

Option A: Direct Import

from mloda.user import mloda, Feature
from my_features.scoring import CustomerScoring

result = mloda.run_all([Feature("CustomerScoring")])

Option B: Via PluginLoader

from mloda.user import PluginLoader, mloda, Feature

PluginLoader.all()

result = mloda.run_all([Feature("CustomerScoring")])

Tip: For incremental results when requesting multiple features, use stream_all instead of run_all.

Next Steps