From d0a5c02233f704aec08adbd622ae8fd9ed3671c3 Mon Sep 17 00:00:00 2001 From: Fredrik Wrede Date: Thu, 11 Jul 2024 18:06:28 +0200 Subject: [PATCH] Bug/SK-938 | Fix KeyError for client_id (#656) --- .github/workflows/build-containers.yaml | 1 + .github/workflows/push-to-pypi.yaml | 3 ++- docs/conf.py | 2 +- fedn/network/storage/statestore/mongostatestore.py | 8 +++++++- pyproject.toml | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-containers.yaml b/.github/workflows/build-containers.yaml index 8dd2f561a..89648764e 100644 --- a/.github/workflows/build-containers.yaml +++ b/.github/workflows/build-containers.yaml @@ -1,6 +1,7 @@ name: "build containers" on: + workflow_dispatch: push: branches: - master diff --git a/.github/workflows/push-to-pypi.yaml b/.github/workflows/push-to-pypi.yaml index 1b59835ad..1e184c17f 100644 --- a/.github/workflows/push-to-pypi.yaml +++ b/.github/workflows/push-to-pypi.yaml @@ -1,8 +1,9 @@ name: Publish Python distribution to PyPI on: + workflow_dispatch: release: - types: [created] + types: published jobs: build-and-publish: diff --git a/docs/conf.py b/docs/conf.py index bebc3a80e..c45e90846 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,7 @@ author = "Scaleout Systems AB" # The full version, including alpha/beta/rc tags -release = "0.11.0" +release = "0.11.1" # Add any Sphinx extension module names here, as strings extensions = [ diff --git a/fedn/network/storage/statestore/mongostatestore.py b/fedn/network/storage/statestore/mongostatestore.py index 7262e5554..7ef22a795 100644 --- a/fedn/network/storage/statestore/mongostatestore.py +++ b/fedn/network/storage/statestore/mongostatestore.py @@ -738,7 +738,13 @@ def set_client(self, client_data): :return: """ client_data["updated_at"] = str(datetime.now()) - self.clients.update_one({"client_id": client_data["client_id"]}, {"$set": client_data}, True) + try: + self.clients.update_one({"client_id": client_data["client_id"]}, {"$set": client_data}, True) + except KeyError: + # If client_id is not present, use name as identifier, for backwards compatibility + id = str(uuid.uuid4()) + client_data["client_id"] = id + self.clients.update_one({"name": client_data["name"]}, {"$set": client_data}, True) def get_client(self, client_id): """Get client by client_id. diff --git a/pyproject.toml b/pyproject.toml index 5773a38a5..3806fee56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" [project] name = "fedn" -version = "0.11.0" +version = "0.11.1" description = "Scaleout Federated Learning" authors = [{ name = "Scaleout Systems AB", email = "contact@scaleoutsystems.com" }] readme = "README.rst"