generated from dopt-python/py311
add simple CLI directly to package, related to #8
This commit is contained in:
parent
1920d01607
commit
dd40440843
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "dopt-sensor-anomalies"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
description = "anomaly detection for sensor images for quality assurance processes"
|
||||
authors = [
|
||||
{name = "d-opt GmbH", email = "f.foerster@d-opt.com"},
|
||||
@ -10,6 +10,9 @@ requires-python = "<3.14,>=3.11"
|
||||
readme = "README.md"
|
||||
license = {text = "LicenseRef-Proprietary"}
|
||||
|
||||
[project.scripts]
|
||||
EKF = "dopt_sensor_anomalies.cli:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["pdm-backend", "Cython", "setuptools"]
|
||||
build-backend = "pdm.backend"
|
||||
@ -76,7 +79,7 @@ directory = "reports/coverage"
|
||||
|
||||
|
||||
[tool.bumpversion]
|
||||
current_version = "0.1.1"
|
||||
current_version = "0.1.2"
|
||||
parse = """(?x)
|
||||
(?P<major>0|[1-9]\\d*)\\.
|
||||
(?P<minor>0|[1-9]\\d*)\\.
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
"""main pipeline interface for external calls"""
|
||||
|
||||
from dopt_sensor_anomalies import detection
|
||||
|
||||
|
||||
33
src/dopt_sensor_anomalies/cli.py
Normal file
33
src/dopt_sensor_anomalies/cli.py
Normal file
@ -0,0 +1,33 @@
|
||||
import argparse
|
||||
from typing import cast
|
||||
|
||||
from dopt_sensor_anomalies import _interface
|
||||
from dopt_sensor_anomalies.types import CliArgs
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(
|
||||
description=("simple CLI tool to analyse single sensor images for anomalies")
|
||||
)
|
||||
parser.add_argument(
|
||||
"img_path",
|
||||
help="file path to the image which is to be analysed",
|
||||
type=str,
|
||||
)
|
||||
parser.add_argument(
|
||||
"calib_value_x",
|
||||
help="calibration value in pixels per mcm for x axis",
|
||||
type=float,
|
||||
)
|
||||
parser.add_argument(
|
||||
"calib_value_y",
|
||||
help="calibration value in pixels per mcm for y axis",
|
||||
type=float,
|
||||
)
|
||||
args = cast(CliArgs, parser.parse_args())
|
||||
|
||||
_interface.sensor_anomalies_detection(
|
||||
args.img_path,
|
||||
args.calib_value_x,
|
||||
args.calib_value_y,
|
||||
)
|
||||
@ -25,3 +25,10 @@ class SensorImages(TypedDict):
|
||||
class DetectionModels(TypedDict):
|
||||
left: Path
|
||||
right: Path
|
||||
|
||||
|
||||
@dc.dataclass()
|
||||
class CliArgs:
|
||||
img_path: str
|
||||
calib_value_x: float
|
||||
calib_value_y: float
|
||||
|
||||
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from dopt_sensor_anomalies import _csharp_interface, constants, errors
|
||||
from dopt_sensor_anomalies import _interface, constants, errors
|
||||
|
||||
|
||||
@patch("dopt_sensor_anomalies._find_paths.STOP_FOLDER_NAME", "lib")
|
||||
@ -15,7 +15,7 @@ def test_sensor_anomalies_detection_FailImagePath(setup_temp_dir):
|
||||
MESSAGE = "The provided path seems not to exist"
|
||||
|
||||
with pytest.raises(FileNotFoundError, match=MESSAGE):
|
||||
_csharp_interface.sensor_anomalies_detection(
|
||||
_interface.sensor_anomalies_detection(
|
||||
img_path, pixels_per_metric_X, pixels_per_metric_Y
|
||||
)
|
||||
|
||||
@ -29,7 +29,7 @@ def test_sensor_anomalies_detection_FailElectrodeCount(path_img_with_failure_Ele
|
||||
MESSAGE = "Number of counted electrodes does not match the"
|
||||
|
||||
with pytest.raises(errors.InvalidElectrodeCount, match=MESSAGE):
|
||||
_csharp_interface.sensor_anomalies_detection(
|
||||
_interface.sensor_anomalies_detection(
|
||||
img_path, pixels_per_metric_X, pixels_per_metric_Y
|
||||
)
|
||||
|
||||
@ -52,9 +52,7 @@ def test_sensor_anomalies_detection_Success(
|
||||
pixels_per_metric_X: float = 0.251
|
||||
pixels_per_metric_Y: float = 0.251
|
||||
|
||||
_csharp_interface.sensor_anomalies_detection(
|
||||
img_path, pixels_per_metric_X, pixels_per_metric_Y
|
||||
)
|
||||
_interface.sensor_anomalies_detection(img_path, pixels_per_metric_X, pixels_per_metric_Y)
|
||||
|
||||
assert csv_file.exists()
|
||||
assert heatmap_file.exists()
|
||||
Loading…
x
Reference in New Issue
Block a user