Skip to content

Run a MedCAT model over a project dataset - #659

Open
tomolopolis wants to merge 1 commit into
mainfrom
cursor/run-model-over-dataset-e648
Open

tomolopolis wants to merge 1 commit into
mainfrom
cursor/run-model-over-dataset-e648

Conversation

@tomolopolis

Copy link
Copy Markdown
Member

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 mctclient method.

  • POST /api/run-model/ queues the project model over dataset documents that still need predictions. background: false runs that work inside the request.
  • GET /api/run-model/<project_id>/ reports progress. DELETE stops a queued run.
  • The existing /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=True polls until the process_tasks worker 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)
Open in Web Open in Cursor 

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 mart-r left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Quite a bit more to it than I would have thought.

But looks good overall.

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