This API allows you to define and execute custom workflow steps. The system dynamically loads step definitions and implementations from custom directories using a callback-based architecture.
Your custom step directory should contain Python files with step definitions and implementations. The system uses a callback-based approach where step definitions reference their implementations.
- Step Definitions: A dictionary or function that returns
StepDefinitionobjects with callback references - Step Implementations: Async functions that implement the steps, referenced by callbacks
custom_steps/
├── definitions.py # Step definitions with callbacks
└── steps.py # Step implementations
definitions.py:
from app.models import StepDefinition
STEP_DEFINITIONS = {
"data_validation": StepDefinition(
id="data_validation",
name="Data Validation",
description="Validates input data format and constraints",
callback="steps.validate_data", # References implementation
params_schema={
"type": "object",
"properties": {
"data_path": {
"type": "string",
"title": "Data Path",
"description": "Path to the data file to validate"
}
},
"required": ["data_path"]
}
)
}steps.py:
import asyncio
from typing import Dict, Any
from app.core import StepContext
async def validate_data(params: Dict[str, Any], context: StepContext):
await context.info("Starting", f"Validating {params.get('data_path')}")
# Your custom logic here
await asyncio.sleep(1)
await context.success("Complete", "Validation completed")
return {"valid": True, "records": 1000}python main.py --helpAvailable options:
--include-steps-root: Path to directory containing custom step definitions (required)--userdata-root: Path to main userdata directory (will contain uploads and projects)--host: Host to bind server to (default: 0.0.0.0)--port: Port to bind server to (default: 8001)
my_custom_steps/
├── definitions.py
└── steps.py
python main.py --include-steps-root ./my_custom_steps --include-steps-root ./bundled_steps/project --userdata-root ./my_userdata