|
1 | | -# mloda-plugin-template |
| 1 | +[](https://github.com/mloda-ai/mloda-plugin-template/blob/main/LICENSE) |
| 2 | +[](https://github.com/mloda-ai/mloda) |
| 3 | +[](https://www.python.org/) |
| 4 | + |
| 5 | +# mloda-plugin-template |
| 6 | + |
| 7 | +> **A GitHub template for creating standalone mloda plugins.** Part of the [mloda](https://github.com/mloda-ai/mloda) ecosystem for open data access. Visit [mloda.ai](https://mloda.ai) for an overview and business context, the [GitHub repository](https://github.com/mloda-ai/mloda) for technical context, or the [documentation](https://mloda-ai.github.io/mloda/) for detailed guides. |
| 8 | +
|
| 9 | +Create your own FeatureGroups, ComputeFrameworks, and Extenders as standalone packages. See the [Getting Started guide](docs/getting-started.md) to create your repository, then follow the setup steps below. |
| 10 | + |
| 11 | +## Related Repositories |
| 12 | + |
| 13 | +- **[mloda](https://github.com/mloda-ai/mloda)**: The core library for open data access. Declaratively define what data you need, not how to get it. mloda handles feature resolution, dependency management, and compute framework abstraction automatically. |
| 14 | + |
| 15 | +- **[mloda-registry](https://github.com/mloda-ai/mloda-registry)**: The central hub for discovering and sharing mloda plugins. Browse community-contributed FeatureGroups, find integration guides, and publish your own plugins for others to use. |
| 16 | + |
| 17 | +## Structure |
| 18 | + |
| 19 | +``` |
| 20 | +placeholder/ |
| 21 | +├── feature_groups/ |
| 22 | +│ └── my_plugin/ |
| 23 | +│ ├── __init__.py # Package exports |
| 24 | +│ ├── my_feature_group.py # Example FeatureGroup implementation |
| 25 | +│ └── tests/ |
| 26 | +│ └── test_my_feature_group.py |
| 27 | +├── compute_frameworks/ |
| 28 | +│ └── my_framework/ |
| 29 | +│ ├── __init__.py |
| 30 | +│ └── my_compute_framework.py |
| 31 | +└── extenders/ |
| 32 | + └── my_extender/ |
| 33 | + ├── __init__.py |
| 34 | + └── my_extender.py |
| 35 | +``` |
| 36 | + |
| 37 | +## Key Files |
| 38 | + |
| 39 | +- `placeholder/` - Root namespace (users rename to company name) |
| 40 | +- `pyproject.toml` - Package config (users edit directly, not auto-generated) |
| 41 | +- `.github/workflows/test.yml` - CI workflow running pytest |
| 42 | + |
| 43 | +## Common Tasks |
| 44 | + |
| 45 | +### Setup Your Plugin |
| 46 | + |
| 47 | +Follow these steps to customize the template for your organization: |
| 48 | + |
| 49 | +#### 1. Rename the directory |
| 50 | + |
| 51 | +```bash |
| 52 | +mv placeholder acme |
| 53 | +``` |
| 54 | + |
| 55 | +#### 2. Update pyproject.toml |
| 56 | + |
| 57 | +Edit the following fields in `pyproject.toml`: |
| 58 | + |
| 59 | +- `name`: Change `"placeholder-my-plugin"` to `"acme-my-plugin"` |
| 60 | +- `authors`: Update name and email |
| 61 | +- `description`: Update to describe your plugin |
| 62 | +- `tool.setuptools.packages.find.include`: Change `["placeholder*"]` to `["acme*"]` |
| 63 | +- `tool.pytest.ini_options.testpaths`: Change `["placeholder", "tests"]` to `["acme", "tests"]` |
| 64 | + |
| 65 | +#### 3. Update Python imports |
| 66 | + |
| 67 | +Update imports in these files (change `from placeholder.` to `from acme.`): |
| 68 | + |
| 69 | +- `acme/feature_groups/my_plugin/__init__.py` |
| 70 | +- `acme/feature_groups/my_plugin/tests/test_my_feature_group.py` |
| 71 | +- `acme/compute_frameworks/my_plugin/__init__.py` |
| 72 | +- `acme/compute_frameworks/my_plugin/tests/test_my_compute_framework.py` |
| 73 | +- `acme/extenders/my_plugin/__init__.py` |
| 74 | +- `acme/extenders/my_plugin/tests/test_my_extender.py` |
| 75 | + |
| 76 | +#### 4. Verify setup |
| 77 | + |
| 78 | +```bash |
| 79 | +uv venv && source .venv/bin/activate && uv pip install -e ".[dev]" && tox |
| 80 | +``` |
| 81 | + |
| 82 | +### Development Setup with uv |
| 83 | + |
| 84 | +**Install uv** (if not already installed): |
| 85 | +```bash |
| 86 | +curl -LsSf https://astral.sh/uv/install.sh | sh |
| 87 | +``` |
| 88 | + |
| 89 | +**Create virtual environment and install dependencies:** |
| 90 | +```bash |
| 91 | +uv venv |
| 92 | +source .venv/bin/activate |
| 93 | +uv pip install -e ".[dev]" |
| 94 | +``` |
| 95 | + |
| 96 | +**Run all checks with tox:** |
| 97 | +```bash |
| 98 | +# Install tox with uv backend |
| 99 | +uv tool install tox --with tox-uv |
| 100 | + |
| 101 | +# Run all checks (pytest, ruff, mypy, bandit) |
| 102 | +tox |
| 103 | +``` |
| 104 | + |
| 105 | +### Run individual checks |
| 106 | + |
| 107 | +```bash |
| 108 | +# Tests only |
| 109 | +pytest |
| 110 | + |
| 111 | +# Format check |
| 112 | +ruff format --check --line-length 120 . |
| 113 | + |
| 114 | +# Lint check |
| 115 | +ruff check . |
| 116 | + |
| 117 | +# Type check |
| 118 | +mypy --strict --ignore-missing-imports . |
| 119 | + |
| 120 | +# Security check |
| 121 | +bandit -c pyproject.toml -r -q . |
| 122 | +``` |
| 123 | + |
| 124 | +### Add new FeatureGroup |
| 125 | +Create new directory under `placeholder/feature_groups/` following the `my_plugin/` pattern. |
| 126 | + |
| 127 | +## Related Documentation |
| 128 | + |
| 129 | +Guides for plugin development can be found in mloda-registry: |
| 130 | + |
| 131 | +- https://github.com/mloda-ai/mloda-registry/tree/main/docs/guides/ |
| 132 | + |
| 133 | +## Architecture Overview |
| 134 | + |
| 135 | +- [Repository structure and relationships](https://github.com/mloda-ai/mloda-registry/blob/main/docs/architecture/00_repositories.md) |
0 commit comments