This guide helps you migrate from legacy IPFS Accelerate tools to the new unified architecture with kit modules, unified CLI, and MCP tools.
- Single Source of Truth: Core logic in kit modules, no duplication
- Multiple Interfaces: Same functionality via CLI, MCP, or Python API
- Better Testing: Pure Python modules easy to unit test
- Consistency: Same behavior across all interfaces
- Maintainability: Changes in one place, propagates everywhere
- Type Safety: Full type hints throughout
- Documentation: Comprehensive docstrings
Before:
# Using gh CLI directly
gh repo list username --limit 10
gh pr list --repo owner/repo --state openAfter:
# Using unified CLI
ipfs-accelerate github list-repos --owner username --limit 10
ipfs-accelerate github list-prs --repo owner/repo --state openBefore:
# Using docker CLI directly
docker run python:3.9 python --version
docker ps -aAfter:
# Using unified CLI
ipfs-accelerate docker run --image python:3.9 --command "python --version"
ipfs-accelerate docker list --allBefore:
# Using various system tools
lscpu
nvidia-smiAfter:
# Using unified CLI
ipfs-accelerate hardware info --detailed
ipfs-accelerate hardware test --accelerator cudaBefore:
# Using standalone script
python scripts/utils/github_autoscaler.py --owner myorg --interval 60After (CLI):
# Using unified CLI
ipfs-accelerate runner start --owner myorg --interval 60 --background
ipfs-accelerate runner status
ipfs-accelerate runner list-workflowsAfter (Python API):
from ipfs_accelerate_py.kit.runner_kit import get_runner_kit, RunnerConfig
config = RunnerConfig(
owner='myorg',
poll_interval=60,
max_runners=8
)
kit = get_runner_kit(config)
kit.start_autoscaler(background=True)
# Monitor status
status = kit.get_status()
print(f"Running: {status.running}")
print(f"Active runners: {status.active_runners}")Before:
import subprocess
result = subprocess.run(['gh', 'repo', 'list', 'owner'], capture_output=True)After:
from ipfs_accelerate_py.kit.github_kit import GitHubKit
kit = GitHubKit()
result = kit.list_repos(owner='owner', limit=10)
if result.success:
repos = result.data
else:
print(f"Error: {result.error}")Before:
import subprocess
result = subprocess.run(['docker', 'run', 'python:3.9', 'python', '--version'],
capture_output=True)After:
from ipfs_accelerate_py.kit.docker_kit import DockerKit
kit = DockerKit()
result = kit.run_container(
image='python:3.9',
command='python --version',
memory_limit='512m',
timeout=30
)
if result.success:
print(result.output)Before:
import platform
import psutil
system = platform.system()
cpu_count = psutil.cpu_count()After:
from ipfs_accelerate_py.kit.hardware_kit import HardwareKit
kit = HardwareKit()
info = kit.get_hardware_info()
print(f"System: {info.platform_info['system']}")
print(f"CPUs: {info.cpu['count']}")
print(f"Memory: {info.memory['total_gb']:.2f} GB")
print(f"Accelerators: {list(info.accelerators.keys())}")Before:
from ipfs_accelerate_py.mcp.tools import some_legacy_tool
result = some_legacy_tool(param1, param2)After:
from ipfs_accelerate_py.mcp.unified_tools import (
github_list_repos,
docker_run_container,
hardware_get_info
)
# All tools follow consistent patterns
repos = github_list_repos(owner='owner', limit=10)
container = docker_run_container(image='python:3.9', command='python --version')
hardware = hardware_get_info(include_detailed=True)Via MCP Server (JavaScript):
// Using MCP JavaScript SDK
const repos = await mcp.call_tool('github_list_repos', {
owner: 'owner',
limit: 10
});
const result = await mcp.call_tool('docker_run_container', {
image: 'python:3.9',
command: 'python --version'
});
const hardware = await mcp.call_tool('hardware_get_info', {
include_detailed: true
});- List all scripts/tools using legacy interfaces
- Identify which kit modules they need
- Check if equivalent functionality exists
# Ensure you have latest version
cd ipfs_accelerate_py
git pull
pip install -e .# Test CLI works
python ipfs_accelerate_py/unified_cli.py --help
python ipfs_accelerate_py/unified_cli.py hardware info
# Test in Python
python -c "from ipfs_accelerate_py.kit.hardware_kit import HardwareKit; print(HardwareKit().get_hardware_info())"- Start with simplest scripts
- Migrate to kit modules
- Test thoroughly
- Update documentation
- Keep legacy version temporarily
Update any CI/CD pipelines using old commands:
Before:
- run: python scripts/utils/github_autoscaler.py --owner myorgAfter:
- run: python ipfs_accelerate_py/unified_cli.py runner start --owner myorg --background- Add deprecation warnings
- Update documentation
- Plan removal timeline
- Communicate to users
Replace direct CLI calls with unified CLI:
# Old
gh repo list owner
# New
ipfs-accelerate github list-repos --owner ownerReplace subprocess calls with kit modules:
# Old
import subprocess
result = subprocess.run(['command'], capture_output=True)
# New
from ipfs_accelerate_py.kit.module_kit import ModuleKit
kit = ModuleKit()
result = kit.method()Use unified MCP tools:
# Old - Direct tool function
from some_module import tool
result = tool(args)
# New - Unified tool
from ipfs_accelerate_py.mcp.unified_tools import tool_name
result = tool_name(args)Solution: Ensure you're importing from correct location:
# Correct
from ipfs_accelerate_py.kit.github_kit import GitHubKit
# Not
from ipfs_kit_py.github_kit import GitHubKit # Wrong packageSolution: Use full path or create alias:
# Full path
python /path/to/ipfs_accelerate_py/unified_cli.py hardware info
# Or create alias
alias ipfs-accelerate="python /path/to/ipfs_accelerate_py/unified_cli.py"Solution: Check new API documentation and adjust parameters. Kit modules may have enhanced validation or different defaults.
- Documentation: See
docs/UNIFIED_ARCHITECTURE.md - Examples: Check
examples/directory - Tests: Look at
test/test_*_kit.pyfor usage patterns - Issues: Report on GitHub
Current (v0.x):
- ✅ Unified architecture available
- ✅ Both old and new interfaces work
⚠️ Migration recommended
Future (v1.x):
- Deprecation warnings added
- Old interfaces marked as deprecated
Future (v2.x):
- Old interfaces removed
- Unified architecture only
The unified architecture provides:
- ✅ Better code organization
- ✅ Multiple access methods (CLI, MCP, Python)
- ✅ Improved testing
- ✅ Consistent interfaces
- ✅ Better documentation
Migration is straightforward and provides immediate benefits. Start migrating high-value scripts first, then gradually migrate remaining code.