Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion mindee/v2/commands/base_inference_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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."""

Expand Down
5 changes: 4 additions & 1 deletion mindee/v2/commands/classification_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
3 changes: 2 additions & 1 deletion mindee/v2/commands/crop_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions mindee/v2/commands/extraction_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion mindee/v2/commands/ocr_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion mindee/v2/commands/split_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/test_v2_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
Loading