Skip to content

fix: raise RoboflowError when a model upload fails - #549

Open
cdeil wants to merge 1 commit into
roboflow:mainfrom
cdeil:raise-on-failed-model-upload
Open

cdeil wants to merge 1 commit into
roboflow:mainfrom
cdeil:raise-on-failed-model-upload

Conversation

@cdeil

@cdeil cdeil commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Part 1 of #545. Version.deploy() and Workspace.deploy_model() printed upload errors and returned normally, so scripts could not detect a failed upload, and roboflow model upload reported {"status": "uploaded"} with exit code 0.

  • Version._upload_zip() and Workspace._upload_zip() now raise RoboflowError (with status_code) when the request for the upload URL or the upload of the weights fails, instead of printing and returning. The message keeps the details that were printed before, including the server response.
  • The 429 branch raises directly. Before, its RuntimeError was caught by the surrounding except and only printed. I kept its message and appended the server response, because I'm not sure the "already has a trained model" wording still fits now that a version can have several models (Feature: Multiple Models Per Version #497).
  • The CLI needs no change: _upload_model already reports exceptions through output_error, so roboflow model upload now exits 1 with the error on stderr.
  • The weights file is opened in a with block, so the handle is closed.

Behavior change: code that called deploy() or deploy_model() and ignored failures now gets an exception.

Part 2 of #545 (upload_dataset() and roboflow image upload <dir>) changes a return value and is left for a separate discussion. This PR touches the same error branches as #548 (API key redaction); whichever is merged first, I'll rebase the other.

Test plan

  • tests/test_model_upload.py: failures of either request in both methods raise RoboflowError with the HTTP status; a successful upload still prints the status URL; the CLI exits 1 with a JSON error and no "uploaded" status. The five failure tests fail on main and pass with this change.
  • Python 3.13: make check_code_quality passes; python -m unittest runs 1217 tests, OK (1 skipped).

Version._upload_zip() and Workspace._upload_zip() caught every error,
printed it and returned, so Version.deploy() and Workspace.deploy_model()
looked successful and `roboflow model upload` reported "uploaded" with
exit code 0. They now raise RoboflowError with the HTTP status when the
upload URL request or the weights upload fails; the 429 branch, whose
RuntimeError was swallowed by the same except, raises directly. The CLI
already reports exceptions through output_error, so it now exits 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant