@@ -210,8 +210,12 @@ def get_model_card(self, as_dict: bool = False):
210
210
else :
211
211
return json .dumps (card , indent = 2 , sort_keys = False )
212
212
213
- def _versioning (self , force_rehash : bool = False ):
213
+ def _versioning (self , force_rehash : bool = False ,
214
+ change_description : Optional [str ] = None ):
214
215
# Check version info and do not allow without it
216
+ date_today = date .today ().strftime ("%d %B %Y" )
217
+ if change_description is not None :
218
+ self .config .version .description += f"\n [{ date_today } ] { change_description } "
215
219
if self .config .version .description == 'No description' :
216
220
logger .warning ("Please consider populating the version information [description, performance, location, ontology] in cat.config.version" )
217
221
@@ -222,14 +226,17 @@ def _versioning(self, force_rehash: bool = False):
222
226
if version .id is not None :
223
227
version .history .append (version ['id' ])
224
228
version .id = m
225
- version .last_modified = date . today (). strftime ( "%d %B %Y" )
229
+ version .last_modified = date_today
226
230
version .cdb_info = self .cdb .make_stats ()
227
231
version .meta_cats = [meta_cat .get_model_card (as_dict = True ) for meta_cat in self ._meta_cats ]
228
232
version .medcat_version = __version__
229
233
logger .warning ("Please consider updating [description, performance, location, ontology] in cat.config.version" )
230
234
231
- def create_model_pack (self , save_dir_path : str , model_pack_name : str = DEFAULT_MODEL_PACK_NAME , force_rehash : bool = False ,
232
- cdb_format : str = 'dill' ) -> str :
235
+ def create_model_pack (self , save_dir_path : str ,
236
+ model_pack_name : str = DEFAULT_MODEL_PACK_NAME ,
237
+ force_rehash : bool = False ,
238
+ change_description : Optional [str ] = None ,
239
+ cdb_format : str = 'dill' ) -> str :
233
240
"""Will crete a .zip file containing all the models in the current running instance
234
241
of MedCAT. This is not the most efficient way, for sure, but good enough for now.
235
242
@@ -240,6 +247,8 @@ def create_model_pack(self, save_dir_path: str, model_pack_name: str = DEFAULT_M
240
247
The model pack name. Defaults to DEFAULT_MODEL_PACK_NAME.
241
248
force_rehash (bool):
242
249
Force recalculation of hash. Defaults to `False`.
250
+ change_description (Optional[str]):
251
+ The description of the change due to which a save is required. Defaults to None.
243
252
cdb_format (str):
244
253
The format of the saved CDB in the model pack.
245
254
The available formats are:
@@ -254,7 +263,7 @@ def create_model_pack(self, save_dir_path: str, model_pack_name: str = DEFAULT_M
254
263
# Spacy model always should be just the name, but during loading it can be reset to path
255
264
self .config .general .spacy_model = os .path .basename (self .config .general .spacy_model )
256
265
# Versioning
257
- self ._versioning (force_rehash )
266
+ self ._versioning (force_rehash , change_description )
258
267
model_pack_name += "_{}" .format (self .config .version .id )
259
268
260
269
logger .warning ("This will save all models into a zip file, can take some time and require quite a bit of disk space." )
0 commit comments