-
-
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. |
// TODO: Fetch provider name from DB | ||
'name' => 'llm2:tinyllama-1.1b-chat-v1.0.Q4_0:summary', |
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 only remaining part that needs to be implemented. Waiting on an answer from @marcelklehr
711a3fe
to
7e6e94a
Compare
*/ | ||
#[NoAdminRequired] | ||
#[ApiRoute(verb: 'GET', url: '/tasks/next', root: '/taskprocessing')] | ||
public function getNextScheduledTask(array $taskTypeIds): DataResponse { |
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.
this method is callable for any user and it will freely give out any scheduled tasks of other users.
Signed-off-by: provokateurin <kate@provokateurin.de>
Signed-off-by: provokateurin <kate@provokateurin.de>
7e6e94a
to
8063ff5
Compare
@@ -191,6 +194,10 @@ public function beforeController($controller, $methodName) { | |||
} | |||
} | |||
|
|||
if ($this->hasAnnotationOrAttribute($reflectionMethod, 'ExAppRequired', ExAppRequired::class) && (!$this->userSession instanceof Session || $this->userSession->getSession()->get('app_api') !== 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.
Could also not introduce the annotation (and then simply directly only check for the attribute)
@@ -191,6 +194,10 @@ public function beforeController($controller, $methodName) { | |||
} | |||
} | |||
|
|||
if ($this->hasAnnotationOrAttribute($reflectionMethod, 'ExAppRequired', ExAppRequired::class) && (!$this->userSession instanceof Session || $this->userSession->getSession()->get('app_api') !== 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.
This check needs to be changed to not needed the PublicPage attribute, as removing the ExAppRequired attribute would then completely expose the endpoint. In case ExAppRequired is set the PublicPage check can be skipped, or even better we throw an error if ExAppRequired is used together with PublicPage so there won't be a mistake later.
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.
Suggestion:
- Rename
#[ExAppRequired]
to#[ExAppRoute]
- Add check for
ExAppRoute
inif (!$this->isLoggedIn) {
at line 134
This will ensure that ExApp can call non public endpoints, and this still can be used with/without PublicPage
and not change the logic of other attributes(like SubAdminRequired).
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.
Rename
#[ExAppRequired]
to#[ExAppRoute]
I think Required
is better, as it must not allow normal users accessing it.
Add check for
ExAppRoute
inif (!$this->isLoggedIn) {
at line 134
I would put it on the outside level before:
if (!$isPublicPage) {
and make that one } elseif (!$isPublicPage) {
to ensure they are mutually exclusive
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