-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(TaskProcessingApi): Add endpoint for getting the next task #45391
base: master
Are you sure you want to change the base?
Conversation
Ah, I missed this, yes.
Yeah, let's do this manually directly in the endpoint |
5800675
to
6d86511
Compare
We need endpoint for getting nextTask by specifying multiple task_types. Or just to change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I agree with @marcelklehr that it makes more sense to change the task status to "running" in the controller method.
TheManager::getNextScheduledTask
method might be used in some context where we don't want to change to task status. -
Also, how about having a
setTaskRunning
parameter (withtrue
as default value) inTaskProcessingApiController::getNextScheduledTask
? Just in case one wants to get the next scheduled task without actually processing it. -
About requesting multiple task types in
getNextScheduledTask
, much needed indeed. @marcelklehr Would you go with another endpoint or change the current one?
I don't see a reason why you would ever need to know the next task without also running it at the same time, but I can change it if you really want 🤷♀️ |
The synchronous background job will re-schedule itself based on the fact whether there is another job waiting to be executed. |
We can add this to the current endpoint. |
711a3fe
to
7e6e94a
Compare
7e6e94a
to
8063ff5
Compare
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
Outdated
Show resolved
Hide resolved
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
Outdated
Show resolved
Hide resolved
Signed-off-by: provokateurin <kate@provokateurin.de>
Signed-off-by: provokateurin <kate@provokateurin.de>
c2caae2
to
d64aa3a
Compare
ExApp needs to call these APIs to process tasks:
more precisely, there should be two versions of getFileContents - one for the UI with cause only having those 4 endpoint ExApp can have no "system" flag to process tasks from what I see |
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The security middleware looks good now
…e.php Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Signed-off-by: Marcel Klehr <mklehr@gmx.net>
…ns with `[ExAppRequired]` Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
I didn't change the logic inside getNextScheduledTask - but it doesn't seem right to me for these reasons:
|
throw new NotFoundException(); | ||
} | ||
|
||
$task->setStatus(Task::STATUS_RUNNING); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, good point @bigcat88, this needs to be persisted
|
||
/** | ||
* Returns the next scheduled task for the taskTypeId | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | |
* | |
* It could be that a provider is looking for new tasks but the task type of the next scheduled task is actually configured to be run with a different provider |
$task = $this->taskProcessingManager->getNextScheduledTask($taskTypeIds); | ||
|
||
$provider = $this->taskProcessingManager->getPreferredProvider($task->getTaskTypeId()); | ||
if (!in_array($provider->getId(), $providerIds, true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine the task queue is as follows
1. free_prompt
2. summarize
and the configuration for the preferred providers says
free_prompt: context_chat
summarize: llm2-llama-3
Then llm2 calls this endpoint with getNextScheduledTask([free_prompt, summarize], [llm2-llama-3])
What will happen is:
- getNextScheduledTask will return the free_prompt task
- But that is configured to be run by context_chat
- So, the endpoint returns NotFoundResponse, even though there is the summarize task waiting that fulfills the requirements of the request
Summary
The ExApps need a way to get the next task.
@marcelklehr I think there is a bug as the tasks are not marked as running when the getNextScheduledTask method of the service is called (or maybe it was also intentional and the endpoint should do it manually).
Checklist