From 02bb3ba734b85c5fcb7bca6d9a7381562f3fd8ce Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 29 Nov 2023 11:54:09 +0000 Subject: [PATCH] Fix vertical-fl example (#2655) Co-authored-by: Charles Beauville --- examples/vertical-fl/pyproject.toml | 6 +++--- examples/vertical-fl/requirements.txt | 2 +- examples/vertical-fl/simulation.py | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/vertical-fl/pyproject.toml b/examples/vertical-fl/pyproject.toml index 3c3307f24f08..14771c70062f 100644 --- a/examples/vertical-fl/pyproject.toml +++ b/examples/vertical-fl/pyproject.toml @@ -3,14 +3,14 @@ requires = ["poetry-core>=1.4.0"] build-backend = "poetry.core.masonry.api" [tool.poetry] -name = "quickstart-pytorch" +name = "vertical-fl" version = "0.1.0" -description = "PyTorch Federated Learning Quickstart with Flower" +description = "PyTorch Vertical FL with Flower" authors = ["The Flower Authors "] [tool.poetry.dependencies] python = ">=3.8,<3.11" -flwr = ">=1.0,<2.0" +flwr = { extras = ["simulation"], version = ">=1.0,<2.0" } torch = "2.1.0" matplotlib = "3.7.3" scikit-learn = "1.3.2" diff --git a/examples/vertical-fl/requirements.txt b/examples/vertical-fl/requirements.txt index f5c4f6f7b453..aee341e4c554 100644 --- a/examples/vertical-fl/requirements.txt +++ b/examples/vertical-fl/requirements.txt @@ -1,4 +1,4 @@ -flwr>=1.0, <2.0 +flwr[simulation]>=1.0, <2.0 torch==2.1.0 matplotlib==3.7.3 scikit-learn==1.3.2 diff --git a/examples/vertical-fl/simulation.py b/examples/vertical-fl/simulation.py index a6b1184dd76c..095ec6e0c7ea 100644 --- a/examples/vertical-fl/simulation.py +++ b/examples/vertical-fl/simulation.py @@ -2,6 +2,7 @@ import numpy as np from strategy import Strategy from client import FlowerClient +from pathlib import Path from task import get_partitions_and_label partitions, label = get_partitions_and_label() @@ -19,4 +20,6 @@ def client_fn(cid): strategy=Strategy(label), ) -np.save("_static/results/hist.npy", hist) +results_dir = Path("_static/results") +results_dir.mkdir(exist_ok=True) +np.save(str(results_dir/"hist.npy"), hist)