diff options
| author | Mykola Martynov <mykola@herdwatch.com> | 2024-03-19 18:56:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-19 18:56:38 +0200 |
| commit | c63589857942cc4f46744919ef73aa60dd44258b (patch) | |
| tree | 6e86e552cc31247e4256efa1ccf9ac46fda980cc | |
| parent | 0251ffc903efff22b965503ed2db92d5404d5529 (diff) | |
use alias when available for strategy setting (#235)
* Add --allow_hpa flag
* use `--allow-hpa` option
* use OptionInfo instead of Option to support different name for same option
* revert back allow_hpa field definition
* fix issue when there is no underscore exist in option name
---------
Co-authored-by: Robusta Runner <aantny@gmail.com>
| -rw-r--r-- | robusta_krr/main.py | 7 | ||||
| -rw-r--r-- | robusta_krr/strategies/simple.py | 3 |
2 files changed, 5 insertions, 5 deletions
diff --git a/robusta_krr/main.py b/robusta_krr/main.py index 83faeba..7dff56b 100644 --- a/robusta_krr/main.py +++ b/robusta_krr/main.py @@ -10,6 +10,7 @@ from uuid import UUID import typer import urllib3 from pydantic import ValidationError # noqa: F401 +from typer.models import OptionInfo from robusta_krr import formatters as concrete_formatters # noqa: F401 from robusta_krr.core.abstract import formatters @@ -280,9 +281,9 @@ def load_commands() -> None: inspect.Parameter( name=field_name, kind=inspect.Parameter.KEYWORD_ONLY, - default=typer.Option( - field_meta.default, - f"--{field_name}", + default=OptionInfo( + default=field_meta.default, + param_decls=list(set([f"--{field_name}", f"--{field_name.replace('_', '-')}"])), help=f"{field_meta.field_info.description}", rich_help_panel="Strategy Settings", ), diff --git a/robusta_krr/strategies/simple.py b/robusta_krr/strategies/simple.py index 8bbd08d..64e58ac 100644 --- a/robusta_krr/strategies/simple.py +++ b/robusta_krr/strategies/simple.py @@ -21,7 +21,6 @@ from robusta_krr.core.integrations.prometheus.metrics import ( PrometheusMetric, ) - class SimpleStrategySettings(StrategySettings): cpu_percentile: float = pd.Field(99, gt=0, le=100, description="The percentile to use for the CPU recommendation.") memory_buffer_percentage: float = pd.Field( @@ -66,7 +65,7 @@ class SimpleStrategy(BaseStrategy[SimpleStrategySettings]): This strategy does not work with objects with HPA defined (Horizontal Pod Autoscaler). If HPA is defined for CPU or Memory, the strategy will return "?" for that resource. - You can override this behaviour by passing the --allow_hpa flag + You can override this behaviour by passing the --allow-hpa flag Learn more: [underline]https://github.com/robusta-dev/krr#algorithm[/underline] """ |
