Skip to content

Commit

Permalink
docs(examples:skip) Use dict for framework and datasets links (#3709)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll authored Jul 4, 2024
1 parent 498a560 commit 049d929
Show file tree
Hide file tree
Showing 44 changed files with 148 additions and 144 deletions.
74 changes: 60 additions & 14 deletions dev/build-example-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,65 @@
"other": {"table": table_headers, "list": ""},
}

urls = {
# Frameworks
"Android": "https://www.android.com/",
"C++": "https://isocpp.org/",
"Docker": "https://www.docker.com/",
"JAX": "https://jax.readthedocs.io/en/latest/",
"Java": "https://www.java.com/",
"Keras": "https://keras.io/",
"Kotlin": "https://kotlinlang.org/",
"mlcube": "https://docs.mlcommons.org/mlcube/",
"MLX": "https://ml-explore.github.io/mlx/build/html/index.html",
"MONAI": "https://monai.io/",
"PEFT": "https://huggingface.co/docs/peft/index",
"Swift": "https://www.swift.org/",
"TensorFlowLite": "https://www.tensorflow.org/lite",
"fastai": "https://fast.ai/",
"lifelines": "https://lifelines.readthedocs.io/en/latest/index.html",
"lightning": "https://lightning.ai/docs/pytorch/stable/",
"numpy": "https://numpy.org/",
"opacus": "https://opacus.ai/",
"pandas": "https://pandas.pydata.org/",
"scikit-learn": "https://scikit-learn.org/",
"tabnet": "https://github.com/titu1994/tf-TabNet",
"tensorboard": "https://www.tensorflow.org/tensorboard",
"tensorflow": "https://www.tensorflow.org/",
"torch": "https://pytorch.org/",
"torchvision": "https://pytorch.org/vision/stable/index.html",
"transformers": "https://huggingface.co/docs/transformers/index",
"wandb": "https://wandb.ai/home",
"whisper": "https://huggingface.co/openai/whisper-tiny",
"xgboost": "https://xgboost.readthedocs.io/en/stable/",
# Datasets
"Adult Census Income": "https://www.kaggle.com/datasets/uciml/adult-census-income/data",
"Alpaca-GPT4": "https://huggingface.co/datasets/vicgalle/alpaca-gpt4",
"CIFAR-10": "https://huggingface.co/datasets/uoft-cs/cifar10",
"HIGGS": "https://archive.ics.uci.edu/dataset/280/higgs",
"IMDB": "https://huggingface.co/datasets/stanfordnlp/imdb",
"Iris": "https://scikit-learn.org/stable/auto_examples/datasets/plot_iris_dataset.html",
"MNIST": "https://huggingface.co/datasets/ylecun/mnist",
"MedNIST": "https://medmnist.com/",
"Oxford Flower-102": "https://www.robots.ox.ac.uk/~vgg/data/flowers/102/",
"SpeechCommands": "https://huggingface.co/datasets/google/speech_commands",
"Titanic": "https://www.kaggle.com/competitions/titanic",
}

def _convert_to_link(search_result):
if "|" in search_result:
if "," in search_result:
result = ""
for part in search_result.split(","):
result += f"{_convert_to_link(part)}, "
return result[:-2]

name, url = search_result.replace('"', "").split("|")
return f"`{name.strip()} <{url.strip()}>`_"

return search_result
def _convert_to_link(search_result):
if "," in search_result:
result = ""
for part in search_result.split(","):
result += f"{_convert_to_link(part)}, "
return result[:-2]
else:
search_result = search_result.strip()
name, url = search_result, urls.get(search_result, None)
if url:
return f"`{name.strip()} <{url.strip()}>`_"
else:
return search_result


def _read_metadata(example):
Expand All @@ -85,7 +131,7 @@ def _read_metadata(example):
raise ValueError("Metadata block not found")
metadata = metadata_match.group(1)

title_match = re.search(r"^title:\s*(.+)$", metadata, re.MULTILINE)
title_match = re.search(r"^# (.+)$", content, re.MULTILINE)
if not title_match:
raise ValueError("Title not found in metadata")
title = title_match.group(1).strip()
Expand Down Expand Up @@ -163,7 +209,7 @@ def _copy_images(example):
)


def _add_all_entries(index_file):
def _add_all_entries():
examples_dir = os.path.join(ROOT, "examples")
for example in sorted(os.listdir(examples_dir)):
example_path = os.path.join(examples_dir, example)
Expand Down Expand Up @@ -211,7 +257,7 @@ def _main():
)
index_file.write(categories["other"]["table"])

_add_all_entries(index_file)
_add_all_entries()

index_file.write(
"\n.. toctree::\n :maxdepth: 1\n :caption: Quickstart\n :hidden:\n\n"
Expand Down
5 changes: 2 additions & 3 deletions examples/advanced-pytorch/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Advanced Flower Example using PyTorch
tags: [advanced, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [torch | https://pytorch.org/, torchvision | https://pytorch.org/vision/stable/index.html]
dataset: [CIFAR-10]
framework: [torch, torchvision]
---

# Advanced Flower Example (PyTorch)
Expand Down
5 changes: 2 additions & 3 deletions examples/advanced-tensorflow/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Advanced Flower Example using TensorFlow/Keras
tags: [advanced, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [tensorflow | https://www.tensorflow.org/, Keras | https://keras.io/]
dataset: [CIFAR-10]
framework: [tensorflow, Keras]
---

# Advanced Flower Example (TensorFlow/Keras)
Expand Down
8 changes: 3 additions & 5 deletions examples/android-kotlin/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
title: Flower Android Example using Kotlin and TF Lite
tags: [basic, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [Android | https://www.android.com/, Kotlin | https://kotlinlang.org/,
TensorFlowLite | https://www.tensorflow.org/lite]
tags: [mobile, vision, sdk]
dataset: [CIFAR-10]
framework: [Android, Kotlin, TensorFlowLite]
---

# Flower Android Client Example with Kotlin and TensorFlow Lite 2022
Expand Down
8 changes: 3 additions & 5 deletions examples/android/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
title: Flower Android Example using Java and TF Lite
tags: [basic, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [Android | https://www.android.com/, Java | https://www.java.com/, TensorFlowLite
| https://www.tensorflow.org/lite]
tags: [mobile, vision, sdk]
dataset: [CIFAR-10]
framework: [Android, Java, TensorFlowLite]
---

# Flower Android Example (TensorFlowLite)
Expand Down
5 changes: 2 additions & 3 deletions examples/app-pytorch/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Example Flower App using PyTorch
tags: [basic, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [torch | https://pytorch.org/, torchvision | https://pytorch.org/vision/stable/index.html]
dataset: [CIFAR-10]
framework: [torch, torchvision]
---

# Flower App (PyTorch) 🧪
Expand Down
3 changes: 1 addition & 2 deletions examples/app-secure-aggregation/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Example Flower App with Secure Aggregation
tags: [basic, vision, fds]
dataset: []
framework: [numpy | https://numpy.org/]
framework: [numpy]
---

# Secure aggregation with Flower (the SecAgg+ protocol) 🧪
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-metrics/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Example Flower App with Custom Metrics
tags: [basic, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [tensorflow | https://www.tensorflow.org/]
dataset: [CIFAR-10]
framework: [tensorflow]
---

# Flower Example using Custom Metrics
Expand Down
7 changes: 3 additions & 4 deletions examples/custom-mods/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Example Flower App with Custom Mods
tags: [mods, monitoring, app]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [wandb | https://wandb.ai/home, tensorboard | https://www.tensorflow.org/tensorboard]
dataset: [CIFAR-10]
framework: [wandb, tensorboard]
---

# Using custom mods 🧪
Expand Down Expand Up @@ -214,7 +213,7 @@ app = fl.client.ClientApp(
client_fn=client_fn,
mods=[
get_wandb_mod("Custom mods example"),
],
],
)
```

Expand Down
7 changes: 3 additions & 4 deletions examples/embedded-devices/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Flower Embedded Devices Example
tags: [basic, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10, MNIST | https://huggingface.co/datasets/ylecun/mnist]
framework: [torch | https://pytorch.org/, tensorflow | https://www.tensorflow.org/]
dataset: [CIFAR-10, MNIST]
framework: [torch, tensorflow]
---

# Federated Learning on Embedded Devices with Flower
Expand Down Expand Up @@ -187,7 +186,7 @@ If you are working on this tutorial on your laptop or desktop, it can host the F

## Running Embedded FL with Flower

For this demo, we'll be using [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10](https://www.cs.toronto.edu/~kriz/cifar.html), a popular dataset for image classification comprised of 10 classes (e.g. car, bird, airplane) and a total of 60K `32x32` RGB images. The training set contains 50K images. The server will automatically download the dataset should it not be found in `./data`. The clients do the same. The dataset is by default split into 50 partitions (each to be assigned to a different client). This can be controlled with the `NUM_CLIENTS` global variable in the client scripts. In this example, each device will play the role of a specific user (specified via `--cid` -- we'll show this later) and therefore only do local training with that portion of the data. For CIFAR-10, clients will be training a MobileNet-v2/3 model.
For this demo, we'll be using [CIFAR-10](https://www.cs.toronto.edu/~kriz/cifar.html), a popular dataset for image classification comprised of 10 classes (e.g. car, bird, airplane) and a total of 60K `32x32` RGB images. The training set contains 50K images. The server will automatically download the dataset should it not be found in `./data`. The clients do the same. The dataset is by default split into 50 partitions (each to be assigned to a different client). This can be controlled with the `NUM_CLIENTS` global variable in the client scripts. In this example, each device will play the role of a specific user (specified via `--cid` -- we'll show this later) and therefore only do local training with that portion of the data. For CIFAR-10, clients will be training a MobileNet-v2/3 model.

You can run this example using MNIST and a smaller CNN model by passing flag `--mnist`. This is useful if you are using devices with a very limited amount of memory (e.g. RaspberryPi Zero) or if you want the training taking place on the embedded devices to be much faster (specially if these are CPU-only). The partitioning of the dataset is done in the same way.

Expand Down
6 changes: 2 additions & 4 deletions examples/federated-kaplan-meier-fitter/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
title: Flower Example using KaplanMeierFitter
tags: [estimator, medical]
dataset: [Waltons |
https://lifelines.readthedocs.io/en/latest/lifelines.datasets.html#lifelines.datasets.load_waltons]
framework: [lifelines | https://lifelines.readthedocs.io/en/latest/index.html]
dataset: [Waltons]
framework: [lifelines]
---

# Flower Example using KaplanMeierFitter
Expand Down
5 changes: 2 additions & 3 deletions examples/fl-dp-sa/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Example of Flower App with DP and SA
tags: [basic, vision, fds]
dataset: [MNIST | https://huggingface.co/datasets/ylecun/mnist]
framework: [torch | https://pytorch.org/, torchvision | https://pytorch.org/vision/stable/index.html]
dataset: [MNIST]
framework: [torch, torchvision]
---

# Example of Flower App with DP and SA
Expand Down
5 changes: 2 additions & 3 deletions examples/fl-tabular/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Flower Example on Adult Census Income Tabular Dataset
tags: [basic, tabular, fds]
dataset: [Adult Census Income | https://www.kaggle.com/datasets/uciml/adult-census-income/data]
framework: [scikit-learn | https://scikit-learn.org/, torch | https://pytorch.org/]
dataset: [Adult Census Income]
framework: [scikit-learn, torch]
---

# Flower Example on Adult Census Income Tabular Dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/flower-authentication/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Flower Example with Authentication
tags: [advanced, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [torch | https://pytorch.org/, torchvision | https://pytorch.org/vision/stable/index.html]
dataset: [CIFAR-10]
framework: [torch, torchvision]
---

# Flower Authentication with PyTorch 🧪
Expand Down
5 changes: 2 additions & 3 deletions examples/flower-in-30-minutes/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: 30-minute tutorial running Flower simulation with PyTorch
tags: [colab, vision, simulation]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [torch | https://pytorch.org/]
dataset: [CIFAR-10]
framework: [torch]
---

# 30-minute tutorial running Flower simulation with PyTorch
Expand Down
5 changes: 2 additions & 3 deletions examples/flower-simulation-step-by-step-pytorch/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Flower Simulation Step-by-Step
tags: [basic, vision, simulation]
dataset: [MNIST | https://huggingface.co/datasets/ylecun/mnist]
framework: [torch | https://pytorch.org/]
dataset: [MNIST]
framework: [torch]
---

# Flower Simulation Step-by-Step
Expand Down
4 changes: 2 additions & 2 deletions examples/flower-via-docker-compose/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Leveraging Flower and Docker for Device Heterogeneity Management in FL
tags: [deployment, vision, tutorial]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [Docker | https://www.docker.com/, tensorflow | https://www.tensorflow.org/]
dataset: [CIFAR-10]
framework: [Docker, tensorflow]
---

# Leveraging Flower and Docker for Device Heterogeneity Management in Federated Learning
Expand Down
7 changes: 3 additions & 4 deletions examples/ios/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Simple Flower Example on iOS
tags: [mobile, vision, fds]
dataset: [MNIST | https://huggingface.co/datasets/ylecun/mnist]
framework: [Swift | https://www.swift.org/]
tags: [mobile, vision, sdk]
dataset: [MNIST]
framework: [Swift]
---

# FLiOS - A Flower SDK for iOS Devices with Example
Expand Down
4 changes: 2 additions & 2 deletions examples/llm-flowertune/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Federated LLM Fine-tuning with Flower
tags: [llm, nlp, LLama2]
dataset: [Alpaca-GPT4 | https://huggingface.co/datasets/vicgalle/alpaca-gpt4]
framework: [PEFT | https://huggingface.co/docs/peft/index, torch | https://pytorch.org/]
dataset: [Alpaca-GPT4]
framework: [PEFT, torch]
---

# LLM FlowerTune: Federated LLM Fine-tuning with Flower
Expand Down
5 changes: 2 additions & 3 deletions examples/opacus/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Sample-Level Differential Privacy using Opacus
tags: [dp, security, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [opacus | https://opacus.ai/, torch | https://pytorch.org/]
dataset: [CIFAR-10]
framework: [opacus, torch]
---

# Training with Sample-Level Differential Privacy using Opacus Privacy Engine
Expand Down
5 changes: 2 additions & 3 deletions examples/pytorch-federated-variational-autoencoder/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Federated Variational Autoencoder using Pytorch
tags: [basic, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [torch | https://pytorch.org/, torchvision | https://pytorch.org/vision/stable/index.html]
dataset: [CIFAR-10]
framework: [torch, torchvision]
---

# Flower Example for Federated Variational Autoencoder using Pytorch
Expand Down
5 changes: 2 additions & 3 deletions examples/pytorch-from-centralized-to-federated/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: PyTorch, From Centralized To Federated
tags: [basic, vision, fds]
dataset: [CIFAR-10 | https://huggingface.co/datasets/uoft-cs/cifar10]
framework: [torch | https://pytorch.org/]
dataset: [CIFAR-10]
framework: [torch]
---

# PyTorch: From Centralized To Federated
Expand Down
3 changes: 1 addition & 2 deletions examples/quickstart-cpp/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Simple Flower Example using C++
tags: [quickstart, linear regression, tabular]
dataset: [Synthetic]
framework: [C++ | https://isocpp.org/]
framework: [C++]
---

# Flower Clients in C++ (under development)
Expand Down
5 changes: 2 additions & 3 deletions examples/quickstart-fastai/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Simple Flower Example using fastai
tags: [quickstart, vision]
dataset: [MNIST | https://huggingface.co/datasets/ylecun/mnist]
framework: [fastai | https://fast.ai]
dataset: [MNIST]
framework: [fastai]
---

# Flower Example using fastai
Expand Down
5 changes: 2 additions & 3 deletions examples/quickstart-huggingface/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Flower Transformers Example using HuggingFace
tags: [quickstart, llm, nlp, sentiment]
dataset: [IMDB | https://huggingface.co/datasets/stanfordnlp/imdb]
framework: [transformers | https://huggingface.co/docs/transformers/index]
dataset: [IMDB]
framework: [transformers]
---

# Federated HuggingFace Transformers using Flower and PyTorch
Expand Down
3 changes: 1 addition & 2 deletions examples/quickstart-jax/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Simple Flower Example using Jax
tags: [quickstart, linear regression]
dataset: [Synthetic]
framework: [JAX | https://jax.readthedocs.io/en/latest/]
framework: [JAX]
---

# JAX: From Centralized To Federated
Expand Down
Loading

0 comments on commit 049d929

Please sign in to comment.