Overview
Thebootstrap function prepares a Flower project for use with Syft-Flwr by configuring the project metadata and creating the necessary runtime files.
Function Signature
Parameters
Path to the Flower project directory. Must contain a
pyproject.toml file and not already have a main.py file.Email of the aggregator (Data Scientist). Must be a valid datasite email address.
List of datasite emails (Data Owners). Each email must be a valid datasite address.
Communication transport to use at runtime:
"syftbox": Local SyftBox with RPC/crypto (default for non-Colab environments)"p2p": P2P sync via Google Drive/OneDrive (default for Colab environments)None: Auto-detect based on environment
Returns
None - The function modifies the project directory in place.
What It Does
- Validates the project directory - Ensures
pyproject.tomlexists andmain.pydoesn’t - Updates
pyproject.tomlwith:- Unique app name:
{aggregator}_{base_app_name}_{timestamp} - Datasites and aggregator configuration
- Transport type configuration
- Adds
syft_flwras a dependency
- Unique app name:
- Creates
main.py- Generates the runtime entrypoint that determines who runs what based on metadata
Usage Example
Fromnotebooks/fl-diabetes-prediction/local/ds.ipynb:252-260:
Modified Configuration
After bootstrapping, thepyproject.toml will include:
Exceptions
FileExistsError
Raised if
main.py already exists in the project directory.FileNotFoundError
Raised if the project directory or
pyproject.toml doesn’t exist.ValueError
Raised if:
- Invalid transport type (not
"syftbox"or"p2p") - Invalid datasite email format for aggregator or any datasite
Notes
- The function auto-detects Google Colab environments and defaults to
"p2p"transport - A unique app name is generated using the current timestamp to avoid conflicts
- The bootstrapped project maintains the same structure as a standard Flower project