Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove poetry from pytorch example #3226

Merged
merged 16 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.