From 19e08c0a142405863c01557b4f1e6e7e5868da23 Mon Sep 17 00:00:00 2001 From: sowmyasris Date: Thu, 4 Jul 2024 11:45:43 +0200 Subject: [PATCH] Feature/SK-918 | Add --version to fedn CLI (#649) * added --version command for fedn package * fixed single quotes with double quotes * fixed double quotes for version * intendation error fixed * fixed the global variable * removed raise in the round handler --- fedn/cli/main.py | 12 ++++++++++-- fedn/common/config.py | 3 --- fedn/network/combiner/roundhandler.py | 1 - 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fedn/cli/main.py b/fedn/cli/main.py index d6f912e62..0d5660c0b 100644 --- a/fedn/cli/main.py +++ b/fedn/cli/main.py @@ -1,3 +1,5 @@ +import importlib.metadata + import click CONTEXT_SETTINGS = dict( @@ -5,10 +7,16 @@ help_option_names=["-h", "--help"], ) +# Dynamically get the version of the package +try: + version = importlib.metadata.version("fedn") +except importlib.metadata.PackageNotFoundError: + version = "unknown" + @click.group(context_settings=CONTEXT_SETTINGS) +@click.version_option(version) @click.pass_context def main(ctx): - """:param ctx: - """ + """:param ctx:""" ctx.obj = dict() diff --git a/fedn/common/config.py b/fedn/common/config.py index 4864ce1ef..94b346d65 100644 --- a/fedn/common/config.py +++ b/fedn/common/config.py @@ -2,9 +2,6 @@ import yaml -global STATESTORE_CONFIG -global MODELSTORAGE_CONFIG - SECRET_KEY = os.environ.get("FEDN_JWT_SECRET_KEY", False) FEDN_JWT_CUSTOM_CLAIM_KEY = os.environ.get("FEDN_JWT_CUSTOM_CLAIM_KEY", False) FEDN_JWT_CUSTOM_CLAIM_VALUE = os.environ.get("FEDN_JWT_CUSTOM_CLAIM_VALUE", False) diff --git a/fedn/network/combiner/roundhandler.py b/fedn/network/combiner/roundhandler.py index ef9029de9..816957323 100644 --- a/fedn/network/combiner/roundhandler.py +++ b/fedn/network/combiner/roundhandler.py @@ -309,7 +309,6 @@ def _assign_round_clients(self, n, type="trainers"): clients = self.server.get_active_trainers() else: logger.error("(ERROR): {} is not a supported type of client".format(type)) - raise # If the number of requested trainers exceeds the number of available, use all available. if n > len(clients):