Synopsis
Description
Therun command executes a bootstrapped syft-flwr project in simulation mode using mock datasets. This allows you to:
- Test your federated learning workflow locally
- Validate model training with sample data
- Debug issues before deploying to distributed datasites
- Simulate multiple clients with different datasets
Arguments
Path to a bootstrapped syft-flwr project directory.The directory must contain:
pyproject.tomlwith syft-flwr configurationmain.py(created bysyft-flwr bootstrap)
~ are expanded.Options
Comma-separated list of paths to mock datasets for each client.Aliases:
-mFormat: Comma-separated file system paths (e.g., ./data/client1,./data/client2)Requirements:- Number of paths must match the number of datasites configured in
pyproject.toml - All paths must exist on the file system
- Each path should contain the dataset for one client
Display help information for the run command.Aliases:
-hExamples
Run with All Flags
Run with Interactive Prompts
Run with Short Flag
Run with Absolute Paths
Run with Current Directory
How It Works
Simulation Process
- Validation: Validates project structure and dataset paths
- Setup: Creates temporary SyftBox network directory
- Client Creation: Initializes mock RDS clients for each datasite
- Encryption Bootstrap: Sets up E2E encryption keys (if enabled)
- Parallel Execution: Runs server and all clients concurrently
- Logging: Captures output from each participant
- Cleanup: Removes temporary directories and configuration
Temporary Environment
During simulation, the following temporary directories are created:Simulation Logs
Logs are written toPROJECT_DIR/simulation_logs/:
Environment Variables
The run command sets environment variables for each participant:Path to the participant’s SyftBox client configuration file.Set automatically for each client and server process.
Path to the mock dataset for each client.Set from the corresponding
--mock-dataset-paths value.Enable or disable E2E encryption during simulation.Set to
false to disable encryption:Skip module validation during project loading.Useful for testing. Not recommended for production use.
Validation
The command validates:- Project directory exists and is a directory
- pyproject.toml exists with valid syft-flwr configuration
- main.py exists in the project directory
- All mock dataset paths exist on the file system
- Number of datasets matches number of configured datasites
Error Handling
Project Not Bootstrapped
Dataset Path Does Not Exist
Dataset Count Mismatch
Simulation Failed
./my-project/simulation_logs/ for details.
Async Execution
In environments with an existing event loop (e.g., Jupyter notebooks), the run command returns an asyncio Task:Encryption
By default, the simulation uses end-to-end encryption with:- Automatic key generation for all participants
- DID (Decentralized Identifier) document creation
- Encrypted message passing between clients and server
Performance
Parallel Execution
All clients run in parallel using asyncio, with the aggregator server coordinating the workflow. The simulation completes when the server process finishes.Resource Usage
Each client runs as a separate Python subprocess. For N clients:- Processes: N + 1 (clients + server)
- Memory: Depends on model size and dataset
- Disk: Temporary files for communication and logs
Exit Codes
0: Simulation succeeded1: Simulation failed (validation error, runtime error, etc.)
Best Practices
Dataset Preparation
Organize mock datasets clearly:Testing Before Deployment
Always run simulations before deploying to distributed datasites:- Create representative mock datasets
- Run simulation multiple times
- Review logs for errors
- Verify model training converges
- Check aggregation results
Debugging
Enable detailed logging in yourmain.py:
simulation_logs/.
See Also
- bootstrap command - Bootstrap a Flower project for syft-flwr
- CLI Overview - Complete CLI reference