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

ci(*:skip) Update e2e tests directory structure #3981

Merged
merged 54 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8fb2462
Rename e2e scripts and change to flower-supernode
danielnugraha Jul 8, 2024
67481b1
Rename e2e scripts and change to flower-supernode
danielnugraha Jul 8, 2024
9364932
Merge branch 'main' into update-e2e-tests-next
danielnugraha Jul 8, 2024
1aee92b
Merge remote-tracking branch 'origin' into update-e2e-tests-next
danielnugraha Aug 8, 2024
9d9e149
Move e2e components to subpackages
danielnugraha Aug 9, 2024
92fea75
Add EOF
danielnugraha Aug 9, 2024
a190e5d
Merge from main
danielnugraha Aug 9, 2024
9a89d11
Fix imports
danielnugraha Aug 9, 2024
289e067
Use supernode in reconnection e2e tests
danielnugraha Aug 9, 2024
428e4cf
Make legacy test work
danielnugraha Aug 12, 2024
ea658ec
Format
danielnugraha Aug 12, 2024
310314b
Update toml files
danielnugraha Aug 12, 2024
191996e
Merge branch 'main' into update-e2e-tests-next
danielnugraha Aug 12, 2024
ce49357
Format
danielnugraha Aug 12, 2024
03ce1c3
Merge remote-tracking branch 'refs/remotes/origin/update-e2e-tests-ne…
danielnugraha Aug 12, 2024
f07c967
Format
danielnugraha Aug 12, 2024
7307c55
Fix bare https
danielnugraha Aug 12, 2024
e8e6c71
Fix pandas
danielnugraha Aug 12, 2024
2f247f3
Fix pandas
danielnugraha Aug 12, 2024
3a945fd
Fix pandas
danielnugraha Aug 12, 2024
5b8a67d
Change subdir names
danielnugraha Aug 13, 2024
e852fbc
Change init name
danielnugraha Aug 13, 2024
aa1ca0b
Merge branch 'main' into update-e2e-tests-next
danielnugraha Aug 13, 2024
43d0573
Change subdir names
danielnugraha Aug 13, 2024
12b0bb1
Merge remote-tracking branch 'refs/remotes/origin/update-e2e-tests-ne…
danielnugraha Aug 13, 2024
8c41819
Format
danielnugraha Aug 13, 2024
6f97d38
Merge remote-tracking branch 'origin' into update-e2e-tests-next
danielnugraha Aug 13, 2024
7a40e75
Merge branch 'reconnection-use-supernode' into update-e2e-tests-next
danielnugraha Aug 13, 2024
0af690a
Fix reconnection
danielnugraha Aug 13, 2024
4bad6c9
Format
danielnugraha Aug 13, 2024
e1f1499
Format
danielnugraha Aug 13, 2024
cf7a958
Format
danielnugraha Aug 13, 2024
6762437
Format
danielnugraha Aug 13, 2024
55348e1
Format
danielnugraha Aug 13, 2024
a60638a
Merge branch 'main' into update-e2e-tests-next
danielnugraha Aug 13, 2024
bbc019d
Format
danielnugraha Aug 13, 2024
7779af5
Merge remote-tracking branch 'refs/remotes/origin/update-e2e-tests-ne…
danielnugraha Aug 13, 2024
e36d0bd
Format
danielnugraha Aug 13, 2024
dc5bfc2
Merge branch 'main' into update-e2e-tests-next
danielnugraha Aug 13, 2024
0edb1ea
Format
danielnugraha Aug 13, 2024
8a7a155
Merge remote-tracking branch 'refs/remotes/origin/update-e2e-tests-ne…
danielnugraha Aug 13, 2024
3053e14
Format
danielnugraha Aug 13, 2024
a8f712f
Format
danielnugraha Aug 13, 2024
ac7b21a
Change naming
danielnugraha Aug 16, 2024
c76e3ca
Change naming
danielnugraha Aug 16, 2024
e868145
Merge branch 'main' into update-e2e-tests-next
danielnugraha Aug 16, 2024
1e6cd6c
Change naming
danielnugraha Aug 16, 2024
931dd58
Merge remote-tracking branch 'refs/remotes/origin/update-e2e-tests-ne…
danielnugraha Aug 16, 2024
24c7f4f
Delete global server app
danielnugraha Aug 16, 2024
955328c
Merge branch 'main' into update-e2e-tests-next
danielnugraha Aug 16, 2024
ca15617
Merge branch 'main' into update-e2e-tests-next
danieljanes Aug 16, 2024
dfa6585
Merge branch 'main' into update-e2e-tests-next
flwrmachine Aug 16, 2024
62c9fb8
Merge branch 'main' into update-e2e-tests-next
flwrmachine Aug 16, 2024
3b4abff
Merge branch 'main' into update-e2e-tests-next
flwrmachine Aug 16, 2024
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
32 changes: 23 additions & 9 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,44 +61,55 @@ jobs:
matrix:
include:
- directory: bare
subdir: baree2e

- directory: bare-https
subdir: httpse2e

- directory: bare-client-auth
subdir: clientauthe2e

- directory: framework-jax
- directory: jax
subdir: jaxe2e

- directory: framework-pytorch
- directory: pytorch
subdir: pytorche2e
dataset: |
from torchvision.datasets import CIFAR10
CIFAR10('./data', download=True)

- directory: framework-tensorflow
- directory: tensorflow
subdir: tfe2e
dataset: |
import tensorflow as tf
tf.keras.datasets.cifar10.load_data()

- directory: framework-opacus
- directory: opacus
subdir: opacuse2e
dataset: |
from torchvision.datasets import CIFAR10
CIFAR10('./data', download=True)

- directory: framework-pytorch-lightning
- directory: pytorch-lightning
subdir: lightninge2e
dataset: |
from torchvision.datasets import MNIST
MNIST('./data', download=True)

- directory: framework-scikit-learn
- directory: scikit-learn
subdir: scikite2e
dataset: |
import openml
openml.datasets.get_dataset(554)

- directory: framework-fastai
- directory: fastai
subdir: fastaie2e
dataset: |
from fastai.vision.all import untar_data, URLs
untar_data(URLs.MNIST)

- directory: framework-pandas
- directory: pandas
subdir: pandase2e
dataset: |
from pathlib import Path
from sklearn.datasets import load_iris
Expand Down Expand Up @@ -135,12 +146,15 @@ jobs:
if: ${{ github.repository == 'adap/flower' && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
run: |
python -m pip install https://${{ env.ARTIFACT_BUCKET }}/py/${{ needs.wheel.outputs.dir }}/${{ needs.wheel.outputs.short_sha }}/${{ needs.wheel.outputs.whl_path }}
- name: Install subdir components
run: pip install .
- name: Download dataset
if: ${{ matrix.dataset }}
run: python -c "${{ matrix.dataset }}"
- name: Run edge client test
if: ${{ matrix.directory != 'bare-client-auth' }}
run: ./../test_legacy.sh "${{ matrix.directory }}"
working-directory: e2e/${{ matrix.directory }}/${{ matrix.subdir }}
run: ./../../test_legacy.sh "${{ matrix.directory }}"
- name: Run virtual client test
if: ${{ matrix.directory != 'bare-client-auth' }}
run: python simulation.py
Expand Down
1 change: 1 addition & 0 deletions e2e/bare-client-auth/clientauthe2e/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""clientatuthe2e."""
File renamed without changes.
4 changes: 2 additions & 2 deletions e2e/bare-client-auth/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ allow-direct-references = true
publisher = "flwrlabs"

[tool.flwr.app.components]
serverapp = ""
clientapp = "client:app"
serverapp = "clientauthe2e.server_app:app"
clientapp = "clientauthe2e.client_app:app"

[tool.flwr.app.config]

Expand Down
1 change: 1 addition & 0 deletions e2e/bare-https/httpse2e/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""httpse2e."""
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ def client_fn(context: Context):
start_client(
server_address="127.0.0.1:8080",
client=FlowerClient().to_client(),
root_certificates=Path("certificates/ca.crt").read_bytes(),
root_certificates=Path("../certificates/ca.crt").read_bytes(),
insecure=False,
)
43 changes: 43 additions & 0 deletions e2e/bare-https/httpse2e/server_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from pathlib import Path

import flwr as fl

app = fl.server.ServerApp()


@app.main()
def main(driver, context):
# Construct the LegacyContext
context = fl.server.LegacyContext(
context=context,
config=fl.server.ServerConfig(num_rounds=3),
)

# Create the workflow
workflow = fl.server.workflow.DefaultWorkflow()

# Execute
workflow(driver, context)

hist = context.history
assert (
hist.losses_distributed[-1][1] == 0
or (hist.losses_distributed[0][1] / hist.losses_distributed[-1][1]) >= 0.98
)


if __name__ == "__main__":
hist = fl.server.start_server(
server_address="127.0.0.1:8080",
config=fl.server.ServerConfig(num_rounds=3),
certificates=(
Path("../certificates/ca.crt").read_bytes(),
Path("../certificates/server.pem").read_bytes(),
Path("../certificates/server.key").read_bytes(),
),
)

assert (
hist.losses_distributed[-1][1] == 0
or (hist.losses_distributed[0][1] / hist.losses_distributed[-1][1]) >= 0.98
)
4 changes: 2 additions & 2 deletions e2e/bare-https/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ allow-direct-references = true
publisher = "flwrlabs"

[tool.flwr.app.components]
serverapp = "server:app"
clientapp = "client:app"
serverapp = "httpse2e.server_app:app"
clientapp = "httpse2e.client_app:app"

[tool.flwr.app.config]

Expand Down
1 change: 1 addition & 0 deletions e2e/bare/baree2e/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""baree2e."""
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions e2e/bare/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ allow-direct-references = true
publisher = "flwrlabs"

[tool.flwr.app.components]
serverapp = ""
clientapp = "client:app"
serverapp = "baree2e.server_app:app"
clientapp = "baree2e.client_app:app"

[tool.flwr.app.config]

Expand Down
2 changes: 1 addition & 1 deletion e2e/bare/simulation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List, Tuple

import numpy as np
from client import client_fn
from baree2e.client_app import client_fn

import flwr as fl
from flwr.common import Metrics
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions e2e/fastai/fastaie2e/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""fastaie2e."""
File renamed without changes.
79 changes: 79 additions & 0 deletions e2e/fastai/fastaie2e/server_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import numpy as np

import flwr as fl

STATE_VAR = "timestamp"


# Define metric aggregation function
def record_state_metrics(metrics):
"""Ensure that timestamps are monotonically increasing."""
if not metrics:
return {}

if STATE_VAR not in metrics[0][1]:
# Do nothing if keyword is not present
return {}

states = []
for _, m in metrics:
# split string and covert timestamps to float
states.append([float(tt) for tt in m[STATE_VAR].split(",")])

for client_state in states:
if len(client_state) == 1:
continue
deltas = np.diff(client_state)
assert np.all(
deltas > 0
), f"Timestamps are not monotonically increasing: {client_state}"

return {STATE_VAR: states}


app = fl.server.ServerApp()


@app.main()
def main(driver, context):
# Construct the LegacyContext
context = fl.server.LegacyContext(
context=context,
config=fl.server.ServerConfig(num_rounds=3),
)

# Create the workflow
workflow = fl.server.workflow.DefaultWorkflow()

# Execute
workflow(driver, context)

hist = context.history
assert (
hist.losses_distributed[-1][1] == 0
or (hist.losses_distributed[0][1] / hist.losses_distributed[-1][1]) >= 0.98
)


if __name__ == "__main__":
strategy = fl.server.strategy.FedAvg(
evaluate_metrics_aggregation_fn=record_state_metrics
)

hist = fl.server.start_server(
server_address="0.0.0.0:8080",
config=fl.server.ServerConfig(num_rounds=3),
strategy=strategy,
)

assert (
hist.losses_distributed[-1][1] == 0
or (hist.losses_distributed[0][1] / hist.losses_distributed[-1][1]) >= 0.98
)

if STATE_VAR in hist.metrics_distributed:
# The checks in record_state_metrics don't do anythinng if client's state has a single entry
state_metrics_last_round = hist.metrics_distributed[STATE_VAR][-1]
assert (
len(state_metrics_last_round[1][0]) == 2 * state_metrics_last_round[0]
), "There should be twice as many entries in the client state as rounds"
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ allow-direct-references = true
publisher = "flwrlabs"

[tool.flwr.app.components]
serverapp = ""
clientapp = "client:app"
serverapp = "fastaie2e.server_app:app"
clientapp = "fastaie2e.client_app:app"

[tool.flwr.app.config]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from client import client_fn
from fastaie2e.client_app import client_fn

import flwr as fl

Expand Down
14 changes: 0 additions & 14 deletions e2e/framework-scikit-learn/simulation.py

This file was deleted.

14 changes: 0 additions & 14 deletions e2e/framework-tensorflow/simulation.py

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions e2e/jax/jaxe2e/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""jaxe2e."""
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from typing import Dict, List, Tuple

import jax
import jax_training
import numpy as np
from jaxe2e import jax_training

from flwr.client import ClientApp, NumPyClient, start_client
from flwr.common import Context
Expand Down
File renamed without changes.
Loading
Loading