Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fds-improve-natural-id-partition…
Browse files Browse the repository at this point in the history
…er' into fds-improve-natural-id-partitioner
  • Loading branch information
adam-narozniak committed Apr 26, 2024
2 parents c031420 + 41138c4 commit eb14e86
Show file tree
Hide file tree
Showing 40 changed files with 1,265 additions and 291 deletions.
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
name: Build docker server image
name: Build docker SuperLink image

on:
workflow_dispatch:
inputs:
flwr-version:
description: "Version of Flower"
description: "Version of Flower."
required: true
type: string
base-image-tag:
description: "The tag of the Flower base image."
required: false
type: string
default: "py3.11-ubuntu22.04"

permissions:
contents: read

jobs:
build-server-images:
build-superlink-images:
name: Build images
uses: ./.github/workflows/_docker-build.yml
# run only on default branch when using it with workflow_dispatch
if: github.ref_name == github.event.repository.default_branch
with:
namespace-repository: flwr/server
file-dir: src/docker/server
namespace-repository: flwr/superlink
file-dir: src/docker/superlink
build-args: |
FLWR_VERSION=${{ github.event.inputs.flwr-version }}
BASE_IMAGE_TAG=${{ github.event.inputs.base-image-tag }}
PYTHON_VERSION=3.11
UBUNTU_VERSION=ubuntu22.04
tags: |
${{ github.event.inputs.flwr-version }}-${{ github.event.inputs.base-image-tag }}
${{ github.event.inputs.flwr-version }}-py3.11-ubuntu22.04
${{ github.event.inputs.flwr-version }}
latest
secrets:
dockerhub-user: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}

summary:
name: Build images
name: Summary
runs-on: ubuntu-22.04
needs: build-server-images
needs: build-superlink-images
timeout-minutes: 10
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
for IMAGE in $(echo ${{ toJson(needs.build-superlink-images.outputs.metadata) }} | jq -r '.tags[]' ); do
echo "- $IMAGE" >> $GITHUB_STEP_SUMMARY
done
44 changes: 42 additions & 2 deletions .github/workflows/release-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,56 @@ env:
FLWR_TELEMETRY_ENABLED: 0

jobs:
release_nightly:
release-nightly:
runs-on: ubuntu-22.04
name: Nightly
name: Relase nightly on PyPI
if: github.repository == 'adap/flower'
outputs:
name: ${{ steps.release.outputs.name }}
version: ${{ steps.release.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Bootstrap
uses: ./.github/actions/bootstrap
- name: Release nightly
id: release
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
./dev/publish-nightly.sh
echo "name=$(poetry version | awk {'print $1'})" >> $GITHUB_OUTPUT
echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT
wait-on-pypi:
runs-on: ubuntu-22.04
timeout-minutes: 5
name: Wait on PyPI
needs: release-nightly
steps:
- uses: actions/checkout@v4
- name: Bootstrap
uses: ./.github/actions/bootstrap
- name: Wait until flwr package is avaiale on PyPI
run: until pip install ${{ needs.release-nightly.outputs.name }}==${{ needs.release-nightly.outputs.version }} --dry-run; do echo "Try again"; sleep 10; done

build-docker-images:
name: Build nightly images
if: github.repository == 'adap/flower'
uses: ./.github/workflows/_docker-build.yml
needs: [release-nightly, wait-on-pypi]
strategy:
fail-fast: false
matrix:
images: [{ repository: "flwr/superlink", file-dir: "src/docker/superlink" }]
with:
namespace-repository: ${{ matrix.images.repository }}
file-dir: ${{ matrix.images.file-dir }}
build-args: |
FLWR_VERSION=${{ needs.release-nightly.outputs.version }}
FLWR_PACKAGE=${{ needs.release-nightly.outputs.name }}
tags: |
${{ needs.release-nightly.outputs.version }}
nightly
secrets:
dockerhub-user: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
6 changes: 3 additions & 3 deletions dev/publish-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
# ==============================================================================

set -e
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../

# This script will build and publish a nightly release of Flower under the condition
# that at least one commit was made in the last 24 hours.
# It will rename the package name in the pyproject.toml to from "flwr" to "flwr-nightly".
# The version name in the pyproject.toml will be appended with "-dev" and the current date.
# The result will be a release on PyPi of the package "flwr-nightly" of version e.g.
# The result will be a release on PyPi of the package "flwr-nightly" of version e.g.
# "0.1.1.dev20200716" as seen at https://pypi.org/project/flwr-nightly/

if [[ $(git log --since="24 hours ago" --pretty=oneline) ]]; then
sed -i -E "s/^name = \"(.+)\"/name = \"\1-nightly\"/" pyproject.toml
sed -i -E "s/^version = \"(.+)\"/version = \"\1-dev$(date '+%Y%m%d')\"/" pyproject.toml
sed -i -E "s/^version = \"(.+)\"/version = \"\1.dev$(date '+%Y%m%d')\"/" pyproject.toml
python -m poetry build
python -m poetry publish -u __token__ -p $PYPI_TOKEN
else
Expand Down
68 changes: 37 additions & 31 deletions doc/source/contributor-how-to-build-docker-images.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
How to build Docker Flower images locally
=========================================

Flower provides pre-made docker images on `Docker Hub <https://hub.docker.com/r/flwr/server/tags>`_
that include all necessary dependencies for running the server. You can also build your own custom
Flower provides pre-made docker images on `Docker Hub <https://hub.docker.com/u/flwr>`_
that include all necessary dependencies for running the SuperLink. You can also build your own custom
docker images from scratch with a different version of Python or Ubuntu if that is what you need.
In this guide, we will explain what images exist and how to build them locally.

Expand All @@ -20,15 +20,15 @@ Before we can start, we need to meet a few prerequisites in our local developmen
:doc:`Run Flower using Docker <how-to-run-flower-using-docker>`
which covers this step in more detail.

Currently, Flower provides two images, a base image and a server image. There will also be a client
image soon. The base image, as the name suggests, contains basic dependencies that both the server
and the client need. This includes system dependencies, Python and Python tools. The server image is
based on the base image, but it additionally installs the Flower server using ``pip``.
Currently, Flower provides two images, a ``base`` image and a ``superlink`` image. The base image,
as the name suggests, contains basic dependencies that the SuperLink needs.
This includes system dependencies, Python and Python tools. The SuperLink image is
based on the base image, but it additionally installs the SuperLink using ``pip``.

The build instructions that assemble the images are located in the respective Dockerfiles. You
can find them in the subdirectories of ``src/docker``.

Both, base and server image are configured via build arguments. Through build arguments, we can make
Both, base and SuperLink image are configured via build arguments. Through build arguments, we can make
our build more flexible. For example, in the base image, we can specify the version of Python to
install using the ``PYTHON_VERSION`` build argument. Some of the build arguments have default
values, others must be specified when building the image. All available build arguments for each
Expand Down Expand Up @@ -76,8 +76,8 @@ The following example creates a base image with Python 3.11.0, pip 23.0.1 and se
The name of image is ``flwr_base`` and the tag ``0.1.0``. Remember that the build arguments as well
as the name and tag can be adapted to your needs. These values serve as examples only.

Building the server image
-------------------------
Building the SuperLink image
----------------------------

.. list-table::
:widths: 25 45 15 15
Expand All @@ -89,47 +89,53 @@ Building the server image
- Example
* - ``BASE_REPOSITORY``
- The repository name of the base image.
- Defaults to ``flwr/server``.
- Defaults to ``flwr/base``.
-
* - ``BASE_IMAGE_TAG``
- The image tag of the base image.
- Defaults to ``py3.11-ubuntu22.04``.
* - ``PYTHON_VERSION``
- The Python version of the base image.
- Defaults to ``py3.11``.
-
* - ``UBUNTU_VERSION``
- The Ubuntu version of the base image.
- Defaults to ``ubuntu22.04``.
-
* - ``FLWR_PACKAGE``
- The PyPI package to install.
- Defaults to ``flwr``.
-
* - ``FLWR_VERSION``
- Version of Flower to be installed.
- Yes
- ``1.7.0``
- ``1.8.0``

The following example creates a server image with the official Flower base image py3.11-ubuntu22.04
and Flower 1.7.0:

The following example creates a SuperLink image with the official Flower base image
py3.11-ubuntu22.04 and Flower 1.8.0:

.. code-block:: bash
$ cd src/docker/server/
$ cd src/docker/superlink/
$ docker build \
--build-arg BASE_IMAGE_TAG=py3.11-ubuntu22.04 \
--build-arg FLWR_VERSION=1.7.0 \
-t flwr_server:0.1.0 .
--build-arg FLWR_VERSION=1.8.0 \
-t flwr_superlink:0.1.0 .
The name of image is ``flwr_server`` and the tag ``0.1.0``. Remember that the build arguments as well
as the name and tag can be adapted to your needs. These values serve as examples only.
The name of image is ``flwr_superlink`` and the tag ``0.1.0``. Remember that the build arguments as
well as the name and tag can be adapted to your needs. These values serve as examples only.

If you want to use your own base image instead of the official Flower base image, all you need to do
is set the ``BASE_REPOSITORY`` and ``BASE_IMAGE_TAG`` build arguments. The value of
``BASE_REPOSITORY`` must match the name of your image and the value of ``BASE_IMAGE_TAG`` must match
the tag of your image.

is set the ``BASE_REPOSITORY``, ``PYTHON_VERSION`` and ``UBUNTU_VERSION`` build arguments.
.. code-block:: bash
$ cd src/docker/server/
$ cd src/docker/superlink/
$ docker build \
--build-arg BASE_REPOSITORY=flwr_base \
--build-arg BASE_IMAGE_TAG=0.1.0 \
--build-arg FLWR_VERSION=1.7.0 \
-t flwr_server:0.1.0 .
--build-arg PYTHON_VERSION=3.11 \
--build-arg UBUNTU_VERSION=ubuntu22.04 \
--build-arg FLWR_VERSION=1.8.0 \
-t flwr_superlink:0.1.0 .
After creating the image, we can test whether the image is working:

.. code-block:: bash
$ docker run --rm flwr_server:0.1.0 --help
$ docker run --rm flwr_superlink:0.1.0 --help
Loading

0 comments on commit eb14e86

Please sign in to comment.