From 2f6e149673d5f67f38289f8b8c0881b6525bffbf Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Tue, 2 May 2023 10:53:54 +0000 Subject: [PATCH 1/8] fix client config grpc --- fedn/fedn/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fedn/fedn/client.py b/fedn/fedn/client.py index 37ba07be7..e4e66410c 100644 --- a/fedn/fedn/client.py +++ b/fedn/fedn/client.py @@ -250,7 +250,7 @@ def _connect(self, client_config): host = client_config['fqdn'] # assuming https if fqdn is used port = 443 - print(f"CLIENT: Connecting to combiner host: {host}", flush=True) + print(f"CLIENT: Connecting to combiner host: {host}:{port}", flush=True) if client_config['certificate']: print("CLIENT: using certificate from Reducer for GRPC channel") @@ -274,6 +274,8 @@ def _connect(self, client_config): channel = grpc.secure_channel("{}:{}".format(host, str(port)), credentials) else: print("CLIENT: using insecure GRPC channel") + if port == 443: + port = 80 channel = grpc.insecure_channel("{}:{}".format( host, str(port))) From 130e8fafb1e90327945c7b68fdfb881d8100530e Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Tue, 2 May 2023 12:03:06 +0000 Subject: [PATCH 2/8] metadata for token --- fedn/fedn/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fedn/fedn/client.py b/fedn/fedn/client.py index e4e66410c..69c7fe72c 100644 --- a/fedn/fedn/client.py +++ b/fedn/fedn/client.py @@ -271,7 +271,12 @@ def _connect(self, client_config): cert = ssl.get_server_certificate((host, port)) credentials = grpc.ssl_channel_credentials(cert.encode('utf-8')) - channel = grpc.secure_channel("{}:{}".format(host, str(port)), credentials) + if self.config['token']: + token = self.config['token'] + auth_creds = grpc.metadata_call_credentials(lambda _, callback: callback([('authorization', f'Token {token}')])) + channel = grpc.secure_channel("{}:{}".format(host, str(port)), grpc.composite_channel_credentials(credentials, auth_creds)) + else: + channel = grpc.secure_channel("{}:{}".format(host, str(port)), credentials) else: print("CLIENT: using insecure GRPC channel") if port == 443: From aa4eb396a865d3290ae236faa093ed9d4808a83f Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Tue, 2 May 2023 16:10:34 +0000 Subject: [PATCH 3/8] upgrade grpcio --- fedn/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedn/setup.py b/fedn/setup.py index abf779106..85f106297 100644 --- a/fedn/setup.py +++ b/fedn/setup.py @@ -17,7 +17,7 @@ "urllib3>=1.26.4", "minio", "python-slugify", - "grpcio~=1.47.0", + "grpcio~=1.54.0", "grpcio-tools", "numpy>=1.21.6,<=1.22.2", "protobuf", From 3615a0f529a994b429c04ecd1f48c3ff437aa1ed Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Tue, 2 May 2023 16:11:02 +0000 Subject: [PATCH 4/8] metadata custom header --- fedn/fedn/client.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fedn/fedn/client.py b/fedn/fedn/client.py index 69c7fe72c..f1abfc3db 100644 --- a/fedn/fedn/client.py +++ b/fedn/fedn/client.py @@ -32,6 +32,14 @@ VALID_NAME_REGEX = '^[a-zA-Z0-9_-]*$' +class GrpcAuth(grpc.AuthMetadataPlugin): + def __init__(self, key): + self._key = key + + def __call__(self, context, callback): + callback((('authorization', f'Token {self._key}'),), None) + + class Client: """FEDn Client. Service running on client/datanodes in a federation, recieving and handling model update and model validation requests. @@ -273,7 +281,7 @@ def _connect(self, client_config): credentials = grpc.ssl_channel_credentials(cert.encode('utf-8')) if self.config['token']: token = self.config['token'] - auth_creds = grpc.metadata_call_credentials(lambda _, callback: callback([('authorization', f'Token {token}')])) + auth_creds = grpc.metadata_call_credentials(GrpcAuth(token)) channel = grpc.secure_channel("{}:{}".format(host, str(port)), grpc.composite_channel_credentials(credentials, auth_creds)) else: channel = grpc.secure_channel("{}:{}".format(host, str(port)), credentials) From 9e83ab77448ccd242448d48618638f4de0c44409 Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Thu, 4 May 2023 12:08:20 +0000 Subject: [PATCH 5/8] update verison of checkout and login actions --- .github/workflows/build-containers.yaml | 12 ++++++------ .github/workflows/code-checks.yaml | 2 +- .github/workflows/integration-tests.yaml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-containers.yaml b/.github/workflows/build-containers.yaml index 2500ead3b..a24094bdf 100644 --- a/.github/workflows/build-containers.yaml +++ b/.github/workflows/build-containers.yaml @@ -21,7 +21,7 @@ jobs: contents: read steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Docker meta fedn id: meta1 @@ -63,15 +63,15 @@ jobs: type=sha,suffix=-mnist-pytorch - - name: Log in to GitHub Docker Registry - uses: docker/login-action@v1 + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 with: registry: docker.pkg.github.com username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: push: "${{ github.event_name != 'pull_request' }}" tags: ${{ steps.meta1.outputs.tags }} @@ -79,7 +79,7 @@ jobs: file: Dockerfile - name: Build and push (mnist-keras) - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: push: "${{ github.event_name != 'pull_request' }}" tags: ${{ steps.meta2.outputs.tags }} @@ -89,7 +89,7 @@ jobs: REQUIREMENTS=examples/mnist-keras/requirements.txt - name: Build and push (mnist-pytorch) - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: push: "${{ github.event_name != 'pull_request' }}" tags: ${{ steps.meta3.outputs.tags }} diff --git a/.github/workflows/code-checks.yaml b/.github/workflows/code-checks.yaml index 311af03fa..c1ec38548 100644 --- a/.github/workflows/code-checks.yaml +++ b/.github/workflows/code-checks.yaml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: init venv run: .devcontainer/bin/init_venv.sh diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 2bf711af3..d5c49a8f0 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -25,7 +25,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - uses: actions/setup-python@v3 with: From ac9daa358e2ed227382f7fb4ad5306485168dc45 Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Thu, 4 May 2023 12:12:49 +0000 Subject: [PATCH 6/8] update vision vesion to comply with torch 1.13.1 --- examples/mnist-pytorch/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mnist-pytorch/requirements.txt b/examples/mnist-pytorch/requirements.txt index 72e57c0cb..784eee27b 100644 --- a/examples/mnist-pytorch/requirements.txt +++ b/examples/mnist-pytorch/requirements.txt @@ -1,4 +1,4 @@ torch==1.13.1 -torchvision==0.12.0 +torchvision==0.14.0 fire==0.3.1 docker==5.0.2 \ No newline at end of file From 84c16104d5fe80cd057bbec98e2d90c0ae176172 Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Thu, 4 May 2023 12:18:15 +0000 Subject: [PATCH 7/8] bump minor release for vision --- examples/mnist-pytorch/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mnist-pytorch/requirements.txt b/examples/mnist-pytorch/requirements.txt index 784eee27b..381aaa4f3 100644 --- a/examples/mnist-pytorch/requirements.txt +++ b/examples/mnist-pytorch/requirements.txt @@ -1,4 +1,4 @@ torch==1.13.1 -torchvision==0.14.0 +torchvision==0.14.1 fire==0.3.1 docker==5.0.2 \ No newline at end of file From 6fe64a64b2fd18007b48c063bb78137e9f39d408 Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Thu, 4 May 2023 13:52:28 +0000 Subject: [PATCH 8/8] revert grpcio bump --- fedn/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedn/setup.py b/fedn/setup.py index 85f106297..abf779106 100644 --- a/fedn/setup.py +++ b/fedn/setup.py @@ -17,7 +17,7 @@ "urllib3>=1.26.4", "minio", "python-slugify", - "grpcio~=1.54.0", + "grpcio~=1.47.0", "grpcio-tools", "numpy>=1.21.6,<=1.22.2", "protobuf",