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 quickstart tensorflow #3228

Merged
merged 8 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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-tensorflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,28 @@ This will create a new directory called `quickstart-tensorflow` containing the f

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

### Installing Dependencies

Project dependencies (such as `tensorflow` 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 `tensorflow` 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"
python -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 TensorFlow/Keras and Flower

Afterward, you are ready to start the Flower server as well as the clients. You can simply start the server in a terminal as follows:
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart-tensorflow/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
type=int,
choices=[0, 1, 2],
default=0,
help="Partition of the dataset (0,1 or 2). "
help="Partition of the dataset (0, 1 or 2). "
"The dataset is divided into 3 partitions created artificially.",
)
args, _ = parser.parse_known_args()
Expand Down
24 changes: 14 additions & 10 deletions examples/quickstart-tensorflow/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
[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-tensorflow"
version = "0.1.0"
description = "Keras Federated Learning Quickstart with Flower"
authors = ["The Flower Authors <hello@flower.ai>"]
authors = [
{ name = "The Flower Authors", email = "hello@flower.ai" },
]
dependencies = [
"flwr>=1.8.0,<2.0",
"flwr-datasets[vision]>=0.0.2,<1.0.0",
"tensorflow-cpu>=2.9.1, != 2.11.1 ; platform_machine == \"x86_64\"",
"tensorflow-macos>=2.9.1, != 2.11.1 ; sys_platform == \"darwin\" and platform_machine == \"arm64\""
]

[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" }
tensorflow-cpu = { version = ">=2.9.1,<2.11.1 || >2.11.1", markers = "platform_machine == \"x86_64\"" }
tensorflow-macos = { version = ">=2.9.1,<2.11.1 || >2.11.1", markers = "sys_platform == \"darwin\" and platform_machine == \"arm64\"" }
[tool.hatch.build.targets.wheel]
packages = ["."]
4 changes: 0 additions & 4 deletions examples/quickstart-tensorflow/requirements.txt

This file was deleted.

15 changes: 0 additions & 15 deletions examples/quickstart-tensorflow/run.sh

This file was deleted.