Skip to content

Commit

Permalink
fix ci test
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrede committed Apr 2, 2024
1 parent 5e38da0 commit fb58f2f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .ci/tests/examples/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ if [ "$example" == "mnist-keras" ]; then
bin/get_data
bin/split_data
fi
popd

pushd "examples/$example"
>&2 echo "Build compute package and seed"
bin/build.sh
bin/build.sh
popd
24 changes: 14 additions & 10 deletions .ci/tests/examples/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ fi
example="$1"
helper="$2"

python -m venv ".$example"
source ".$example/bin/activate"
pip install ./fedn/ fire

>&2 echo "Start FEDn"
pushd "examples/$example"

Expand All @@ -18,29 +22,29 @@ docker-compose \
up -d --build

>&2 echo "Wait for reducer to start"
".$example/bin/python" ../../.ci/tests/examples/wait_for.py reducer
python ../../.ci/tests/examples/wait_for.py reducer

>&2 echo "Wait for combiners to connect"
".$example/bin/python" ../../.ci/tests/examples/wait_for.py combiners
python ../../.ci/tests/examples/wait_for.py combiners

>&2 echo "Upload compute package"
".$example/bin/python" ../../.ci/tests/examples/api_test.py set_package --path package.tgz --helper "$helper"
python ../../.ci/tests/examples/api_test.py set_package --path package.tgz --helper "$helper"

>&2 echo "Upload seed"
".$example/bin/python" ../../.ci/tests/examples/api_test.py set_seed --path seed.npz
python ../../.ci/tests/examples/api_test.py set_seed --path seed.npz

>&2 echo "Wait for clients to connect"
".$example/bin/python" ../../.ci/tests/examples/wait_for.py clients
python ../../.ci/tests/examples/wait_for.py clients

>&2 echo "Start session"
".$example/bin/python" ../../.ci/tests/examples/api_test.py start_session --rounds 3 --helper "$helper"
python ../../.ci/tests/examples/api_test.py start_session --rounds 3 --helper "$helper"

>&2 echo "Checking rounds success"
".$example/bin/python" ../../.ci/tests/examples/wait_for.py rounds
python ../../.ci/tests/examples/wait_for.py rounds

>&2 echo "Test client connection with dowloaded settings"
# Get config
".$example/bin/python" ../../.ci/tests/examples/api_test.py get_client_config --output ../../client.yaml
python ../../.ci/tests/examples/api_test.py get_client_config --output ../../client.yaml

# Redeploy clients with config
docker-compose \
Expand All @@ -50,10 +54,10 @@ docker-compose \
up -d

>&2 echo "Wait for clients to reconnect"
".$example/bin/python" ../../.ci/tests/examples/wait_for.py clients
python ../../.ci/tests/examples/wait_for.py clients

>&2 echo "Test API GET requests"
".$example/bin/python" ../../.ci/tests/examples/api_test.py test_api_get_methods
python ../../.ci/tests/examples/api_test.py test_api_get_methods

popd
>&2 echo "Test completed successfully"
3 changes: 0 additions & 3 deletions examples/mnist-pytorch/bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
set -e

# Init seed
client/entrypoint init_seed

# Make compute package
tar -czvf package.tgz client
3 changes: 3 additions & 0 deletions examples/mnist-pytorch/client/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import torch
import torchvision
from model import init_seed

dir_path = os.path.dirname(os.path.realpath(__file__))
abs_path = os.path.abspath(dir_path)
Expand Down Expand Up @@ -95,3 +96,5 @@ def split(out_dir='data', n_splits=2):
if not os.path.exists(abs_path+'/data/clients/1'):
get_data()
split()
if not os.path.exists(abs_path+'/data/models'):
init_seed(abs_path+'data/models/seed.npz')
1 change: 1 addition & 0 deletions examples/mnist-pytorch/client/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import collections

import torch

from fedn.utils.helpers.helpers import get_helper

HELPER_MODULE = 'numpyhelper'
Expand Down
3 changes: 2 additions & 1 deletion examples/mnist-pytorch/client/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import torch
from data import load_data
from fedn.utils.helpers.helpers import save_metrics
from model import load_parameters

from fedn.utils.helpers.helpers import save_metrics

dir_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.abspath(dir_path))

Expand Down
4 changes: 0 additions & 4 deletions examples/mnist-pytorch/requirements.txt

This file was deleted.

0 comments on commit fb58f2f

Please sign in to comment.