Skip to content
qgonDEV DOCSSDK 0.3.31
ENKR

qgon.queue

In the appBuild › Scheduling

Reorders the GPU queue and sends urgent requests and yield requests.

from qgon import queue as q
q.order() # the 'gpu' queue: {queue, admin, entries:[{task_id, position, owner, mine, urgent, ...}]}
q.move("3fa8c2d1", "up") # my task: swap places with my nearest task ahead (admin: up one place)
q.move("3fa8c2d1", swap_with="9b01e7aa") # swap with that task: members only with their own task right ahead or behind, admins only with the adjacent task
q.move("3fa8c2d1", "top") # top and bottom are admin-only; members send an urgent request
q.urgent("3fa8c2d1", reason="demo in 30 minutes") # urgent request; moves to the front when an admin approves
q.urgent_requests() # my requests (admins: all); state='all' includes handled ones
q.cancel_urgent(12) # cancel by request number · admins: q.approve_urgent(12) / q.reject_urgent(12, note=...)
q.yield_task("5c77…") # ask a running GPU task to yield (admin, or the owner for their own task) · cancel=True cancels
q.status() # dispatch status: wait reasons (waiting), running tasks (running), yields (yields)

The server decides every rule and the SDK passes requests through. Members reorder only their own tasks: up and down swap with their nearest own task ahead or behind, and other users' tasks keep their places. Admins can move any task up or down one place, or to the top or bottom; there is no move to an arbitrary position. Members do not see the names or wait reasons of other users' tasks.

The module uses the device address and session from the SDK configuration, and it also works inside a workspace. A workspace key cannot perform admin actions, even for an admin account (approving or rejecting urgent requests, top and bottom, yield for_task and force); use the web app or the SDK with your own API key from Settings › API credentials for those.

When the server refuses a request, QueueError carries the server's message, the HTTP status and the error code. A malformed argument raises QueueUsageError before anything is sent. A task id is the full 32-character id, or a prefix of at least 4 characters that matches exactly one task in the list the action works on.

import qgon.queue

QueueError

exception

Raised when the server refuses a request or cannot be reached, with the server's message (in Korean); status is the HTTP status (0 if unreachable, 400 if the SDK rejected it first) and code the server error code.

QueueError(message: str, status: int=0, code: Optional[str]=None)

In the app · Build › Scheduling

Raised by the SDK before sending when an argument is malformed (task id form, action, state or request number); the CLI exits with code 2.

QueueUsageError(message: str, code: Optional[str]=None)

In the app · Build › Scheduling

order

function

Returns the queue order as {queue, admin, entries}; name appears only for your own tasks or to admins, owner_id only to admins, and the default queue is QGON_QUEUE or gpu.

order(queue: Optional[str]=None) -> Dict[str, Any]
Full description (Korean original)

name 은 내 작업·관리자에게만, owner_id 는 관리자에게만. 기본 큐 = 환경변수 QGON_QUEUE 또는 gpu.

In the app · Build › Scheduling

move

function

Moves a waiting task.

move(
task_id: str,
action: Optional[str] = None,
*,
queue: Optional[str] = None,
swap_with: Optional[str] = None,
) -> Dict[str, Any]
Full description (Korean original)
action
up · down, 멤버: 가장 가까운 앞/뒤의 내 작업과 자리 교환(남의 작업 자리는 그대로) · 관리자: 한 칸. top · bottom, 관리자만(멤버는 서버가 403 admin_only → 긴급 요청).
swap_with
그 작업과 맞바꾸기, 지금 순서를 읽어 한 번의 up/down 으로 되는지 보고 보낸다(멤버: 바로 앞/뒤의 내 작업, 관리자: 바로 옆).

반환: 서버 응답 {queue, task_id, action, moved, from, to, swapped_with?, entries:[{task_id, position}]}.
swap_with 로 보냈는데 그사이 순서가 바뀌어 서버가 다른 작업과 바꿨으면 응답에 swap_mismatch=True 를 더한다.

In the app · Build › Scheduling

urgent

function

Asks an admin to move your waiting task to the front, with a one-line reason of up to 200 characters; once approved, the task moves to the front and is marked urgent.

urgent(
task_id: str,
reason: str,
*,
queue: Optional[str] = None,
) -> Dict[str, Any]
Full description (Korean original)

반환: 요청 항목 {id, task_id, task_name, queue, state:'pending', requester, reason, created, position, …}.
짧은 id 는 queue(기본 gpu) 대기열의 내 작업에서 찾는다.

In the app · Build › Scheduling

Lists urgent requests (admins see all, members their own; the latest 200), filtered by state: pending (default), approving, approved, rejected, cancelled or all.

urgent_requests(state: str='pending') -> List[Dict[str, Any]]

In the app · Build › Scheduling

Cancels an urgent request you sent, before it is handled, by its request number (the id from urgent_requests()).

cancel_urgent(request_id) -> Dict[str, Any]

In the app · Build › Scheduling

(Admin) Approves an urgent request and moves the task to the front; the result includes position and ran_immediately.

approve_urgent(request_id, note: Optional[str]=None) -> Dict[str, Any]

In the app · Build › Scheduling

(Admin) Rejects an urgent request; the order stays as it is.

reject_urgent(request_id, note: Optional[str]=None) -> Dict[str, Any]

In the app · Build › Scheduling

status

function

Returns the dispatch status, including why tasks are waiting, the running tasks and yields; members see only the position and reason of other users' waiting tasks and none of their running tasks.

status() -> Dict[str, Any]
Full description (Korean original)

멤버에게 남의 대기 작업은 {position, reason, mine:false} 만, 남의 실행 중 작업은 보이지 않는다.

In the app · Build › Scheduling

yield_task

function

Asks a running GPU task to yield, so it exits after a checkpoint with code 75 and rejoins the queue to resume; admins can ask any task, and owners their own, which then goes to the back of the queue.

yield_task(
task_id: str,
cancel: bool = False,
*,
reason: Optional[str] = None,
for_task: Optional[str] = None,
force: bool = False,
) -> Dict[str, Any]
Full description (Korean original)

cancel=True 면 열린 요청 취소(SDK 가 아직 종료를 시작하지 않았을 때만).
for_task(누구를 위해, 대기 중인 긴급 작업)·force(양보할 수 없는 작업도 강제로 멈추고 다시 줄 세우기)는 관리자만.
반환: 요청 {id, task_id, state(requested|stopping), deadline, wait_s, force, yield_capable} · 취소 {task_id, state:'cancelled'}.
짧은 id 는 status() 의 실행 중 작업(멤버는 내 것만)·양보 목록에서 찾는다.

In the app · Build › Scheduling