Skip to content

feat(medcat-trainer): Avoid loading meta cat upon model pack upload#567

Merged
mart-r merged 19 commits into
mainfrom
feat/medcat-trainer/avoid-loading-meta-cat-upon-model-pack-upload
Jun 25, 2026
Merged

feat(medcat-trainer): Avoid loading meta cat upon model pack upload#567
mart-r merged 19 commits into
mainfrom
feat/medcat-trainer/avoid-loading-meta-cat-upon-model-pack-upload

Conversation

@mart-r

@mart-r mart-r commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

This PR allows model packs with MetaCATs (and other addons) to be uploaded without the need to load all these addons.

The reason they were previously loaded (though notably addons other than MetaCAT weren't used) was to get some information for meta tasks.

In an ideal world, we'd have all the sufficient information saved in the model card. But alas, we don't.

So what this PR does is load the model pack's config (only) and gets the relevant information from there.

This should save a considerable amount of time (and memory) since loading all these addons (in an ephemral way, no less) can consume a lot of resources and loading just the (admittedly dill-serialised) json should be a lot leaner.

NB! Limitations:
This is currently hard-coded to dill serialisations of the model pack. While this is currently the only serialisation we provide, this does create tight coupling. So we may need to review this in the future.

@alhendrickson alhendrickson 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.

lgtm, should really speed it up

@tomolopolis tomolopolis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

small comments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

generally dislike the term 'fake' model. either use dummy or example? fake personally sounds like its not a test or perhaps not a model at all, when in fact it is both a real model and even a real model on disk by the looks of it.

with patch.object(MetaCATAddon, "__init__") as mock_init:
import_model_pack(
MODEL_PATH,
name='fake-test-model',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just test-model is fine

@tomolopolis

Copy link
Copy Markdown
Member

Lgtm

@mart-r mart-r merged commit faa54b5 into main Jun 25, 2026
11 checks passed
@mart-r mart-r deleted the feat/medcat-trainer/avoid-loading-meta-cat-upon-model-pack-upload branch June 25, 2026 12:34
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