nvflare.lighter.spec module

class Builder[source]

Bases: ABC

Abstract base class for FL startup kit builders.

A Builder is responsible for generating configuration or content used during federated learning provisioning. Builders participate in a three-phase lifecycle:

  1. initialize(project, ctx) – Prepare any resources or context needed for the build.

  2. build(project, ctx) – Perform the core build logic, modifying the context.

  3. finalize(project, ctx) – Clean up, validate, or finalize build outputs.

All builders registered in a provision workflow are executed in sequence.

The finalize phase is executed in reverse order from the other phases. This allows builders to finalize or clean up in a specific sequence when multiple builders are involved.

build(project: Project, ctx: ProvisionContext)[source]

Execute the main build logic for this builder.

Parameters:
  • project (Project) – The project to be provisioned.

  • ctx (ProvisionContext) – Context shared across builders.

finalize(project: Project, ctx: ProvisionContext)[source]

Finalize the build process and perform any cleanup.

Parameters:
  • project (Project) – The project to be provisioned.

  • ctx (ProvisionContext) – Context shared across builders.

initialize(project: Project, ctx: ProvisionContext)[source]

Prepare the builder with any necessary pre-processing.

Parameters:
  • project (Project) – The project to be provisioned.

  • ctx (ProvisionContext) – Context shared across builders.

class Packager[source]

Bases: ABC

Packager is responsible for packaging the generated startup kits for each participant after the kits have been generated by the builders.

The packager, if specified, is called as the last step of the provision process.

abstract package(project: Project, ctx: ProvisionContext)[source]

Package the generated startup kits for release.

Parameters:
  • project – the project being provisioned

  • ctx – the provision context object

Returns: None