From 8038b7d850fcb244152b809f20fd4a74d61c183a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Thu, 2 Jul 2026 13:14:12 +0200 Subject: [PATCH] :sparkles: allow passing a webhook to the CLI --- mindee/v2/commands/base_inference_command.py | 13 ++++++++++++- mindee/v2/commands/classification_command.py | 5 ++++- mindee/v2/commands/crop_command.py | 3 ++- mindee/v2/commands/extraction_command.py | 2 ++ mindee/v2/commands/ocr_command.py | 3 ++- mindee/v2/commands/split_command.py | 3 ++- tests/test_v2_cli.sh | 2 +- 7 files changed, 25 insertions(+), 6 deletions(-) diff --git a/mindee/v2/commands/base_inference_command.py b/mindee/v2/commands/base_inference_command.py index 56820213..e6da5139 100644 --- a/mindee/v2/commands/base_inference_command.py +++ b/mindee/v2/commands/base_inference_command.py @@ -78,6 +78,15 @@ def register(self, subparsers: _SubParsersAction) -> ArgumentParser: "- raw: full JSON object\n" ), ) + parser.add_argument( + "-w", + "--webhook-id", + dest="webhook_ids", + action="append", + help="Specify a webhook by ID. May be used multiple times.", + required=False, + default=None, + ) self.configure_product_options(parser) parser.add_argument("path", help="The path of the file to parse.") return parser @@ -98,13 +107,14 @@ def execute( """Run the inference for ``parsed_args`` using ``client_factory``.""" api_key = getattr(parsed_args, "api_key", None) model_id = parsed_args.model_id + webhook_ids = getattr(parsed_args, "webhook_ids", None) alias = getattr(parsed_args, "alias", None) output_type = OutputType( getattr(parsed_args, "output", OutputType.SUMMARY.value) ) client = client_factory(api_key) - params = self.build_parameters(parsed_args, model_id, alias) + params = self.build_parameters(parsed_args, model_id, alias, webhook_ids) input_source = _build_input_source(parsed_args.path) response: ( ExtractionResponse @@ -126,6 +136,7 @@ def build_parameters( parsed_args: Namespace, model_id: str, alias: str | None, + webhook_ids: list[str] | None, ) -> BaseParameters: """Build the V2 inference parameters for this product.""" diff --git a/mindee/v2/commands/classification_command.py b/mindee/v2/commands/classification_command.py index aea19a1f..f092271a 100644 --- a/mindee/v2/commands/classification_command.py +++ b/mindee/v2/commands/classification_command.py @@ -19,6 +19,9 @@ def build_parameters( parsed_args: Namespace, model_id: str, alias: str | None, + webhook_ids: list[str] | None, ) -> BaseParameters: del parsed_args - return ClassificationParameters(model_id=model_id, alias=alias) + return ClassificationParameters( + model_id=model_id, alias=alias, webhook_ids=webhook_ids + ) diff --git a/mindee/v2/commands/crop_command.py b/mindee/v2/commands/crop_command.py index 647980c0..39967f09 100644 --- a/mindee/v2/commands/crop_command.py +++ b/mindee/v2/commands/crop_command.py @@ -19,6 +19,7 @@ def build_parameters( parsed_args: Namespace, model_id: str, alias: str | None, + webhook_ids: list[str] | None, ) -> BaseParameters: del parsed_args - return CropParameters(model_id=model_id, alias=alias) + return CropParameters(model_id=model_id, alias=alias, webhook_ids=webhook_ids) diff --git a/mindee/v2/commands/extraction_command.py b/mindee/v2/commands/extraction_command.py index 40b500d6..2e578de5 100644 --- a/mindee/v2/commands/extraction_command.py +++ b/mindee/v2/commands/extraction_command.py @@ -64,6 +64,7 @@ def build_parameters( parsed_args: Namespace, model_id: str, alias: str | None, + webhook_ids: list[str] | None, ) -> BaseParameters: return ExtractionParameters( model_id=model_id, @@ -73,6 +74,7 @@ def build_parameters( polygon=True if getattr(parsed_args, "polygon", False) else None, confidence=(True if getattr(parsed_args, "confidence", False) else None), text_context=getattr(parsed_args, "text_context", None), + webhook_ids=webhook_ids, ) def get_full_output(self, parsed_args: Namespace, response) -> str: diff --git a/mindee/v2/commands/ocr_command.py b/mindee/v2/commands/ocr_command.py index a5063367..fdd9488c 100644 --- a/mindee/v2/commands/ocr_command.py +++ b/mindee/v2/commands/ocr_command.py @@ -19,6 +19,7 @@ def build_parameters( parsed_args: Namespace, model_id: str, alias: str | None, + webhook_ids: list[str] | None, ) -> BaseParameters: del parsed_args - return OCRParameters(model_id=model_id, alias=alias) + return OCRParameters(model_id=model_id, alias=alias, webhook_ids=webhook_ids) diff --git a/mindee/v2/commands/split_command.py b/mindee/v2/commands/split_command.py index 6f62f940..18b792e8 100644 --- a/mindee/v2/commands/split_command.py +++ b/mindee/v2/commands/split_command.py @@ -19,6 +19,7 @@ def build_parameters( parsed_args: Namespace, model_id: str, alias: str | None, + webhook_ids: list[str] | None, ) -> BaseParameters: del parsed_args - return SplitParameters(model_id=model_id, alias=alias) + return SplitParameters(model_id=model_id, alias=alias, webhook_ids=webhook_ids) diff --git a/tests/test_v2_cli.sh b/tests/test_v2_cli.sh index 9f50532f..cb084b06 100755 --- a/tests/test_v2_cli.sh +++ b/tests/test_v2_cli.sh @@ -28,7 +28,7 @@ run_test() { model_type="$2" echo "--- Test $model_type ID: $model_id" - SUMMARY_OUTPUT=$("$PYTHON_BIN" -m mindee "$model_type" -m "$model_id" "$TEST_FILE") + SUMMARY_OUTPUT=$("$PYTHON_BIN" -m mindee "$model_type" -m "$model_id" -a "python-sdk-cli-${model_type}" "$TEST_FILE") echo "$SUMMARY_OUTPUT" echo "" echo ""