Adding Policies
This guide explains how to add support for a new policy to Maple.
Overview
Adding a new policy requires:
Creating a Docker image with the policy server
Implementing a policy backend class
Creating an adapter for each environment
Step 1: Create Docker Image
Create a new directory under docker/:
mkdir -p docker/mypolicy
Create docker/mypolicy/policy_server.py with FastAPI endpoints:
GET /health- Health checkPOST /load- Load model weightsPOST /act- Get action for observationGET /info- Model information
Create docker/mypolicy/Dockerfile based on the OpenVLA example.
Step 2: Create Backend Class
Create maple/backend/policy/mypolicy.py:
from maple.backend.policy.base import DockerPolicyBackend
class MyPolicyBackend(DockerPolicyBackend):
name = "mypolicy"
IMAGE = "maple/mypolicy:latest"
HF_REPOS = {
"base": "org/mypolicy-base",
"large": "org/mypolicy-large",
}
DEFAULT_VERSION = "base"
Register in maple/backend/policy/registry.py:
from maple.backend.policy.mypolicy import MyPolicyBackend
POLICY_BACKENDS = {
"mypolicy": MyPolicyBackend,
# ...
}
Step 3: Create Adapter
Create maple/adapters/mypolicy_libero.py implementing observation and action transformations.
Register in maple/adapters/registry.py.
See ../api/adapters for detailed adapter documentation.