Repository navigation
Run a MedCAT model over a project dataset - #659
Open
tomolopolis wants to merge 1 commit into
Open
tomolopolis wants to merge 1 commit into
tomolopolis wants to merge 1 commit into
Conversation
Expose the project-list Run action as POST /api/run-model/ and add a client method so a configured project can be annotated by its model without using the UI. Background runs use the existing doc_prep worker; small datasets can run inside the request. Co-authored-by: tomolopolis <tomolopolis@users.noreply.github.com>
mart-r
approved these changes
Nov 2, 2026
mart-r
left a comment
Collaborator
There was a problem hiding this comment.
Quite a bit more to it than I would have thought.
But looks good overall.
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.
Summary
The project list Run button already queued background document preparation, but nothing in the API client could do that after a project was created. This adds a stable run-model API and a matching
mctclientmethod.POST /api/run-model/queues the project model over dataset documents that still need predictions.background: falseruns that work inside the request.GET /api/run-model/<project_id>/reports progress.DELETEstops a queued run./api/prepare-documents-bg/and/api/prep-docs-bg-tasks/paths call the same handlers, so the project list Run button keeps working.MedCATTrainerSession.run_model()starts a run from a project object, id, or name.wait=Truepolls until theprocess_tasksworker finishes.Documents that already have annotations, have been submitted, or have already been prepared are left unchanged.
Testing
python -m unittest tests.test_mctclient(client)python manage.py test api.tests.test_run_model api.tests.test_views(trainer API)