Data Scientist: Bootstrapping with syft-flwr
Learn how to convert existing Flower projects to use SyftBox's file sync network with minimal code changes.
Bootstrapping is the process of wrapping a standard Flower application in the syft-flwr communication layer. This allows the ServerApp (the aggregator) and the ClientApp (running on Data Owner sites) to exchange model weights through SyftBox instead of direct gRPC connections. By bootstrapping, you enable your project to utilize SyftBox's file sync network for secure, distributed communication with minimal code changes.
1. Using the syft_flwr bootstrap Command
The syft-flwr CLI provides a utility to automate the conversion process.
- Initialization: Navigate to your Flower project directory and run:
syft-flwr bootstrap .
- Function: This command scans your existing
pyproject.tomland directory structure to identify the ClientApp and ServerApp entry points. - Automation: It automatically adds the necessary
syft-flwrdependencies and modifies the federation configuration to target the SyftBox file sync protocol.
2. Configuring Aggregator and Datasites
Once bootstrapped, you must define where the training will take place within your pyproject.toml.
- Aggregator Node: Specify the email or UID of the SyftBox node that will act as the central server.
- Target Datasites: List the participating Data Owner emails. These are the nodes where your
ClientAppwill be sent for execution. - Federation Section: Update the
[tool.flwr.federations]section to include asyftboxprofile instead of a local simulation.
3. Updating pyproject.toml
The bootstrap process makes key additions to your configuration file:
[tool.flwr.app.components]: Points to yourserver_appandclient_appobjects.[tool.flwr.app.config]: Holds the hyperparameters (rounds, learning rate) that will be synced across the network.- Dependencies: Ensures
syft-flwris listed in thedependenciesarray so it is installed on the remote Data Owner's sandbox.
4. Adding syft-flwr Dependencies
Your project requires specific libraries to handle the SyftBox transport layer:
- Core Library: Ensure
syft-flwris installed in your local environment. - Compatibility: The bootstrapping tool ensures that the version of
flwrin your project is compatible with the version ofsyft-flwrbeing used.
5. Project Configuration Options
You can further customize how your project behaves on the SyftBox network:
- Privacy Budget: Configure Differential Privacy (DP) parameters directly in the
tomlfile if supported by your strategy. - Job Metadata: Add a project description and motivation. This is vital because Data Owners will see this info when reviewing your job proposal.
- Resource Limits: Optionally request specific hardware (e.g., GPU access) if the Data Owner allows it.
Next Step: With your project bootstrapped, you are ready to move to Submitting FL Jobs to push your code to the Data Owners for approval.