From 804e0a3915101ccd103c26774c621972e8c83b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=C3=85strand?= <112588563+benjaminastrand@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:18:44 +0100 Subject: [PATCH] Fix/SK-1181 | Prevent default flag values from always overwriting yaml file in start-v2 (#741) --- fedn/cli/client_cmd.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fedn/cli/client_cmd.py b/fedn/cli/client_cmd.py index 7827d1cc0..b6c33d8af 100644 --- a/fedn/cli/client_cmd.py +++ b/fedn/cli/client_cmd.py @@ -212,14 +212,14 @@ def _complement_client_params(config: dict): @click.option("-u", "--api-url", required=False, help="Hostname for fedn api.") @click.option("-p", "--api-port", required=False, help="Port for discovery services (reducer).") @click.option("--token", required=False, help="Set token provided by reducer if enabled") -@click.option("-n", "--name", required=False, default="client" + str(uuid.uuid4())[:8]) +@click.option("-n", "--name", required=False) @click.option("-i", "--client-id", required=False) @click.option("--local-package", is_flag=True, help="Enable local compute package") @click.option("-c", "--preferred-combiner", type=str, required=False, default="", help="name of the preferred combiner") @click.option("--combiner", type=str, required=False, default=None, help="Skip combiner assignment from discover service and attach directly to combiner host.") @click.option("--combiner-port", type=str, required=False, default=None, help="Combiner port, need to be used with --combiner") -@click.option("-va", "--validator", required=False, default=True) -@click.option("-tr", "--trainer", required=False, default=True) +@click.option("-va", "--validator", required=False, default=None) +@click.option("-tr", "--trainer", required=False, default=None) @click.option("-h", "--helper_type", required=False, default=None) @click.option("-in", "--init", required=False, default=None, help="Set to a filename to (re)init client from file state.") @click.pass_context @@ -291,6 +291,8 @@ def client_start_v2_cmd( config["name"] = name if config["name"]: click.echo(f"Input param name: {name} overrides value from file") + elif config["name"] is None: + config["name"] = "client" + str(uuid.uuid4())[:8] if client_id and client_id != "": config["client_id"] = client_id @@ -316,11 +318,15 @@ def client_start_v2_cmd( config["validator"] = validator if config["validator"] is not None: click.echo(f"Input param validator: {validator} overrides value from file") + elif config["validator"] is None: + config["validator"] = True if trainer is not None: config["trainer"] = trainer if config["trainer"] is not None: click.echo(f"Input param trainer: {trainer} overrides value from file") + elif config["trainer"] is None: + config["trainer"] = True if helper_type and helper_type != "": config["helper_type"] = helper_type