Source code for kappa_sdk.workflow_settings

from enum import Enum
from typing import Optional, Dict, Any, List, Union


[docs] class IptaParameter(Enum): C = "-C" Skin = "-Skin" k = "-k" h = "-h" phi = "-ɸ" S = "-S" E = "-E" N = "-N" W = "-W"
[docs] class IrtaParameter(Enum): Skin = "-Skin" Xmf = "-Xmf" Pi = '-Pi' k = "-k" h = "-h" phi = "-ɸ" zone_1_d = "Zone 1-d" zone_1_ri = "Zone 1-Ri" zone_2_d = "Zone 2-d"
[docs] class WorkflowImproveSettings: def __init__(self, workflow_improve_parameters: List[Dict[str, Any]], use_all_parameters: bool = False, use_wide_search: bool = False, update_values: bool = False, update_bounds: bool = False): self.__parameters: List[Dict[str, Any]] = workflow_improve_parameters if use_all_parameters: for parameter in self.__parameters: parameter["isIncluded"] = True self.__wide_search_settings: Dict[str, Any] = {"useWideSearch": use_wide_search, "initialPopulation": 50, "boundsStretch": 10} self.__update_values: bool = update_values self.__update_bounds: bool = update_bounds def select_parameter(self, parameter: Union[IptaParameter, IrtaParameter], min_value: Optional[float] = None, max_value: Optional[float] = None) -> None: try: selected_parameter = next(x for x in self.__parameters if x["id"] == parameter.value) except StopIteration: raise ValueError(f"Cannot find {parameter.value} in the improve parameter list, make sure you are using the right type of parameter, could be IptaParameter or IrtaParameter") if min_value is not None: selected_parameter["minValue"] = min_value if max_value is not None: selected_parameter["maxValue"] = max_value selected_parameter["isIncluded"] = True def remove_parameter(self, parameter: Union[IptaParameter, IrtaParameter]) -> None: try: selected_parameter = next(x for x in self.__parameters if x["id"] == parameter.value) except StopIteration: raise ValueError(f"Cannot find {parameter.value} in the improve parameter list, make sure you are using the right type of parameter, could be IptaParameter or IrtaParameter") selected_parameter["isIncluded"] = False def update_wide_search_settings(self, initial_population: float = 50, bounds_stretch: float = 10) -> None: self.__wide_search_settings["initialPopulation"] = initial_population self.__wide_search_settings["boundsStretch"] = bounds_stretch def dump(self) -> Dict[str, Any]: return {"updateValues": self.__update_values, "updateBounds": self.__update_bounds, "nlrSettings": {"wideSearchSettings": self.__wide_search_settings}, "parameters": self.__parameters}