-
Notifications
You must be signed in to change notification settings - Fork 11
feat(TaskProcessing): Add next_task_batch endpoint #383
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
Conversation
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.
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:
|
|
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
left a comment
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.
🚀
there are pre-commit issues though, seems minor, spaces left over.
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
3815249 to
1955ffb
Compare
Changes proposed in this pull request:
Untested.