From cc72ee2ee5c1e7773f80585f7b714f12f0e79a0a Mon Sep 17 00:00:00 2001 From: foefl Date: Tue, 6 Jan 2026 08:39:46 +0100 Subject: [PATCH] adapt CLI to include anomaly threshold as parameter, related to #20 --- cli.py | 13 ++++++++++++- cli_mocked.py | 13 ++++++++++++- run_cli_mocked.ps1 | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 run_cli_mocked.ps1 diff --git a/cli.py b/cli.py index b61d84c..8af03c2 100644 --- a/cli.py +++ b/cli.py @@ -5,7 +5,7 @@ from typing import cast from dopt_basics import cli -from dopt_sensor_anomalies import _interface +from dopt_sensor_anomalies import _interface, constants @dc.dataclass() @@ -13,6 +13,7 @@ class CliArgs: img_path: str calib_value_x: float calib_value_y: float + anomaly_threshold: float def main() -> int: @@ -34,6 +35,15 @@ def main() -> int: help="calibration value in pixels per mcm for y axis, type: float", type=float, ) + parser.add_argument( + "--anomaly_threshold", + help=( + f"optional anomaly threshold to set, default: " + f"{constants.ANOMALY_THRESHOLD_DEFAULT}, type: float" + ), + default=constants.ANOMALY_THRESHOLD_DEFAULT, + type=float, + ) args = cast(CliArgs, parser.parse_args()) with cli.LoadingAnimation( @@ -44,6 +54,7 @@ def main() -> int: args.img_path, args.calib_value_x, args.calib_value_y, + args.anomaly_threshold, ) if status != 0: loader.stop(interrupt=True) diff --git a/cli_mocked.py b/cli_mocked.py index df1a317..96c14e7 100644 --- a/cli_mocked.py +++ b/cli_mocked.py @@ -6,7 +6,7 @@ from unittest.mock import patch from dopt_basics import cli -from dopt_sensor_anomalies import _interface +from dopt_sensor_anomalies import _interface, constants @dc.dataclass() @@ -14,6 +14,7 @@ class CliArgs: img_path: str calib_value_x: float calib_value_y: float + anomaly_threshold: float @patch("dopt_sensor_anomalies._find_paths.STOP_FOLDER_NAME", "src") @@ -37,6 +38,15 @@ def main() -> int: help="calibration value in pixels per mcm for y axis, type: float", type=float, ) + parser.add_argument( + "--anomaly_threshold", + help=( + f"optional anomaly threshold to set, default: " + f"{constants.ANOMALY_THRESHOLD_DEFAULT}, type: float" + ), + default=constants.ANOMALY_THRESHOLD_DEFAULT, + type=float, + ) args = cast(CliArgs, parser.parse_args()) with cli.LoadingAnimation( @@ -47,6 +57,7 @@ def main() -> int: args.img_path, args.calib_value_x, args.calib_value_y, + args.anomaly_threshold, ) if status != 0: loader.stop(interrupt=True) diff --git a/run_cli_mocked.ps1 b/run_cli_mocked.ps1 new file mode 100644 index 0000000..ac66432 --- /dev/null +++ b/run_cli_mocked.ps1 @@ -0,0 +1 @@ +pdm run python .\cli_mocked.py ".\prototypes\img\window_19_fail_model.bmp" 0.251 0.251 \ No newline at end of file