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

docs: run python library solely #187

Merged
merged 1 commit into from
Jul 15, 2022
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
38 changes: 38 additions & 0 deletions lib/python/flame/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# A guide to run python library locally without engaging with the system components

## Environment Setup
We recommend setting up your environment with `conda`. This example is based on Ubuntu 22.04.
```bash
conda create -n flame python=3.9
conda activate flame


pip install google
pip install tensorflow
pip install torch
pip install torchvision

cd ..
make install
```

## Configuring Brokers
As the flame system uses MQTT brokers to exchange messages during federated learning, to run the python library locally, you could either 1) install a local MQTT broker 2) use a public MQTT broker. Here we'll illustrate the second option.

Go to any examples that you wish to run locally in `examples` directory, change the `host` from `"flame-mosquitto"` to `broker.hivemq.com` in the `config.json` files of both the trainer and aggregator.

## Running the Python Code

```bash
cd examples/mnist/trainer

python keras/main.py config.json
```

```bash
# Open another terminal
conda activate flame
cd examples/mnist/aggregator

python keras/main.py config.json
```
29 changes: 12 additions & 17 deletions lib/python/flame/examples/mnist/aggregator/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"backend": "mqtt",
"brokers": [
{
"host": "flame-mosquitto",
"host": "broker.hivemq.com",
"sort": "mqtt"
}
],
Expand Down Expand Up @@ -37,31 +37,26 @@
"rounds": 5
},
"baseModel": {
"name": "",
"version": 2
"name": "",
"version": 2
},
"job" : {
"id": "622a358619ab59012eabeefb",
"name": "mnist"
"id": "622a358619ab59012eabeefb",
"name": "mnist"
},
"registry": {
"sort": "mlflow",
"uri": "http://flame-mlflow:5000"
"sort": "dummy",
"uri": ""
},
"selector": {
"sort": "random",
"kwargs": {"k": 1}
"sort": "default",
"kwargs": {}
},
"optimizer": {
"sort": "fedyogi",
"kwargs": {
"beta_1": 0.9,
"beta_2": 0.99,
"eta": 1,
"tau": 1
}
"sort": "fedavg",
"kwargs": {}
},
"maxRunTime": 300,
"realm": "",
"realm": "default",
"role": "aggregator"
}
29 changes: 12 additions & 17 deletions lib/python/flame/examples/mnist/trainer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"backend": "mqtt",
"brokers": [
{
"host": "flame-mosquitto",
"host": "broker.hivemq.com",
"sort": "mqtt"
}
],
Expand Down Expand Up @@ -37,31 +37,26 @@
"rounds": 5
},
"baseModel": {
"name": "",
"version": 1
"name": "",
"version": 1
},
"job" : {
"id": "622a358619ab59012eabeefb",
"name": "mnist"
"id": "622a358619ab59012eabeefb",
"name": "mnist"
},
"registry": {
"sort": "mlflow",
"uri": "http://flame-mlflow:5000"
"sort": "dummy",
"uri": ""
},
"selector": {
"sort": "random",
"kwargs": {"k": 1}
"sort": "default",
"kwargs": {}
},
"optimizer": {
"sort": "fedyogi",
"kwargs": {
"beta_1": 0.9,
"beta_2": 0.99,
"eta": 1,
"tau": 1
}
"sort": "fedavg",
"kwargs": {}
},
"maxRunTime": 300,
"realm": "us|west",
"realm": "default/us/west",
"role": "trainer"
}