diff --git a/dashscope/cli/deployments.py b/dashscope/cli/deployments.py index 4450d0e..6fffe1e 100644 --- a/dashscope/cli/deployments.py +++ b/dashscope/cli/deployments.py @@ -85,9 +85,11 @@ def _wait_for_deployment( except Exception as exc: logger.debug("wait_for_deployment error", exc_info=exc) err_console.print( + f"[red]Error:[/red] Failed to check deployment status: {exc}. " f"You can get deployment status via: " f"[cyan]dashscope deployments get {deployed_model}[/cyan]", ) + raise typer.Exit(1) def _print_deployments(output): diff --git a/dashscope/finetune/deployments.py b/dashscope/finetune/deployments.py index 182062a..4bfb916 100644 --- a/dashscope/finetune/deployments.py +++ b/dashscope/finetune/deployments.py @@ -47,12 +47,12 @@ def call( # pylint: disable=arguments-renamed # type: ignore[override] Args: model (str): The model name. + capacity (int): The model service capacity. version (str, optional): The model version, unnecessary for fine-tuned model. Defaults to None. suffix (str, optional): The name suffix of the model deployment, If specified, the final model name will be model_suffix. Defaults to None. - capacity (int, optional): The model service capacity. plan (str, optional): The deployment plan required by the service: "ptu" (PTU reserved), "mu" (model unit) or "Lora" (LoRA deployment). Defaults to None. diff --git a/tests/unit/test_cli_main.py b/tests/unit/test_cli_main.py index a7f04ad..22f9c34 100644 --- a/tests/unit/test_cli_main.py +++ b/tests/unit/test_cli_main.py @@ -756,6 +756,38 @@ def mock_call(**kwargs): assert "Create deployment failed: deployment failed" in result.output assert "Traceback" not in result.output + def test_deployments_create_exits_nonzero_when_status_poll_fails( + self, + monkeypatch, + ): + def mock_call(**_kwargs): + return SimpleNamespace( + status_code=200, + output={"deployed_model": "deploy-1"}, + ) + + def mock_get(*_args, **_kwargs): + raise RuntimeError("network down") + + monkeypatch.setattr( + "dashscope.cli.deployments.dashscope.Deployments.call", + mock_call, + ) + monkeypatch.setattr( + "dashscope.cli.deployments.dashscope.Deployments.get", + mock_get, + ) + + result = CliRunner().invoke( + cli_app, + ["deployments", "create", "--model", "qwen", "--plan", "ptu"], + ) + + assert result.exit_code == 1 + assert "Failed to check deployment status" in result.output + assert "deployments get deploy-1" in result.output + assert "Traceback" not in result.output + def test_application_response_without_usage_is_supported( self, monkeypatch,