Skip to content

[PLT-4664] Add Project.clear_queue_reservations - #2087

Merged
Gabefire merged 1 commit into
developfrom
gu/plt-4664-clear-queue-reservations
Oct 21, 2026
Merged

Gabefire merged 1 commit into
developfrom
gu/plt-4664-clear-queue-reservations

Conversation

@Gabefire

@Gabefire Gabefire commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds Project.clear_queue_reservations(task_queue_id), which clears every reservation in one task queue of a project. It's the SDK equivalent of Clear all reservations on the project Queue tab. Customers asked for it so admins can unblock rows stuck in a queue without a support ticket (PLT-4664).

queue = next(q for q in project.task_queues() if q.name == "Review")
cleared = project.clear_queue_reservations(queue.uid)  # int, or None if the count was unavailable
  • Docstring warning: it says plainly that the action is destructive and cannot be undone. Holders lose their rows and unsaved work on them. Only reservations are cleared: no labels are deleted and no data rows are enqueued or moved.
  • Requirements: the project permission to clear all reservations (Admin, Team Manager, or a custom role). Not supported on GitHub-integrated projects with the reservation lifecycle enabled.
  • Return value: the number of reservations the queue held just before the clear, or None if that count couldn't be read (the clear still ran).
  • Errors: raises LabelboxError when the server reports the clear failed, and ResourceNotFoundError when the queue is not in the project.

Depends on Labelbox/intelligence#31631, which makes the clearQueueReservations mutation public and adds clearedReservationCount. Release this after that PR is deployed; until then, calls fail with a schema error.

Fixes PLT-4664 (SDK part)

Type of change

  • New feature (non-breaking change which adds functionality)

All Submissions

  • Have you followed the guidelines in our Contributing document?
  • Have you provided a description?
  • Are your changes properly formatted?

New Feature Submissions

  • Does your submission pass tests?
  • Have you added thorough tests for your new feature?
  • Have you commented your code, particularly in hard-to-understand areas?
  • Have you added a Docstring?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you updated any code comments, as applicable?

Tests: tests/unit/test_unit_project_clear_queue_reservations.py (3 tests) pass locally, alongside the existing bulk-assign unit tests. No integration test yet, because it needs the API change deployed.

🤖 Generated with Claude Code


Note

Medium Risk
Introduces a destructive, permission-gated queue operation that can drop labeler reservations and unsaved work; misuse or wrong queue ID could disrupt labeling, though existing behavior is unchanged.

Overview
Adds Project.clear_queue_reservations(task_queue_id), exposing the Queue tab’s “clear all reservations” action in the Python SDK. The method calls the clearQueueReservations GraphQL mutation with the project and queue IDs, returns how many reservations were cleared (or None if the count is unavailable), and raises LabelboxError when the server reports failure. The docstring documents destructive impact (holders lose rows and unsaved work), permission requirements, and GitHub reservation-lifecycle limitations.

Unit tests mock the client to verify mutation shape, successful count/None returns, and error handling on success: false. Depends on backend PR making clearQueueReservations public before this works in production.

Reviewed by Cursor Bugbot for commit 9c9c3ce. Bugbot is set up for automated code reviews on this repo. Configure here.

Clears every reservation in one task queue of a project and returns how
many reservations the queue held, or None when that count could not be
read. Destructive and irreversible: holders lose their rows and unsaved
work on them. Only reservations are cleared; no labels are deleted and
no data rows are enqueued. Raises LabelboxError when the clear fails.

Requires the clearQueueReservations mutation to be public (intelligence,
PLT-4664).

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9c9c3ce. Configure here.

result = self.client.execute(
query_str,
{"input": {"projectId": self.uid, "queueId": task_queue_id}},
)["clearQueueReservations"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing queue raises TypeError

Medium Severity

When the queue is not in the project, client.execute returns None for a RESOURCE_NOT_FOUND GraphQL error. Indexing that result then raises TypeError instead of the documented ResourceNotFoundError, so callers catching that exception miss the failure.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9c9c3ce. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid: execute returns None on RESOURCE_NOT_FOUND without raise_return_resource_not_found=True. This PR merged before the fix; fixed in #2090.

@Gabefire
Gabefire merged commit 70fdaae into develop Oct 21, 2026
43 of 44 checks passed
@Gabefire
Gabefire deleted the gu/plt-4664-clear-queue-reservations branch October 21, 2026 14:47

This branch was previously deployed

1 inactive deployment
Test-PyPI — 9c9c3ce7 Deployed Oct 19, 2026 by Gabefire via test-pypi #2550
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.

2 participants