mirror of
https://github.com/clearml/clearml-server
synced 2025-05-08 22:09:24 +00:00
Add "queue watched" indication for tasks.enqueue and tasks.enqueue_many
This commit is contained in:
parent
6b3eff1426
commit
bc23f1b0cf
@ -1948,6 +1948,17 @@ Fails if the following parameters in the task were not filled:
|
||||
type: string
|
||||
}
|
||||
}
|
||||
"999.0": ${enqueue."2.19"} {
|
||||
request.properties.verify_watched_queue {
|
||||
description: If passed then check wheter there are any workers watiching the queue
|
||||
type: boolean
|
||||
default: false
|
||||
}
|
||||
response.properties.queue_watched {
|
||||
description: Returns true if there are workers or autscalers working with the queue
|
||||
type: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
enqueue_many {
|
||||
"2.13": ${_definitions.change_many_request} {
|
||||
@ -1981,6 +1992,17 @@ enqueue_many {
|
||||
type: string
|
||||
}
|
||||
}
|
||||
"999.0": ${enqueue_many."2.19"} {
|
||||
request.properties.verify_watched_queue {
|
||||
description: If passed then check wheter there are any workers watiching the queue
|
||||
type: boolean
|
||||
default: false
|
||||
}
|
||||
response.properties.queue_watched {
|
||||
description: Returns true if there are workers or autscalers working with the queue
|
||||
type: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
dequeue {
|
||||
"1.5" {
|
||||
|
@ -850,6 +850,11 @@ def enqueue(call: APICall, company_id, request: EnqueueRequest):
|
||||
queue_name=request.queue_name,
|
||||
force=request.force,
|
||||
)
|
||||
if request.verify_watched_queue:
|
||||
res_queue = nested_get(res, ("fields", "execution.queue"))
|
||||
if res_queue:
|
||||
res["queue_watched"] = queue_bll.check_for_workers(company_id, res_queue)
|
||||
|
||||
call.result.data_model = EnqueueResponse(queued=queued, **res)
|
||||
|
||||
|
||||
@ -871,12 +876,20 @@ def enqueue_many(call: APICall, company_id, request: EnqueueManyRequest):
|
||||
),
|
||||
ids=request.ids,
|
||||
)
|
||||
extra = {}
|
||||
if request.verify_watched_queue and results:
|
||||
_id, (queued, res) = results[0]
|
||||
res_queue = nested_get(res, ("fields", "execution.queue"))
|
||||
if res_queue:
|
||||
extra["queue_watched"] = queue_bll.check_for_workers(company_id, res_queue)
|
||||
|
||||
call.result.data_model = EnqueueManyResponse(
|
||||
succeeded=[
|
||||
EnqueueBatchItem(id=_id, queued=bool(queued), **res)
|
||||
for _id, (queued, res) in results
|
||||
],
|
||||
failed=failures,
|
||||
**extra,
|
||||
)
|
||||
|
||||
|
||||
|
@ -7,9 +7,6 @@ class TestBatchOperations(TestService):
|
||||
comment = "this is a comment"
|
||||
delete_params = dict(can_fail=True, force=True)
|
||||
|
||||
def setUp(self, version="2.13"):
|
||||
super().setUp(version=version)
|
||||
|
||||
def test_tasks(self):
|
||||
tasks = [self._temp_task() for _ in range(2)]
|
||||
models = [
|
||||
|
Loading…
Reference in New Issue
Block a user