Unable to save model from trainer

I’m getting the below error (AttributeError: 'NoneType' object has no attribute 'cdb_file') when attemping to save a model from “Save Model” button on the MedCAT trainer landing page, following a bunch of submitted annotations (with “train on submit” enabled via admin).

This was incremental training of the v2_Snomed2025 publicly available MedCATv2 model. I can see a cdb in the admin page (/home/api/media/v2_Snomed2025_MIMIC_IV_bbe806e192df009f_9Xv5lF5/cdb), so I wouldn’t expect this to be an issue?

Any suggestions for debugging would be welcome, thank you!

medcat v2.6.0, trainer image built from source.

nginx-1          | 172.18.0.1 - - [02/Apr/2026:15:24:05 +0000] "POST /api/save-models/ HTTP/1.1" 500 91672 "http://localhost:8001/" ""


medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/rest_framework/views.py", line 486, in raise_uncaught_exception
medcattrainer-1  | [medcattrainer]     raise exc
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/rest_framework/views.py", line 512, in dispatch
medcattrainer-1  | [medcattrainer]     response = handler(request, *args, **kwargs)
medcattrainer-1  | [medcattrainer]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/rest_framework/decorators.py", line 50, in handler
medcattrainer-1  | [medcattrainer]     return func(*args, **kwargs)
medcattrainer-1  | [medcattrainer]            ^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/api/api/views.py", line 566, in save_models
medcattrainer-1  | [medcattrainer]     cat.cdb.save(project.concept_db.cdb_file.path)
medcattrainer-1  | [medcattrainer]                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer] AttributeError: 'NoneType' object has no attribute 'cdb_file'
medcattrainer-1  | [medcattrainer] ERROR 2026-04-02 15:24:05,131 log.py l:253:Internal Server Error: /api/save-models/
medcattrainer-1  | [medcattrainer] Traceback (most recent call last):
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
medcattrainer-1  | [medcattrainer]     response = get_response(request)
medcattrainer-1  | [medcattrainer]                ^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
medcattrainer-1  | [medcattrainer]     response = wrapped_callback(request, *callback_args, **callback_kwargs)
medcattrainer-1  | [medcattrainer]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
medcattrainer-1  | [medcattrainer]     return view_func(request, *args, **kwargs)
medcattrainer-1  | [medcattrainer]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/django/views/generic/base.py", line 105, in view
medcattrainer-1  | [medcattrainer]     return self.dispatch(request, *args, **kwargs)
medcattrainer-1  | [medcattrainer]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/rest_framework/views.py", line 515, in dispatch
medcattrainer-1  | [medcattrainer]     response = self.handle_exception(exc)
medcattrainer-1  | [medcattrainer]                ^^^^^^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/rest_framework/views.py", line 475, in handle_exception
medcattrainer-1  | [medcattrainer]     self.raise_uncaught_exception(exc)
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/rest_framework/views.py", line 486, in raise_uncaught_exception
medcattrainer-1  | [medcattrainer]     raise exc
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/rest_framework/views.py", line 512, in dispatch
medcattrainer-1  | [medcattrainer]     response = handler(request, *args, **kwargs)
medcattrainer-1  | [medcattrainer]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/.venv/lib/python3.12/site-packages/rest_framework/decorators.py", line 50, in handler
medcattrainer-1  | [medcattrainer]     return func(*args, **kwargs)
medcattrainer-1  | [medcattrainer]            ^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer]   File "/home/api/api/views.py", line 566, in save_models
medcattrainer-1  | [medcattrainer]     cat.cdb.save(project.concept_db.cdb_file.path)
medcattrainer-1  | [medcattrainer]                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
medcattrainer-1  | [medcattrainer] AttributeError: 'NoneType' object has no attribute 'cdb_file'

Hi!

Sorry for the delayed response. Long holidays and all that.

I’ve managed to replicate the issue on our side as well. So the good news is that it’s not an issue on your side specifically.

Before going on to describing why this happens, I’ll suggest a workaround (at least for now):
Instead of having the trainer do the training, use the admin panel to download the trainer export (under Project annotate entities) and do the fine-tuning outside of trainer.

As for the issue at hand. I’m pretty sure this is an issue with old CDB/Vocab based model usage (which is largely deprecated now). Because just a single model pack is used instead, the concept_db is empty (None) for projects created with a model pack instead. However - clearly - the change to use model packs insteads hasn’t fully been implemented here.

PS: If you did in fact use separate CDB / Vocab for this model instead of a model pack, do let me know (I doubt it). That would make this a more difficult issue to debug.

We’ll try to fix this in the near future. Thanks for bringing this to our attention!

Thanks for such a quick response, I’ve exported (thanks for pointing me towards the admin action) and now the model is happily tagging new concepts - was wondering why this wasn’t starting to work in the GUI training loop.

I’m glad my proposed workaround worked for you.

Though - somewhat obviously - it’s not a good workaround, especially for situations where you might need to do this multiple times manually.

There is a PR up already that should fix the underlying issue:

But I can’t promise a release window with the fix, I’m afrair. Though if you’re building from source, you’re welcome to do so based on that branch. But with the caveat that this PR hasn’t been merged in (i.e hasn’t been reviewed by others on the team).