medcat.utils.legacy.convert_config
Functions:
-
fix_spacy_model_name– -
get_config_from_nested_dict–Get the v2 config from v1 json data.
-
get_config_from_old–Convert the saved v1 config into a v2 Config.
-
get_config_from_old_per_cls–Convert the saved v1 config into a v2 Config for a specific class.
-
get_val_and_parent_model–Get the value and the model to set it for from the path specified.
Attributes:
-
CONFIG_KEEP_IDENTICAL– -
CONFIG_MOVE– -
CONFIG_MOVE_OPTIONAL– -
MOVE_WITH_REMOVES– -
SET_IDENTIFIER– -
logger–
CONFIG_KEEP_IDENTICAL
module-attribute
CONFIG_KEEP_IDENTICAL = {'cdb_maker', 'preprocessing'}
CONFIG_MOVE
module-attribute
CONFIG_MOVE = {'linking': 'components.linking', 'ner': 'components.ner', 'version.description': 'meta.description', 'version.id': 'meta.hash', 'version.ontology': 'meta.ontology', 'general.spacy_model': 'general.nlp.modelname', 'general.spacy_disabled_components': 'general.nlp.disabled_components'}
CONFIG_MOVE_OPTIONAL
module-attribute
CONFIG_MOVE_OPTIONAL = {'version.description', 'version.id', 'version.ontology'}
MOVE_WITH_REMOVES
module-attribute
MOVE_WITH_REMOVES = {'general': {'checkpoint', 'spacy_model', 'spacy_disabled_components', 'usage_monitor'}, 'annotation_output': {'doc_extended_info'}}
SET_IDENTIFIER
module-attribute
SET_IDENTIFIER = '==SET=='
fix_spacy_model_name
fix_spacy_model_name(cnf: Config, tokenizer: BaseTokenizer | None = None) -> None
Source code in medcat-v2/medcat/utils/legacy/convert_config.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
get_config_from_nested_dict
Get the v2 config from v1 json data.
Parameters:
-
(old_datadict) –The json (nested dict) data.
Returns:
-
Config(Config) –The v 2 config.
Source code in medcat-v2/medcat/utils/legacy/convert_config.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
get_config_from_old
Convert the saved v1 config into a v2 Config.
Parameters:
-
(pathstr) –The v1 config path.
Returns:
-
Config(Config) –The v2 config.
Source code in medcat-v2/medcat/utils/legacy/convert_config.py
192 193 194 195 196 197 198 199 200 201 202 203 | |
get_config_from_old_per_cls
get_config_from_old_per_cls(path: str, cls: Type[SerialisableBaseModel]) -> SerialisableBaseModel
Convert the saved v1 config into a v2 Config for a specific class.
Parameters:
-
(pathstr) –The v1 config path.
-
(clsType[SerialisableBaseModel]) –The class to convert to.
Returns:
-
SerialisableBaseModel(SerialisableBaseModel) –The converted config.
Source code in medcat-v2/medcat/utils/legacy/convert_config.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
get_val_and_parent_model
get_val_and_parent_model(old_data: Optional[dict], cnf: Optional[Config], path: str) -> tuple[Optional[Any], Optional[BaseModel]]
Get the value and the model to set it for from the path specified.
The paths may be specified in a .-separated manner. This unwraps that
and figures out the value in the old model and the class that should
be used in the new model.
Parameters:
-
(old_dataOptional[dict]) –The raw v1 config data.
-
(cnfOptional[Config]) –The v2 config.
-
(pathstr) –The path to look for.
Returns:
-
tuple[Optional[Any], Optional[BaseModel]]–tuple[Optional[Any], Optional[BaseModel]]: The value to set, and the model to set it for.
Source code in medcat-v2/medcat/utils/legacy/convert_config.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 | |