From 6fb13bc9a696ac955b2bb90812049555ec2f2eb6 Mon Sep 17 00:00:00 2001 From: yan-gao-GY Date: Wed, 18 Sep 2024 17:58:52 +0100 Subject: [PATCH] Formatting --- examples/xgboost-comprehensive/README.md | 1 - examples/xgboost-comprehensive/pyproject.toml | 1 - .../xgboost_comprehensive/client_app.py | 10 ++++++++-- .../xgboost_comprehensive/server_app.py | 4 +++- .../xgboost_comprehensive/task.py | 12 +++++++++--- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/xgboost-comprehensive/README.md b/examples/xgboost-comprehensive/README.md index 2bb7e08df3d7..d28b719edbf2 100644 --- a/examples/xgboost-comprehensive/README.md +++ b/examples/xgboost-comprehensive/README.md @@ -103,7 +103,6 @@ flwr run . --run-config "train-method='cyclic' partitioner-type='linear' central > \[!NOTE\] > An update to this example will show how to run this Flower application with the Deployment Engine and TLS certificates, or with Docker. - ## Expected Experimental Results ### Bagging aggregation experiment diff --git a/examples/xgboost-comprehensive/pyproject.toml b/examples/xgboost-comprehensive/pyproject.toml index 28409b5eb4d4..25af0483a9bf 100644 --- a/examples/xgboost-comprehensive/pyproject.toml +++ b/examples/xgboost-comprehensive/pyproject.toml @@ -53,4 +53,3 @@ default = "local-simulation" [tool.flwr.federations.local-simulation] options.num-supernodes = 5 options.backend.client-resources.num-cpus = 2 -options.backend.client-resources.num-gpus = 0.0 diff --git a/examples/xgboost-comprehensive/xgboost_comprehensive/client_app.py b/examples/xgboost-comprehensive/xgboost_comprehensive/client_app.py index 7ed1bd7f08d5..9c583e209067 100644 --- a/examples/xgboost-comprehensive/xgboost_comprehensive/client_app.py +++ b/examples/xgboost-comprehensive/xgboost_comprehensive/client_app.py @@ -133,8 +133,14 @@ def client_fn(context: Context): centralised_eval_client = cfg["centralised_eval_client"] # Load training and validation data - train_dmatrix, valid_dmatrix, num_train, num_val = load_data(partitioner_type, partition_id, num_partitions, - centralised_eval_client, test_fraction, seed) + train_dmatrix, valid_dmatrix, num_train, num_val = load_data( + partitioner_type, + partition_id, + num_partitions, + centralised_eval_client, + test_fraction, + seed, + ) # Setup learning rate if cfg["scaled_lr"]: diff --git a/examples/xgboost-comprehensive/xgboost_comprehensive/server_app.py b/examples/xgboost-comprehensive/xgboost_comprehensive/server_app.py index fde276b06d13..07bbd3cb3ea4 100644 --- a/examples/xgboost-comprehensive/xgboost_comprehensive/server_app.py +++ b/examples/xgboost-comprehensive/xgboost_comprehensive/server_app.py @@ -152,7 +152,9 @@ def server_fn(context: Context): config = ServerConfig(num_rounds=num_rounds) client_manager = CyclicClientManager() if train_method == "cyclic" else None - return ServerAppComponents(strategy=strategy, config=config, client_manager=client_manager) + return ServerAppComponents( + strategy=strategy, config=config, client_manager=client_manager + ) # Create ServerApp diff --git a/examples/xgboost-comprehensive/xgboost_comprehensive/task.py b/examples/xgboost-comprehensive/xgboost_comprehensive/task.py index bdd40222cade..74605da031d4 100644 --- a/examples/xgboost-comprehensive/xgboost_comprehensive/task.py +++ b/examples/xgboost-comprehensive/xgboost_comprehensive/task.py @@ -1,8 +1,6 @@ """xgboost_comprehensive: A Flower / XGBoost app.""" from logging import INFO -from typing import Union -from tqdm import tqdm import xgboost as xgb from datasets import Dataset, DatasetDict, concatenate_datasets @@ -24,6 +22,7 @@ fds = None # Cache FederatedDataset + def train_test_split(partition, test_fraction, seed): """Split the data into train and validation set given split rate.""" train_test = partition.train_test_split(test_size=test_fraction, seed=seed) @@ -60,7 +59,14 @@ def instantiate_fds(partitioner_type, num_partitions): return fds -def load_data(partitioner_type, partition_id, num_partitions, centralised_eval_client, test_fraction, seed): +def load_data( + partitioner_type, + partition_id, + num_partitions, + centralised_eval_client, + test_fraction, + seed, +): """Load partition data.""" fds_ = instantiate_fds(partitioner_type, num_partitions) partition = fds_.load_partition(partition_id)