medcat.plugins.catalog
Management of the curated plugin catalog.
Classes:
-
CatalogModel–Pydantic model for the top-level catalog JSON.
-
NoCompatibleSpecException– -
NoSuchPluginException– -
PluginCatalog–Manages the catalog of curated plugins.
-
PluginCompatibility– -
PluginInfo– -
UnmergablePluginInfo–
Functions:
-
get_catalog–Get the global plugin catalog instance.
Attributes:
LOCAL_CATALOG_PATH
module-attribute
LOCAL_CATALOG_PATH = files('medcat.plugins.data') / 'plugin_catalog.json'
CatalogModel
Bases: BaseModel
Pydantic model for the top-level catalog JSON.
Methods:
-
merge–Merge another catalog into this one.
Attributes:
-
last_updated(str) – -
plugins(dict[str, PluginInfo]) – -
version(str) –
plugins
class-attribute
instance-attribute
plugins: dict[str, PluginInfo] = Field(default_factory=dict)
merge
merge(other: CatalogModel, prefer_other: bool = True) -> None
Merge another catalog into this one.
Parameters:
-
(otherCatalogModel) –The other catalog to merge.
-
(prefer_otherbool, default:True) –Whether to prefer other. Defaults to True.
Source code in medcat-v2/medcat/plugins/catalog.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
NoCompatibleSpecException
NoCompatibleSpecException(plugin: PluginInfo, medcat_ver: Version)
Bases: ValueError
Source code in medcat-v2/medcat/plugins/catalog.py
229 230 231 232 233 | |
NoSuchPluginException
NoSuchPluginException(plugin_name: str)
Bases: ValueError
Source code in medcat-v2/medcat/plugins/catalog.py
222 223 224 | |
PluginCatalog
PluginCatalog(use_remote: bool = True)
Manages the catalog of curated plugins.
Initialize the plugin catalog.
Parameters:
-
(use_remotebool, default:True) –Whether to attempt fetching the remote catalog
Methods:
-
get_compatible_version–Get compatible plugin version for given MedCAT version.
-
get_plugin–Get plugin info by name.
-
is_curated–Check if a plugin is in the curated catalog.
-
list_plugins–List all available plugins.
Attributes:
Source code in medcat-v2/medcat/plugins/catalog.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
REMOTE_CATALOG_URL
class-attribute
instance-attribute
REMOTE_CATALOG_URL = 'https://raw.githubusercontent.com/CogStack/cogstack-nlp/main/medcat-v2/medcat/plugins/data/plugin_catalog.json'
get_compatible_version
get_compatible_version(plugin_name: str, medcat_version: str) -> str
Get compatible plugin version for given MedCAT version.
Parameters:
Raises:
-
NoSuchPluginException–If the plugin wasn't found / known.
-
NoCompatibleSpecException–If compatibility spec was unable to be met.
Returns:
-
str–Compatible version specifier
Source code in medcat-v2/medcat/plugins/catalog.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
get_plugin
get_plugin(name: str) -> Optional[PluginInfo]
Get plugin info by name.
Source code in medcat-v2/medcat/plugins/catalog.py
158 159 160 161 162 163 164 | |
is_curated
Check if a plugin is in the curated catalog.
Source code in medcat-v2/medcat/plugins/catalog.py
171 172 173 | |
list_plugins
list_plugins() -> list[PluginInfo]
List all available plugins.
Source code in medcat-v2/medcat/plugins/catalog.py
167 168 169 | |
PluginCompatibility
PluginInfo
Bases: BaseModel
Methods:
Attributes:
-
compatibility(list[PluginCompatibility]) – -
description(str) – -
display_name(str) – -
homepage(str) – -
name(str) – -
requires_auth(bool) – -
source_spec(PluginSourceSpec) –
can_merge
can_merge(other: PluginInfo) -> bool
Checks if 2 plugin infos can be merged.
This checks to make sure the name and the source spec is the same. In that case the two objects likely refer to the same plugin. But one might have updated information.
Parameters:
-
(otherPluginInfo) –The other plugin info.
Returns:
-
bool(bool) –Whether they can be merged.
Source code in medcat-v2/medcat/plugins/catalog.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
merge
merge(other: PluginInfo, prefer_other: bool = True) -> None
Merge other plugin info into this one.
Normally it is likely the "other" plugin info is newer so we want to prefer its data if/when possible.
Parameters:
-
(otherPluginInfo) –The other plugin info.
-
(prefer_otherbool, default:True) –Whether to prefer other. Defaults to True.
Raises:
-
UnmergablePluginInfo–If the infos cannot be merged.
Source code in medcat-v2/medcat/plugins/catalog.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
UnmergablePluginInfo
UnmergablePluginInfo(info1: PluginInfo, info2: PluginInfo)
Bases: ValueError
Source code in medcat-v2/medcat/plugins/catalog.py
238 239 240 241 242 | |
get_catalog
get_catalog() -> PluginCatalog
Get the global plugin catalog instance.
Source code in medcat-v2/medcat/plugins/catalog.py
212 213 214 215 216 217 | |