Skip to content

Commit

Permalink
Feature/remove poetry from pytorch example (#3226)
Browse files Browse the repository at this point in the history
Co-authored-by: Charles Beauville <[email protected]>
  • Loading branch information
chongshenng and charlesbvll authored Apr 22, 2024
1 parent ff9fc0b commit 96846d5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 49 deletions.
21 changes: 5 additions & 16 deletions examples/quickstart-pytorch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,28 @@ This will create a new directory called `quickstart-pytorch` containing the foll

```shell
-- pyproject.toml
-- requirements.txt
-- client.py
-- server.py
-- README.md
```

### Installing Dependencies

Project dependencies (such as `torch` and `flwr`) are defined in `pyproject.toml` and `requirements.txt`. We recommend [Poetry](https://python-poetry.org/docs/) to install those dependencies and manage your virtual environment ([Poetry installation](https://python-poetry.org/docs/#installation)) or [pip](https://pip.pypa.io/en/latest/development/), but feel free to use a different way of installing dependencies and managing virtual environments if you have other preferences.

#### Poetry
Project dependencies (such as `torch` and `flwr`) are defined in `pyproject.toml`. You can install the dependencies by invoking `pip`:

```shell
poetry install
poetry shell
# From a new python environment, run:
pip install .
```

Poetry will install all your dependencies in a newly created virtual environment. To verify that everything works correctly you can run the following command:
Then, to verify that everything works correctly you can run the following command:

```shell
poetry run python3 -c "import flwr"
python3 -c "import flwr"
```

If you don't see any errors you're good to go!

#### pip

Write the command below in your terminal to install the dependencies according to the configuration file requirements.txt.

```shell
pip install -r requirements.txt
```

______________________________________________________________________

## Run Federated Learning with PyTorch and Flower
Expand Down
26 changes: 15 additions & 11 deletions examples/quickstart-pytorch/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
[build-system]
requires = ["poetry-core>=1.4.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.poetry]
[project]
name = "quickstart-pytorch"
version = "0.1.0"
description = "PyTorch Federated Learning Quickstart with Flower"
authors = ["The Flower Authors <[email protected]>"]
authors = [
{ name = "The Flower Authors", email = "[email protected]" },
]
dependencies = [
"flwr>=1.8.0,<2.0",
"flwr-datasets[vision]>=0.0.2,<1.0.0",
"torch==2.1.1",
"torchvision==0.16.1",
"tqdm==4.65.0"
]

[tool.poetry.dependencies]
python = ">=3.8,<3.11"
flwr = ">=1.8.0,<2.0"
flwr-datasets = { extras = ["vision"], version = ">=0.0.2,<1.0.0" }
torch = "2.1.1"
torchvision = "0.16.1"
tqdm = "4.65.0"
[tool.hatch.build.targets.wheel]
packages = ["."]
5 changes: 0 additions & 5 deletions examples/quickstart-pytorch/requirements.txt

This file was deleted.

17 changes: 0 additions & 17 deletions examples/quickstart-pytorch/run.sh

This file was deleted.

0 comments on commit 96846d5

Please sign in to comment.