feat(TaskProcessing): Add next_task_batch endpoint#383
Merged
marcelklehr merged 3 commits intomainfrom Nov 13, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new next_task_batch endpoint method to the TaskProcessing provider API, allowing retrieval of multiple tasks at once instead of fetching them individually. This is available starting with Nextcloud 33.
Key Changes:
- Added
next_task_batchmethod to retrieve multiple task processing tasks in a single request - Method returns a dictionary containing a list of tasks and a boolean indicating if more tasks are available
- Follows similar error handling pattern as the existing
next_taskmethod
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
938553f to
b8cb9bf
Compare
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #383 +/- ##
==========================================
- Coverage 94.93% 94.79% -0.14%
==========================================
Files 45 45
Lines 5371 5381 +10
==========================================
+ Hits 5099 5101 +2
- Misses 272 280 +8
🚀 New features to boost your workflow:
|
Contributor
|
did a simple test patching the translate2 (and nc_py_api): diff --git a/lib/main.py b/lib/main.py
index c60024a..1143b9b 100644
--- a/lib/main.py
+++ b/lib/main.py
@@ -67,7 +67,7 @@ async def lifespan(_: FastAPI):
print(f"Config loaded: {json.dumps(config, indent=4)}", flush=True)
nc = NextcloudApp()
- if nc.enabled_state:
+ if not nc.enabled_state:
app_enabled.set()
if "hf_model_path" not in config["loader"] and "model_path" not in config["loader"]:
with suppress(NextcloudException):
@@ -121,6 +121,7 @@ async def _(request: Request, exc: Exception):
def task_fetch_thread(service: Service):
global app_enabled
+ return
service.load_model()
nc = NextcloudApp()
@@ -234,6 +235,16 @@ def wait_for_task(interval = None):
IDLE_POLLING_INTERVAL = IDLE_POLLING_INTERVAL_WITH_TRIGGER
TRIGGER.clear()
+@APP.get('/test-multi-fetch')
+def _():
+ nc = NextcloudApp()
+ try:
+ tasks = nc.providers.task_processing.next_task_batch([APP_ID], [TASK_TYPE_ID], 2)
+ except (NextcloudException, json.JSONDecodeError) as e:
+ logger.error("Error fetching the next task", exc_info=e)
+ print("Tasks:", tasks, flush=True)
+ return responses.JSONResponse(tasks)
+
if __name__ == "__main__":
uvicorn_log_level = ( |
kyteinsky
approved these changes
Nov 13, 2025
Contributor
kyteinsky
left a comment
There was a problem hiding this comment.
🚀
there are pre-commit issues though, seems minor, spaces left over.
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
3815249 to
1955ffb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request:
Untested.