Skip to content

feat(medcat-trainer): trainer-ee-scaffolding#524

Merged
tomolopolis merged 2 commits into
mainfrom
feat/medcat-trainer/ee-scaffold-phase-0
Jun 3, 2026
Merged

feat(medcat-trainer): trainer-ee-scaffolding#524
tomolopolis merged 2 commits into
mainfrom
feat/medcat-trainer/ee-scaffold-phase-0

Conversation

@tomolopolis
Copy link
Copy Markdown
Member

Scaffolding changes for the mct OSS project here according to the plan

Plugin scaffolding changes for TrainAnnotations ProjectAdmin and security features in mct-ee

Copy link
Copy Markdown
Collaborator

@mart-r mart-r left a comment

Choose a reason for hiding this comment

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

Overall looks good to me!

A few comments on type informations in extensions.

A question / suggestion regarding tyhe typing of permission hooks.

A note about shallow copies in extensions/plugins routes management.

A suggestion to simplify entry point discovery (no need to support python<3.9-style).

PS:
Didn't look at the frontend stuff really.

pre_document_submit = Signal()

#: Sent immediately after a document is submitted to training.
#: kwargs: ``project``, ``document``, ``user``.
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.

I guess type information is consistent with the one above, but do we perhaps want to be explicit about it?

post_document_submit = Signal()

#: Sent after an :class:`AnnotatedEntity` row is created.
#: kwargs: ``annotation`` (AnnotatedEntity), ``project``, ``document``,
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.

Here as well, type information for project and document isn't included.

annotation_created = Signal()

#: Sent after an :class:`AnnotatedEntity` row is updated.
#: kwargs: ``annotation``, ``project``, ``document``, ``user``.
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.

Again, typing not included

annotation_updated = Signal()

#: Sent after an :class:`AnnotatedEntity` row is deleted.
#: kwargs: ``annotation`` (instance prior to delete), ``project``, ``document``.
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.

Typing not included

annotation_deleted = Signal()

#: Sent after a :class:`ProjectGroup` row is created.
#: kwargs: ``project_group``.
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.

Typing not included



def get_menu_extensions() -> list[dict[str, Any]]:
return [dict(it) for it in _menu_extensions]
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.

Same note here regarding shallow copy

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

raise TypeError("route must be a dict")
if "path" not in route or "component" not in route:
raise ValueError("route requires 'path' and 'component'")
_plugin_routes.append(dict(route))
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.

Same note here regarding shallow copy

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done



def get_routes() -> list[dict[str, Any]]:
return [dict(r) for r in _plugin_routes]
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.

Same note here regarding shallow copy

try:
try:
eps = entry_points(group='mct.plugins')
except TypeError:
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.

We don't need this except clause. This would only be applicable for pre python 3.10:
https://docs.python.org/3/library/importlib.metadata.html#entry-points

3.9 (and below) are end of life, so I don't think we need to keep trying to support them.
Plus, we're running 3.12 for the image anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

# used. Hooks MUST NOT be used to deny access that the OSS code would
# otherwise grant.

PermissionHook = Callable[..., Optional[bool]]
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.

Theser have an unknown argument signature. Is there a reason not to force args User and ProjectAnnotateEntites? That's what's being passed in api.permissions.is_project_admin, right? Or is that just because the method it's used in doesn't have typing? Perhaps at the very least define as 2 arguments as [Any, Any]?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good point - have typed and limited to the two args used



def is_project_admin(user, project):
def is_project_admin(user: [User], project: [ProjectAnnotateEntities]):
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.

I don't think this is correct type annotation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ah - yep - thanks

@tomolopolis tomolopolis merged commit 9b1bf48 into main Jun 3, 2026
10 checks passed
@tomolopolis tomolopolis deleted the feat/medcat-trainer/ee-scaffold-phase-0 branch June 3, 2026 11:10
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.

2 participants