From 217756eef5462b701b6a91a73372d61734c7d866 Mon Sep 17 00:00:00 2001 From: Akrem Abayed Date: Tue, 2 Apr 2024 12:44:20 +0200 Subject: [PATCH] replace options with choices --- agenta-cli/agenta/sdk/agenta_decorator.py | 2 +- agenta-cli/agenta/sdk/types.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/agenta-cli/agenta/sdk/agenta_decorator.py b/agenta-cli/agenta/sdk/agenta_decorator.py index adf78d36b9..dc0ae686b0 100644 --- a/agenta-cli/agenta/sdk/agenta_decorator.py +++ b/agenta-cli/agenta/sdk/agenta_decorator.py @@ -400,7 +400,7 @@ def find_in_schema(schema: dict, param_name: str, xparam: str): if isinstance(param_val, GroupedMultipleChoiceParam): subschema = find_in_schema(schema_to_override, param_name, "grouped_choice") if subschema: - subschema["choices"] = param_val.options + subschema["choices"] = param_val.choices subschema["default"] = param_val.default if isinstance(param_val, MultipleChoiceParam): subschema = find_in_schema(schema_to_override, param_name, "choice") diff --git a/agenta-cli/agenta/sdk/types.py b/agenta-cli/agenta/sdk/types.py index 2c1b8fe959..1526f434d8 100644 --- a/agenta-cli/agenta/sdk/types.py +++ b/agenta-cli/agenta/sdk/types.py @@ -128,34 +128,34 @@ def __modify_schema__(cls, field_schema: dict[str, Any]): class GroupedMultipleChoiceParam(str): - def __new__(cls, default: str = None, options: Dict[str, List[str]] = None): - if options is None: - options = {} + def __new__(cls, default: str = None, choices: Dict[str, List[str]] = None): + if choices is None: + choices = {} - # Check if default is in the options - if default and not any(default in choices for choices in options.values()): - if not options: + # Check if default is in the choices + if default and not any(default in choices for choices in choices.values()): + if not choices: print( - f"Warning: Default value {default} provided but options are empty." + f"Warning: Default value {default} provided but choices are empty." ) else: raise ValueError( - f"Default value {default} is not in the provided options" + f"Default value {default} is not in the provided choices" ) if not default: - for choices in options.values(): + for choices in choices.values(): if choices: default = choices[0] break if default is None: raise ValueError( - "No choices available in the provided options or default not set" + "No choices available in the provided choices or default not set" ) instance = super().__new__(cls, default) - instance.options = options + instance.choices = choices instance.default = default return instance