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
2 changes: 2 additions & 0 deletions dashscope/cli/deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion dashscope/finetune/deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/test_cli_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading