Skip to content

Commit

Permalink
Merge branch 'main' into add-fds-e2e-tests-to-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tanertopal authored Dec 20, 2023
2 parents b8004b0 + 216fdac commit 19c4502
Show file tree
Hide file tree
Showing 469 changed files with 37,953 additions and 3,255 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
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@

# Flower Baselines
/baselines @jafermarq @tanertopal @danieljanes

# Flower Examples
/examples @jafermarq @tanertopal @danieljanes

# Changelog
/doc/source/ref-changelog.md @jafermarq @tanertopal @danieljanes
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
144 changes: 144 additions & 0 deletions .github/workflows/_docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Reusable docker server image build workflow

on:
workflow_call:
inputs:
namespace-repository:
description: "The namespace and repository in the following format `namespace/repository` e.g. (flwr/base)."
required: true
type: string
file-dir:
description: "Path of the directory that contains the Dockerfile."
required: true
type: string
build-args:
description: "List of build-time variables."
required: false
type: string
tags:
description: "List of tags."
required: true
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 }}

permissions:
contents: read

# based on https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
jobs:
build:
name: Build server image
runs-on: ubuntu-22.04
timeout-minutes: 60
outputs:
build-id: ${{ steps.build-id.outputs.id }}
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:
- name: Create build id
id: build-id
shell: python
run: |
import hashlib
import os
hash = hashlib.sha256('''${{ inputs.build-args }}'''.encode())
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print(f"id={hash.hexdigest()}", file=fh)
- 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: ${{ inputs.namespace-repository }}

- 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: "{{defaultContext}}:${{ inputs.file-dir }}"
build-args: ${{ inputs.build-args }}
outputs: type=image,name=${{ inputs.namespace-repository }},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-${{ steps.build-id.outputs.id }}
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: build
outputs:
metadata: ${{ steps.meta.outputs.json }}
steps:
- name: Download digests
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: digests-${{ needs.build.outputs.build-id }}
path: /tmp/digests

- name: Docker meta
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0
with:
images: ${{ inputs.namespace-repository }}
tags: ${{ inputs.tags }}

- 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 '${{ inputs.namespace-repository }}@sha256:%s ' *)
- name: Inspect image
run: docker buildx imagetools inspect ${{ inputs.namespace-repository }}:${{ 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
60 changes: 60 additions & 0 deletions .github/workflows/docker-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build docker base image

on:
push:
branches: ["main"]
paths:
- "src/docker/base/**"
- ".github/workflows/docker-base.yml"
# re-run if something chnages in the bootstrap action (e.g. version of the dependencies)
- ".github/actions/bootstrap/action.yml"
- ".github/workflows/_docker-build.yml"

permissions:
contents: read

env:
DEFAULT_UBUNTU: 22.04

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 }}
ubuntu-version: ${{ steps.versions.outputs.ubuntu-version }}

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

- uses: ./.github/actions/bootstrap
id: bootstrap

- id: versions
run: |
echo "pip-version=${{ steps.bootstrap.outputs.pip-version }}" >> "$GITHUB_OUTPUT"
echo "setuptools-version=${{ steps.bootstrap.outputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
echo "ubuntu-version=${{ env.DEFAULT_UBUNTU }}" >> "$GITHUB_OUTPUT"
build-base-images:
name: Build images
uses: ./.github/workflows/_docker-build.yml
needs: parameters
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
with:
namespace-repository: flwr/base
file-dir: src/docker/base
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
PIP_VERSION=${{ needs.parameters.outputs.pip-version }}
SETUPTOOLS_VERSION=${{ needs.parameters.outputs.setuptools-version }}
UBUNTU_VERSION=${{ needs.parameters.outputs.ubuntu-version }}
tags: py${{ matrix.python-version }}-ubuntu${{ needs.parameters.outputs.ubuntu-version }}
secrets:
dockerhub-user: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
Loading

0 comments on commit 19c4502

Please sign in to comment.