generated from dopt-python/py311
adapt CLI to include anomaly threshold as parameter, related to #20
This commit is contained in:
parent
ca75b2308f
commit
cc72ee2ee5
13
cli.py
13
cli.py
@ -5,7 +5,7 @@ from typing import cast
|
|||||||
|
|
||||||
from dopt_basics import cli
|
from dopt_basics import cli
|
||||||
|
|
||||||
from dopt_sensor_anomalies import _interface
|
from dopt_sensor_anomalies import _interface, constants
|
||||||
|
|
||||||
|
|
||||||
@dc.dataclass()
|
@dc.dataclass()
|
||||||
@ -13,6 +13,7 @@ class CliArgs:
|
|||||||
img_path: str
|
img_path: str
|
||||||
calib_value_x: float
|
calib_value_x: float
|
||||||
calib_value_y: float
|
calib_value_y: float
|
||||||
|
anomaly_threshold: float
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
@ -34,6 +35,15 @@ def main() -> int:
|
|||||||
help="calibration value in pixels per mcm for y axis, type: float",
|
help="calibration value in pixels per mcm for y axis, type: float",
|
||||||
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())
|
args = cast(CliArgs, parser.parse_args())
|
||||||
|
|
||||||
with cli.LoadingAnimation(
|
with cli.LoadingAnimation(
|
||||||
@ -44,6 +54,7 @@ def main() -> int:
|
|||||||
args.img_path,
|
args.img_path,
|
||||||
args.calib_value_x,
|
args.calib_value_x,
|
||||||
args.calib_value_y,
|
args.calib_value_y,
|
||||||
|
args.anomaly_threshold,
|
||||||
)
|
)
|
||||||
if status != 0:
|
if status != 0:
|
||||||
loader.stop(interrupt=True)
|
loader.stop(interrupt=True)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
from dopt_basics import cli
|
from dopt_basics import cli
|
||||||
|
|
||||||
from dopt_sensor_anomalies import _interface
|
from dopt_sensor_anomalies import _interface, constants
|
||||||
|
|
||||||
|
|
||||||
@dc.dataclass()
|
@dc.dataclass()
|
||||||
@ -14,6 +14,7 @@ class CliArgs:
|
|||||||
img_path: str
|
img_path: str
|
||||||
calib_value_x: float
|
calib_value_x: float
|
||||||
calib_value_y: float
|
calib_value_y: float
|
||||||
|
anomaly_threshold: float
|
||||||
|
|
||||||
|
|
||||||
@patch("dopt_sensor_anomalies._find_paths.STOP_FOLDER_NAME", "src")
|
@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",
|
help="calibration value in pixels per mcm for y axis, type: float",
|
||||||
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())
|
args = cast(CliArgs, parser.parse_args())
|
||||||
|
|
||||||
with cli.LoadingAnimation(
|
with cli.LoadingAnimation(
|
||||||
@ -47,6 +57,7 @@ def main() -> int:
|
|||||||
args.img_path,
|
args.img_path,
|
||||||
args.calib_value_x,
|
args.calib_value_x,
|
||||||
args.calib_value_y,
|
args.calib_value_y,
|
||||||
|
args.anomaly_threshold,
|
||||||
)
|
)
|
||||||
if status != 0:
|
if status != 0:
|
||||||
loader.stop(interrupt=True)
|
loader.stop(interrupt=True)
|
||||||
|
|||||||
1
run_cli_mocked.ps1
Normal file
1
run_cli_mocked.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
pdm run python .\cli_mocked.py ".\prototypes\img\window_19_fail_model.bmp" 0.251 0.251
|
||||||
Loading…
x
Reference in New Issue
Block a user