Skip to content

Conversation

@marcelklehr
Copy link
Contributor

@marcelklehr marcelklehr commented Nov 13, 2025

Changes proposed in this pull request:

Untested.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_batch method 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_task method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.79%. Comparing base (d2eb66a) to head (1955ffb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
nc_py_api/ex_app/providers/task_processing.py 20.00% 8 Missing ⚠️
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     
Files with missing lines Coverage Δ
nc_py_api/ex_app/providers/task_processing.py 90.00% <20.00%> (-5.00%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kyteinsky
Copy link
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 = (

Copy link
Contributor

@kyteinsky kyteinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

there are pre-commit issues though, seems minor, spaces left over.

Signed-off-by: Marcel Klehr <[email protected]>
@marcelklehr marcelklehr enabled auto-merge (squash) November 13, 2025 12:14
@marcelklehr marcelklehr merged commit 7a374e5 into main Nov 13, 2025
12 checks passed
@marcelklehr marcelklehr deleted the enh/next_task_batch branch November 13, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants