From 2b8b134063ec387d0b1f6137ad522b8254181a0c Mon Sep 17 00:00:00 2001 From: markstur Date: Mon, 13 Nov 2023 16:22:50 -0800 Subject: [PATCH] Per-review feedback: save() code is cleaner and GUIDS are guids. * Removed some unnecessary things in save() * Lowercase module GUID for consistency Signed-off-by: markstur --- caikit_nlp/modules/text_embedding/embedding.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/caikit_nlp/modules/text_embedding/embedding.py b/caikit_nlp/modules/text_embedding/embedding.py index 91ccd128..ea415048 100644 --- a/caikit_nlp/modules/text_embedding/embedding.py +++ b/caikit_nlp/modules/text_embedding/embedding.py @@ -32,7 +32,7 @@ @module( - "EEB12558-B4FA-4F34-A9FD-3F5890E9CD3F", + "eeb12558-b4fa-4f34-a9fd-3f5890e9cd3f", "EmbeddingModule", "0.0.1", EmbeddingTask, @@ -121,22 +121,18 @@ def save(self, model_path: str, *args, **kwargs): model_config_path.strip() ) # No leading/trailing spaces sneaky weirdness + # Only allow new dirs because there are not enough controls to safely update in-place os.makedirs(model_config_path, exist_ok=False) + saver = ModuleSaver( module=self, model_path=model_config_path, ) - - # Get and update config (artifacts_path) - artifacts_path = saver.config.get(self._ARTIFACTS_PATH_KEY) - if not artifacts_path: - artifacts_path = self._ARTIFACTS_PATH_DEFAULT - saver.update_config({self._ARTIFACTS_PATH_KEY: artifacts_path}) + artifacts_path = self._ARTIFACTS_PATH_DEFAULT + saver.update_config({self._ARTIFACTS_PATH_KEY: artifacts_path}) # Save the model - self.model.save( - os.path.join(model_config_path, artifacts_path), create_model_card=True - ) + self.model.save(os.path.join(model_config_path, artifacts_path)) # Save the config ModuleConfig(saver.config).save(model_config_path)