Skip to content

Commit a49b6b2

Browse files
[log] add log
1 parent a592c59 commit a49b6b2

6 files changed

Lines changed: 28 additions & 38 deletions

File tree

‎dashscope/cli/deployments.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,9 @@ def _wait_for_deployment(
8585
except Exception as exc:
8686
logger.debug("wait_for_deployment error", exc_info=exc)
8787
err_console.print(
88-
f"[red]Error:[/red] Failed to check deployment status: {exc}. "
8988
f"You can get deployment status via: "
9089
f"[cyan]dashscope deployments get {deployed_model}[/cyan]",
9190
)
92-
raise typer.Exit(1)
9391

9492

9593
def _print_deployments(output):

‎dashscope/finetune/deployments.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ def call( # pylint: disable=arguments-renamed # type: ignore[override]
4747
4848
Args:
4949
model (str): The model name.
50-
capacity (int): The model service capacity.
5150
version (str, optional): The model version, unnecessary
5251
for fine-tuned model. Defaults to None.
5352
suffix (str, optional): The name suffix of the model deployment,
5453
If specified, the final model name will be model_suffix.
5554
Defaults to None.
55+
capacity (int, optional): The model service capacity.
5656
plan (str, optional): The deployment plan required by the
5757
service: "ptu" (PTU reserved), "mu" (model unit) or
5858
"Lora" (LoRA deployment). Defaults to None.

‎dashscope/finetune/reinforcement/common/utils.py‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,20 @@ def _sync_upload_to_oss(signed_url: str, zip_path: str) -> int:
520520
file_size = os.path.getsize(zip_path)
521521
size_mb = file_size / (1024 * 1024)
522522
if file_size > FC_OSS_FILE_SIZE_WARNING:
523-
logger.warning(
524-
f"Uploading large file: {zip_path} ({size_mb:.2f}MB) to OSS",
523+
max_mb = FC_OSS_FILE_SIZE_WARNING / (1024 * 1024)
524+
reason = (
525+
f"Package too large: {zip_path} ({size_mb:.2f}MB) "
526+
f"exceeds the maximum allowed size of {max_mb:.0f}MB "
527+
f"for OSS upload. The upload was not attempted. "
528+
f"Reduce the package size (e.g. exclude large files via "
529+
f"env var FC_ZIP_EXCLUDE_PATTERNS) or raise the limit via "
530+
f"env var FC_OSS_FILE_SIZE_WARNING (current: "
531+
f"{FC_OSS_FILE_SIZE_WARNING} bytes)."
525532
)
533+
logger.error(reason)
526534
raise OSSUploadError(
527-
f"Uploading large file: {zip_path} ({size_mb:.2f}MB) to OSS",
535+
reason,
536+
file_size=file_size,
528537
)
529538

530539
logger.debug(
@@ -541,11 +550,18 @@ def _sync_upload_to_oss(signed_url: str, zip_path: str) -> int:
541550

542551
if response.status_code != 200:
543552
error_msg = response.text
553+
logger.error(
554+
f"OSS upload failed | File: {zip_path} "
555+
f"({size_mb:.2f}MB), Status: {response.status_code}, "
556+
f"Response: {error_msg}",
557+
)
544558
raise OSError(
545559
f"OSS upload failed ({response.status_code}): {error_msg}",
546560
)
547561

548562
return response.status_code
563+
except OSSUploadError:
564+
raise
549565
except Exception as e:
550566
raise RuntimeErrorWithCode(
551567
"OSS upload error",

‎dashscope/finetune/reinforcement/component/data/reward_output.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class RewardOutput(BaseModel):
5555
default=None,
5656
description="Error details if the reward computation failed.",
5757
)
58+
error_code: Optional[str] = Field(
59+
default=None,
60+
description="Error code if the reward computation failed.",
61+
)
5862

5963
class Config:
6064
extra = "allow"

‎dashscope/finetune/reinforcement/component/data/rollout_output.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class RolloutOutput(BaseModel):
4040
default=None,
4141
description="Error details (when failed).",
4242
)
43+
error_code: Optional[str] = Field(
44+
default=None,
45+
description="Error code (when failed).",
46+
)
4347

4448
class Config:
4549
extra = "allow"

‎tests/unit/test_cli_main.py‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -756,38 +756,6 @@ def mock_call(**kwargs):
756756
assert "Create deployment failed: deployment failed" in result.output
757757
assert "Traceback" not in result.output
758758

759-
def test_deployments_create_exits_nonzero_when_status_poll_fails(
760-
self,
761-
monkeypatch,
762-
):
763-
def mock_call(**_kwargs):
764-
return SimpleNamespace(
765-
status_code=200,
766-
output={"deployed_model": "deploy-1"},
767-
)
768-
769-
def mock_get(*_args, **_kwargs):
770-
raise RuntimeError("network down")
771-
772-
monkeypatch.setattr(
773-
"dashscope.cli.deployments.dashscope.Deployments.call",
774-
mock_call,
775-
)
776-
monkeypatch.setattr(
777-
"dashscope.cli.deployments.dashscope.Deployments.get",
778-
mock_get,
779-
)
780-
781-
result = CliRunner().invoke(
782-
cli_app,
783-
["deployments", "create", "--model", "qwen", "--plan", "ptu"],
784-
)
785-
786-
assert result.exit_code == 1
787-
assert "Failed to check deployment status" in result.output
788-
assert "deployments get deploy-1" in result.output
789-
assert "Traceback" not in result.output
790-
791759
def test_application_response_without_usage_is_supported(
792760
self,
793761
monkeypatch,

0 commit comments

Comments
 (0)