Skip to main content

FLIP - Federated Learning and Interoperability Platform library built on NVIDIA FLARE

Project description

FLIP-FL-base-FLARE

flip-flare-logo

codecov PyPI version Docker - flare-fl-base Docker - flare-fl-server Docker - flare-fl-client Python 3.12+ Documentation StatusLicense

This repository contains the FLIP (Federated Learning and Interoperability Platform) federated learning base application utilities. It is a monorepo that includes:

  • flip — pip-installable Python package with platform logic, NVFLARE components, and utilities
  • tutorials/ — example applications you can run on the FLIP platform
  • fl_services/ — Docker services for running FL networks (server, clients, admin API)

Table of Contents


flip Python Package

The flip package is the core pip-installable library for the FLIP federated learning platform. It provides all platform logic core to training and evaluating FL applications.

Installation

uv sync
# or
pip install .

To build a distributable package:

uv build

Package Structure

flip/
├── core/         # FLIPBase, FLIPStandardProd/Dev implementations, FLIP() factory
├── constants/    # FlipConstants (pydantic-settings), enums, PTConstants
├── utils/        # General utilities: Utils, model weight helpers
└── nvflare/      # NVFLARE-specific logic and components
    ├── executors/    # RUN_TRAINER, RUN_VALIDATOR, RUN_EVALUATOR wrappers
    ├── controllers/  # Workflow controllers (ScatterAndGather, CrossSiteModelEval, …)
    └── components/   # Event handlers, persistors, privacy filters, locators, …

The FLIP() factory selects FLIPStandardDev (local CSV/filesystem) or FLIPStandardProd (FLIP platform APIs) based on the LOCAL_DEV environment variable.

User Application Requirements

User-provided files go in the job's custom/ directory and are dynamically imported by the executor wrappers:

File Description
trainer.py Training logic — must export FLIP_TRAINER class
validator.py Validation logic — must export FLIP_VALIDATOR class
models.py Model definitions — must export get_model() function
config.json Hyperparameters — must include LOCAL_ROUNDS and LEARNING_RATE
transforms.py Data transforms (optional)

Job Types

Set via the JOB_TYPE environment variable:

Type Description
standard Federated training with FedAvg aggregation (default)
evaluation Distributed model evaluation without training
diffusion_model Two-stage training (VAE encoder + diffusion)
fed_opt Custom federated optimization

The corresponding configs live in src/<job_type>/app/config/.

Development Mode

DEV mode lets you test FL applications locally before deploying to production.

  1. Edit .env.development:

    LOCAL_DEV=true
    DEV_IMAGES_DIR=../data/accession-resources
    DEV_DATAFRAME=../data/sample_get_dataframe.csv
    JOB_TYPE=standard
    
  2. Place your application files in src/<JOB_TYPE>/app/custom/.

  3. Run the simulator in Docker:

    make run-container
    

Unit Tests

make unit-test
# or
uv run pytest -s -vv

Tutorials

The tutorials/ directory contains ready-to-use example applications that can be uploaded to the FLIP platform UI. Each tutorial is designed to work with a specific app type from src/.

FL app structure

App / Tutorial Compatibility

App Tutorial
standard image_segmentation/3d_spleen_segmentation
standard image_classification/xray_classification
diffusion_model image_synthesis/latent_diffusion_model
fed_opt image_segmentation/3d_spleen_segmentation
evaluation image_evaluation/3d_spleen_segmentation

FL Services API

The fl_services/ directory contains Docker-based NVFLARE services. See the FL services README and the FL API README for full details on provisioning and the API endpoints.

Prerequisites

  • Docker and Docker Compose
  • uv (Python package manager)
  • AWS CLI configured (for downloading test data)

Provisioning a Network

Generate the certificates, keys, and configuration for a new FL network:

make nvflare-provision NET_NUMBER=1

This creates a network-specific compose file (deploy/compose-net-1.yml) and service secrets in workspace/net-1/services/ (gitignored). Multiple networks can be provisioned with different ports:

make nvflare-provision NET_NUMBER=2 FL_PORT=8004 ADMIN_PORT=8005

Warning: Provisioned files contain cryptographic signatures. Any modification will cause errors. Always re-run provisioning if changes are needed.

Running the Network

make build NET_NUMBER=1   # Build Docker images
make up NET_NUMBER=1      # Start the network (server, 2 clients, API)
make down NET_NUMBER=1    # Stop the network
make clean NET_NUMBER=1   # Remove containers and images

Integration Testing

Download test data (requires AWS S3 access) then run the relevant target:

make download-test-data
make test   # Run all integration tests

CI/CD

GitHub Actions workflows use OIDC to authenticate to AWS (no long-lived keys).

Trigger Target
PR to any branch s3://flipdev/base-application-dev/pull-requests/<PR_NUMBER>/src/
Merge to develop s3://flipdev/base-application-dev/src/ and s3://flipstag/base-application/src/
Merge to main s3://flipprod/base-application/src/

Warning: Never manually sync to the production bucket.

To test a PR on the FLIP platform, update FL_APP_BASE_BUCKET in the flip repo environment variables to point to your PR's S3 path.

Makefile Reference

Network Management

Command Description
make nvflare-provision NET_NUMBER=X Provision FL network X
make build NET_NUMBER=X Build Docker images for network X
make up NET_NUMBER=X Start FL network X
make down NET_NUMBER=X Stop FL network X
make clean NET_NUMBER=X Remove containers and images

Development

Command Description
make run-container Run NVFLARE simulator in Docker

Data Management

Command Description
make download-test-data Download all test data (x-ray and spleen images, model checkpoints) from S3

Testing

Command Description
make unit-test Run pytest unit tests for flip python package
make test-xrays-standard Test standard job with x-ray data
make test-spleen-standard Test standard job with spleen data
make test-spleen-evaluation Test evaluation job with spleen data
make test-spleen-diffusion Test diffusion model with spleen data
make test Run all integration tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flip_utils-0.1.3.tar.gz (44.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flip_utils-0.1.3-py3-none-any.whl (84.0 kB view details)

Uploaded Python 3

File details

Details for the file flip_utils-0.1.3.tar.gz.

File metadata

  • Download URL: flip_utils-0.1.3.tar.gz
  • Upload date:
  • Size: 44.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for flip_utils-0.1.3.tar.gz
Algorithm Hash digest
SHA256 44460635215a9be417260165db19f2800cc62a49aef11ee88373b9cbe149658f
MD5 be74ab363c4783a3706e5f53a0bfe6bd
BLAKE2b-256 3d82292a86e5375a77a484f4362b8ac542c0dd15dd81c476b9ef873193daf462

See more details on using hashes here.

File details

Details for the file flip_utils-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: flip_utils-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 84.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for flip_utils-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af016d7c3f09c1c12101904372f1953eace0b67b2776813cf8dac9d39dc400ec
MD5 caf12e6d15761f4970024b0142fcd908
BLAKE2b-256 0fc5b6866b495ce555ff648e61b05741f40cdfabe6290cb7a7fcb35b9eccb84d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page