mrmd-orchestrator
Python orchestrator for mrmd services. Starts and manages sync server, monitors, and runtimes.
Quick Start
# From mrmd-packages directory
cd mrmd-orchestrator
# Create virtual environment and install dependencies with uv
uv venv
uv pip install -e .
# Start everything
uv run mrmd
# Or with options
uv run mrmd --docs ./notebooks --port 3000
Then open http://localhost:8080/examples/minimal.html
What It Does
The orchestrator:
- Starts mrmd-sync - Yjs sync server on ws://localhost:4444
- Starts mrmd-python - Python runtime on http://localhost:8000
- Serves mrmd-editor - Static files on http://localhost:8080
- Manages monitors - Start/stop via HTTP API
┌─────────────────────────────────────────────────────────────────┐
│ mrmd-orchestrator (Python) │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ mrmd-sync │ │ mrmd-python │ │ HTTP Server │ │
│ │ (Node.js) │ │ (Python) │ │ + API │ │
│ │ port 4444 │ │ port 8000 │ │ port 8080 │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │
│ └──── monitors (per document) ──────┘ │
│ ┌─────────┐ ┌─────────┐ │
│ │monitor:a│ │monitor:b│ ... │
│ └─────────┘ └─────────┘ │
└─────────────────────────────────────────────────────────────────┘
CLI Options
mrmd [options]
Paths:
--docs, -d PATH Document directory (default: ./docs)
--packages PATH Path to mrmd-packages (auto-detected)
Ports:
--port, -p PORT HTTP/API port (default: 8080)
--sync-port PORT Sync server port (default: 4444)
--runtime-port PORT Python runtime port (default: 8000)
Remote Services (distributed mode):
--sync-url URL Connect to existing sync server
--runtime-url URL Connect to existing runtime
Disable Services:
--no-sync Don't start mrmd-sync
--no-runtime Don't start mrmd-python
--no-editor Don't serve editor files
--no-monitors Don't allow starting monitors
Auto-start:
--monitor DOC Auto-start monitor for document (repeatable)
Examples:
mrmd # Start everything
mrmd --docs ./notebooks # Custom docs directory
mrmd --monitor my-notebook # Auto-start monitor
mrmd --sync-url ws://remote:4444 # Use remote sync
HTTP API
Status
# Health check
GET /health
# Full status
GET /api/status
# Service URLs
GET /api/urls
Monitors
# List active monitors
GET /api/monitors
# Start monitor for document
POST /api/monitors
Content-Type: application/json
{"doc": "my-notebook"}
# Stop monitor
DELETE /api/monitors/my-notebook
# Check monitor status
GET /api/monitors/my-notebook
Logs
# Get recent output from a process
GET /api/logs/mrmd-sync?lines=100
GET /api/logs/mrmd-python?lines=50
GET /api/logs/monitor:my-notebook?lines=50
Distributed Mode
For users who want services on different machines:
# Machine 1: Sync server only
cd mrmd-sync && node bin/cli.js ./docs
# Machine 2: Python runtime only
cd mrmd-python && python -m mrmd_python.cli --port 8000
# Machine 3: Orchestrator connecting to remote services
mrmd \
--sync-url ws://machine1:4444 \
--runtime-url http://machine2:8000/mrp/v1 \
--no-sync \
--no-runtime
Or use the Python API:
from mrmd_orchestrator import Orchestrator, OrchestratorConfig
config = OrchestratorConfig.for_distributed(
sync_url="ws://remote-sync:4444",
runtime_urls={"python": "http://remote-python:8000/mrp/v1"},
)
orchestrator = Orchestrator(config)
await orchestrator.start()
Programmatic Usage
import asyncio
from mrmd_orchestrator import Orchestrator, OrchestratorConfig
async def main():
# Default config (start everything locally)
config = OrchestratorConfig.for_development()
# Create orchestrator
orchestrator = Orchestrator(config)
# Start services
await orchestrator.start()
# Start a monitor
await orchestrator.start_monitor("my-notebook")
# Check status
status = orchestrator.get_status()
print(status)
# Stop monitor
await orchestrator.stop_monitor("my-notebook")
# Stop everything
await orchestrator.stop()
asyncio.run(main())
Architecture: 1 Monitor Per Document
Each document gets its own monitor process:
Document A ──→ monitor:document-a ──→ mrmd-python (session: document-a)
Document B ──→ monitor:document-b ──→ mrmd-python (session: document-b)
Why?
- Isolation: Killing notebook A doesn't affect B
- Matches mental model: "Restart" means this notebook
- Security: Different permissions per notebook
- Matches Jupyter: 1 kernel per notebook
Trade-offs:
- More processes (10 notebooks = 10 monitors)
- Startup latency when opening new documents
Development
# Create venv and install with dev dependencies
cd mrmd-orchestrator
uv venv
uv pip install -e ".[dev]"
# Run tests
uv run pytest
# Run with debug logging
uv run mrmd --log-level debug
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mrmd_orchestrator-0.2.0.tar.gz
(110.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mrmd_orchestrator-0.2.0.tar.gz.
File metadata
- Download URL: mrmd_orchestrator-0.2.0.tar.gz
- Upload date:
- Size: 110.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff65e7a03da6fcb6467809e569a6aa7a3a2fd95ec9d9c3424bd82678fd1f9e0b
|
|
| MD5 |
f11cda2a1958131dcdccde1df3b4dd38
|
|
| BLAKE2b-256 |
1c9c3d62731b543aeec85792a956d8727b892a865f18b3e3d18949a95f3a7e87
|
File details
Details for the file mrmd_orchestrator-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mrmd_orchestrator-0.2.0-py3-none-any.whl
- Upload date:
- Size: 32.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
266d53117fa2be51d7d0ff87f1cf8508b92e11a1aed52a5c91daf2a11451869d
|
|
| MD5 |
e7bd44f50c8d8f5bddeb5122c0a3643d
|
|
| BLAKE2b-256 |
f5c409ce31e4536121381747da36dd03f5301705064601d8ea7d12fef9484810
|