Skip to content

Commit

Permalink
Merge branch 'main' into flanders
Browse files Browse the repository at this point in the history
  • Loading branch information
edogab33 authored Dec 6, 2023
2 parents 3daa7d6 + 8e9cb56 commit ac609d8
Show file tree
Hide file tree
Showing 143 changed files with 18,731 additions and 485 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhisto
&& echo $SNIPPET >> "/home/$USERNAME/.bashrc"

# Install system dependencies
RUN apt update
RUN apt install -y curl wget gnupg python3 python-is-python3 python3-pip git \
RUN apt-get update
RUN apt-get install -y curl wget gnupg python3 python-is-python3 python3-pip git \
build-essential tmux vim

RUN python -m pip install \
Expand Down
16 changes: 10 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"dockerFile": "Dockerfile",
"postCreateCommand": "poetry install --extras \"simulation\"",
"extensions": ["ms-python.python"],
"settings": {
"files.watcherExclude": {},
"search.exclude": {},
"terminal.integrated.defaultProfile.linux": "bash"
"postCreateCommand": "sudo poetry install --extras \"simulation\"",
"customizations": {
"vscode": {
"settings": {
"files.watcherExclude": { },
"search.exclude": { },
"terminal.integrated.defaultProfile.linux": "bash"
},
"extensions": [ "ms-python.python" ]
}
},
"remoteUser": "flwr-vscode",
"containerEnv": {
Expand Down
32 changes: 11 additions & 21 deletions .github/ISSUE_TEMPLATE/baseline_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,22 @@ body:
- [ ] Read the [`first contribution` doc](https://flower.dev/docs/first-time-contributors.html)
- [ ] Complete the Flower tutorial
- [ ] Read the Flower Baselines docs to get an overview:
- [ ] [https://flower.dev/docs/using-baselines.html](https://flower.dev/docs/using-baselines.html)
- [ ] [https://flower.dev/docs/contributing-baselines.html](https://flower.dev/docs/contributing-baselines.html)
- [ ] [How to use Flower Baselines](https://flower.dev/docs/baselines/how-to-use-baselines.html)
- [ ] [How to contribute a Flower Baseline](https://flower.dev/docs/baselines/how-to-contribute-baselines.html)
- type: checkboxes
attributes:
label: Prepare - understand the scope
options:
- label: Read the paper linked above
- label: Create the directory structure in Flower Baselines (just the `__init__.py` files and a `README.md`)
- label: Before starting to write code, write down all of the specs of this experiment in a README (dataset, partitioning, model, number of clients, all hyperparameters, …)
- label: Open a draft PR
- label: Decide which experiments you'd like to reproduce. The more the better!
- label: Follow the steps outlined in [Add a new Flower Baseline](https://flower.dev/docs/baselines/how-to-contribute-baselines.html#add-a-new-flower-baseline).
- label: You can use as reference [other baselines](https://github.com/adap/flower/tree/main/baselines) that the community merged following those steps.
- type: checkboxes
attributes:
label: Implement - make it work
label: Verify your implementation
options:
- label: Implement some form of dataset loading and partitioning in a separate `dataset.py` (doesn’t have to match the paper exactly)
- label: Implement the model in PyTorch
- label: Write a test that shows that the model has the number of parameters mentioned in the paper
- label: Implement the federated learning setup outlined in the paper, maybe starting with fewer clients
- label: Plot accuracy and loss
- label: Run it and check if the model starts to converge
- type: checkboxes
attributes:
label: Align - make it converge
options:
- label: Implement the exact data partitioning outlined in the paper
- label: Use the exact hyperparameters outlined in the paper
- label: Make it converge to roughly the same accuracy that the paper states
- label: Commit the final hyperparameters and plots
- label: Mark the PR as ready
- label: Follow the steps indicated in the `EXTENDED_README.md` that was created in your baseline directory
- label: Ensure your code reproduces the results for the experiments you chose
- label: Ensure your `README.md` is ready to be run by someone that is no familiar with your code. Are all step-by-step instructions clear?
- label: Ensure running the formatting and typing tests for your baseline runs without errors.
- label: Clone your repo on a new directory, follow the guide on your own `README.md` and verify everything runs.
22 changes: 21 additions & 1 deletion .github/actions/bootstrap/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
python-version:
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax."
default: 3.8
pip-version:
pip-version:
description: "Version of pip to be installed using pip"
default: 23.3.1
setuptools-version:
Expand All @@ -13,6 +13,19 @@ inputs:
poetry-version:
description: "Version of poetry to be installed using pip"
default: 1.5.1
outputs:
python-version:
description: "Version range or exact version of Python or PyPy"
value: ${{ steps.versions.outputs.python-version }}
pip-version:
description: "Installed version of pip"
value: ${{ steps.versions.outputs.pip-version }}
setuptools-version:
description: "Installed version of setuptools"
value: ${{ steps.versions.outputs.setuptools-version }}
poetry-version:
description: "Installed version of poetry"
value: ${{ steps.versions.outputs.poetry-version }}
runs:
using: "composite"
steps:
Expand All @@ -27,3 +40,10 @@ runs:
python -m pip install -U poetry==${{ inputs.poetry-version }}
python -m poetry config virtualenvs.create false
shell: bash
- id: versions
shell: bash
run: |
echo "python-version=$(echo ${{ inputs.python-version }})" >> $GITHUB_OUTPUT
echo "pip-version=$(echo ${{ inputs.pip-version }})" >> $GITHUB_OUTPUT
echo "setuptools-version=$(echo ${{ inputs.setuptools-version }})" >> $GITHUB_OUTPUT
echo "poetry-version=$(echo ${{ inputs.poetry-version }})" >> $GITHUB_OUTPUT
193 changes: 193 additions & 0 deletions .github/workflows/_docker-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: Reusable docker server image build workflow

on:
workflow_call:
inputs:
flwr-version:
description: "Version of Flower."
required: true
type: string
python-version:
description: "Version of Python e.g. (3.11.7 or 3.11). Defaults to 3.11."
required: false
type: string
pip-version:
description: "Version of pip. Defaults to the version defined in actions/bootstrap."
required: false
type: string
setuptools-version:
description: "Version of setuptools. Defaults to the version defined in actions/bootstrap."
required: false
type: string
ubuntu-version:
description: "Version of Ubuntu. Defaults to 22.04."
required: false
type: string
secrets:
dockerhub-user:
required: true
dockerhub-token:
required: true
outputs:
metadata:
description: "Metadata of the docker image."
value: ${{ jobs.build-manifest.outputs.metadata }}

env:
REGISTRY_IMAGE: flwr/server
DEFAULT_PYTHON: 3.11
DEFAULT_UBUNTU: 22.04

permissions:
contents: read

# based on https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
jobs:
parameters:
name: Collect build parameters
runs-on: ubuntu-22.04
timeout-minutes: 10
outputs:
pip-version: ${{ steps.versions.outputs.pip-version }}
setuptools-version: ${{ steps.versions.outputs.setuptools-version }}
python-version: ${{ steps.versions.outputs.python-version }}
ubuntu-version: ${{ steps.versions.outputs.ubuntu-version }}

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: ./.github/actions/bootstrap
if: ${{ !(inputs.pip-version != '' && inputs.setuptools-version != '') }}
id: bootstrap

- id: versions
run: |
if [[ "${{ inputs.pip-version }}" = "" ]]; then
echo "pip-version=${{ steps.bootstrap.outputs.pip-version }}" >> "$GITHUB_OUTPUT"
else
echo "pip-version=${{ inputs.pip-version }}" >> "$GITHUB_OUTPUT"
fi
if [[ "${{ inputs.setuptools-version }}" = "" ]]; then
echo "setuptools-version=${{ steps.bootstrap.outputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
else
echo "setuptools-version=${{ inputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
fi
if [[ "${{ inputs.python-version }}" = "" ]]; then
echo "python-version=${{ env.DEFAULT_PYTHON }}" >> "$GITHUB_OUTPUT"
else
echo "python-version=${{ inputs.python-version }}" >> "$GITHUB_OUTPUT"
fi
if [[ "${{ inputs.ubuntu-version }}" = "" ]]; then
echo "ubuntu-version=${{ env.DEFAULT_UBUNTU }}" >> "$GITHUB_OUTPUT"
else
echo "ubuntu-version=${{ inputs.ubuntu-version }}" >> "$GITHUB_OUTPUT"
fi
build:
name: Build server image
runs-on: ubuntu-22.04
timeout-minutes: 60
needs: parameters
strategy:
fail-fast: true
matrix:
platform: [
# build-push action and qemu use different platform names
# therefore we create a map
{ qemu: "", docker: "linux/amd64" },
{ qemu: "arm64", docker: "linux/arm64" },
]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up QEMU
if: matrix.platform.qemu != ''
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
with:
platforms: ${{ matrix.platform.qemu }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Login to Docker Hub
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.dockerhub-user }}
password: ${{ secrets.dockerhub-token }}

- name: Build and push
id: build
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
platforms: ${{ matrix.platform.docker }}
context: src/docker/server
build-args: |
PYTHON_VERSION=${{ needs.parameters.outputs.python-version }}
PIP_VERSION=${{ needs.parameters.outputs.pip-version }}
SETUPTOOLS_VERSION=${{ needs.parameters.outputs.setuptools-version }}
FLWR_VERSION=${{ inputs.flwr-version }}
UBUNTU_VERSION=${{ needs.parameters.outputs.ubuntu-version }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

build-manifest:
name: Build and push docker manifest for all platforms
runs-on: ubuntu-22.04
timeout-minutes: 10
needs: [parameters, build]
outputs:
metadata: ${{ steps.meta.outputs.json }}
steps:
- name: Download digests
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: digests
path: /tmp/digests

- name: Docker meta
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
${{ inputs.flwr-version }}-py${{ needs.parameters.outputs.python-version }}-ubuntu${{ needs.parameters.outputs.ubuntu-version }}
${{ inputs.flwr-version }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Login to Docker Hub
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.dockerhub-user }}
password: ${{ secrets.dockerhub-token }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
2 changes: 1 addition & 1 deletion .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
working-directory: src/kotlin
name: Release build and publish
if: github.repository == 'adap/flower'
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
build_and_test:
name: Build and test
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/docker-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build docker server image

on:
workflow_dispatch:
inputs:
flwr-version:
description: "Version of Flower e.g. (1.6.0)."
required: true
type: string
python-version:
description: "Version of Python e.g. (3.11.7 or 3.11). Defaults to the version defined in _docker-server.yaml."
required: false
type: string
pip-version:
description: "Version of pip. Defaults to the version defined in _docker-server.yaml."
required: false
type: string
setuptools-version:
description: "Version of setuptools. Defaults to the version defined in _docker-server.yaml."
required: false
type: string
ubuntu-version:
description: "Version of Ubuntu. Defaults to the version defined in _docker-server.yaml."
required: false
type: string

permissions:
contents: read

jobs:
build-server-images:
uses: ./.github/workflows/_docker-server.yml
with:
flwr-version: ${{ github.event.inputs.flwr-version }}
python-version: ${{ github.event.inputs.python-version }}
pip-version: ${{ github.event.inputs.pip-version }}
setuptools-version: ${{ github.event.inputs.setuptools-version }}
ubuntu-version: ${{ github.event.inputs.ubuntu-version }}
secrets:
dockerhub-user: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}

summary:
runs-on: ubuntu-22.04
needs: build-server-images
steps:
- run: |
echo "### Images" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
for IMAGE in $(echo ${{ toJson(needs.build-server-images.outputs.metadata) }} | jq -r '.tags[]' ); do
echo "- $IMAGE" >> $GITHUB_STEP_SUMMARY
done
4 changes: 3 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ jobs:
include:
- directory: bare

- directory: bare-https

- directory: jax

- directory: pytorch
Expand Down Expand Up @@ -135,7 +137,7 @@ jobs:
- name: Run virtual client test
run: python simulation.py
- name: Run driver test
run: ./../test_driver.sh
run: ./../test_driver.sh "${{ matrix.directory }}"

strategies:
runs-on: ubuntu-22.04
Expand Down
Loading

0 comments on commit ac609d8

Please sign in to comment.