Skip to main content

Enterprise-grade federated learning package (refactor of fl_framework)

Project description

Federated Learning — Enterprise Rewrite

This folder contains an enterprise-style refactor of the fl_framework package. The package is provided as federated_learning and preserves the original framework API while adding enterprise-oriented structure, packaging, and getting-started documentation.

Installation

  1. Create a virtual environment and install runtime dependencies:
python -m venv .venv
source .venv/bin/activate  # on Windows use `.venv\Scripts\Activate.ps1`
pip install -r requirements.txt

Quickstart — programmatic (Server)

Minimal example to start a server programmatically:

from federated_learning.config import FLConfig
from federated_learning.fl_server import FLServer

cfg = FLConfig(
	backend_url="http://localhost:8000",
	sqs_queue_url="https://sqs.us-east-1.amazonaws.com/…/server-queue",
	sqs_server_queue_url="https://sqs.us-east-1.amazonaws.com/…/server-queue",
	client_id="fl-server",
	model_id="my_model_v1",
	min_clients_for_aggregation=2,
)

server = FLServer(cfg, client_queue_urls=[
	"https://sqs.us-east-1.amazonaws.com/…/client-1",
	"https://sqs.us-east-1.amazonaws.com/…/client-2",
])
server.start()  # Blocking; use start_async() for background thread

Quickstart — programmatic (Client)

Client example (you must provide a model implementing FLModel):

from federated_learning.config import FLConfig
from federated_learning.fl_client import FLClient
from my_models import MyModel  # your implementation of FLModel

cfg = FLConfig(
	backend_url="http://localhost:8000",
	sqs_queue_url="https://sqs.us-east-1.amazonaws.com/…/client-queue",
	sqs_server_queue_url="https://sqs.us-east-1.amazonaws.com/…/server-queue",
	client_id="edge-node-1",
	model_id="my_model_v1",
)

model = MyModel()
client = FLClient(model=model, config=cfg, train_data_fn=lambda: load_train_df(), eval_data_fn=lambda: load_eval_df())
client.start()

CLI

A minimal CLI is provided for development:

python -m federated_learning.cli --role server --model-id my_model_v1

Testing

Run the basic import test:

pip install -r requirements.txt
pytest -q

Configuration

Most runtime options can be set via environment variables. Important keys:

  • FL_BACKEND_URL — Backend HTTP API base URL
  • FL_SQS_QUEUE_URL — SQS queue URL for client
  • FL_SQS_SERVER_QUEUE_URL — SQS queue URL for server
  • FL_USE_MONGODB — when true, use MongoDB storage backend
  • FL_MONGO_URI, FL_MONGO_DB — MongoDB connection details

Contributing

This repository is a starting point. Suggested next steps:

  • Add structured logging and Prometheus metrics.
  • Expand unit tests for aggregator, transport, and sqs_listener.
  • Add CI (GitHub Actions) and packaging (wheel) pipelines.

See the package source in the federated_learning package for implementation details.

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

federated_learning_enterprise-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

federated_learning_enterprise-0.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file federated_learning_enterprise-0.1.0.tar.gz.

File metadata

File hashes

Hashes for federated_learning_enterprise-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb9fe818f3959119643634217f0927db6b8c9b2c14da468d3a1c7e9c5b5f4da6
MD5 6dca545bd9fef1a3b3e700ee6fc46102
BLAKE2b-256 acb2d139a97d3e6fbc9820f00667e6c401278f14602274ea9c2f2ca2a1d1e2e6

See more details on using hashes here.

File details

Details for the file federated_learning_enterprise-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for federated_learning_enterprise-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee5b3732d8533857e8b7a879ffe227213c79bb0101f733fc0626f5069106242d
MD5 655b6ae2828269fbc018d7a01b9847f6
BLAKE2b-256 a827aa090c320e7abce301ed41e339c7c1e2c852edfbd470f2860ee094627f30

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