Repository: caikit/caikit
Pull request #222 (2023-06-12 19:07:31)

fix for old-style workflow id
Closes https://github.com/caikit/caikit/issues/216


Patch:
diff --git a/caikit/core/modules/config.py b/caikit/core/modules/config.py
index 309be417..cc8e5cb6 100644
--- a/caikit/core/modules/config.py
+++ b/caikit/core/modules/config.py
@@ -14,7 +14,6 @@
 
 # Standard
 import os
-import warnings
 
 # First Party
 import aconfig
@@ -63,16 +62,15 @@ class ModuleConfig(aconfig.Config):
 
         # 🌶️🌶️🌶️: Backwards compatibility for old-style `blocks`, `workflows`, and `resources`
         if not self.module_id:  # pylint: disable=access-member-before-definition
-            warnings.warn(
-                "No module_id found in config. Re-save the block to use module_id",
-                DeprecationWarning,
-            )  # actual warning or just log.warning?
+            log.warning(
+                "No module_id found in config. Re-save the model to use module_id."
+            )
             if self.block_id:
                 log.debug("Detected legacy block_id in config")
                 self.module_id = self.block_id
             elif self.workflow_id:
                 log.debug("Detected legacy workflow_id in config")
-                self.module_id = self.block_id
+                self.module_id = self.workflow_id
             elif self.resource_id:
                 log.debug("Detected legacy resource_id in config")
                 self.module_id = self.resource_id


Test patch:
diff --git a/tests/core/modules/test_module.py b/tests/core/modules/test_module.py
index 2c930520..0b5e6233 100644
--- a/tests/core/modules/test_module.py
+++ b/tests/core/modules/test_module.py
@@ -174,6 +174,29 @@ def test_init_and_members():
     assert config.nested.float == -0.123
 
 
+def test_backwards_compatibility_for_block():
+    config = ModuleConfig({"block_id": "123"})
+    assert config.module_id == "123"
+
+
+def test_backwards_compatibility_for_workflow():
+    config = ModuleConfig(
+        {
+            "workflow_id": "456",
+        }
+    )
+    assert config.module_id == "456"
+
+
+def test_backwards_compatibility_for_resource():
+    config = ModuleConfig(
+        {
+            "resource_id": "789",
+        }
+    )
+    assert config.module_id == "789"
+
+
 def test_reserved_keys():
     for reserved_key in ("model_path",):
         with pytest.raises(KeyError):
diff --git a/tests/core/test_model_manager.py b/tests/core/test_model_manager.py
index ec94a8ee..a3bba692 100644
--- a/tests/core/test_model_manager.py
+++ b/tests/core/test_model_manager.py
@@ -176,13 +176,10 @@ class TestModelManager(TestCaseBase):
         from caikit.core.model_manager import module_registry  # isort: skip
 
     def test_load_model_with_no_module_id(self):
-        """Test that we can load a module with the legacy block_id instead of module_id, and that
-        a DeprecationWarning is raised.
-        """
+        """Test that we can load a module with the legacy block_id instead of module_id"""
         model_path = os.path.join(self.fixtures_dir, DUMMY_NO_ID_MODEL_NAME)
-        with pytest.deprecated_call():
-            model = caikit.core.load(model_path)
-            self.assertIsInstance(model, caikit.core.ModuleBase)
+        model = caikit.core.load(model_path)
+        self.assertIsInstance(model, caikit.core.ModuleBase)
 
 
 # Pytest tests #########################################################