@@ -1042,31 +1042,6 @@ def create_custom_component(self, model: Any, config: Config, **kwargs: Any) ->
1042
1042
}
1043
1043
return custom_component_class (** kwargs )
1044
1044
1045
- @staticmethod
1046
- def _get_components_module_object (
1047
- config : Config ,
1048
- ) -> types .ModuleType :
1049
- """Get a components module object based on the provided config.
1050
-
1051
- If custom python components is provided, this will be loaded. Otherwise, we will
1052
- attempt to load from the `components` module already imported.
1053
- """
1054
- INJECTED_COMPONENTS_PY = "__injected_components_py"
1055
- COMPONENTS_MODULE_NAME = "components"
1056
-
1057
- components_module : types .ModuleType
1058
- if not INJECTED_COMPONENTS_PY in config :
1059
- raise ValueError (
1060
- "Custom components must be defined in a module named `components`. Please provide a custom components module."
1061
- )
1062
-
1063
- # Create a new module object and execute the provided Python code text within it
1064
- components_module = types .ModuleType (name = COMPONENTS_MODULE_NAME )
1065
- python_text = config [INJECTED_COMPONENTS_PY ]
1066
- exec (python_text , components_module .__dict__ )
1067
- sys .modules [COMPONENTS_MODULE_NAME ] = components_module
1068
- return components_module
1069
-
1070
1045
@staticmethod
1071
1046
def _get_class_from_fully_qualified_class_name (
1072
1047
full_qualified_class_name : str ,
@@ -1106,6 +1081,31 @@ def _get_class_from_fully_qualified_class_name(
1106
1081
except (AttributeError , ModuleNotFoundError ) as e :
1107
1082
raise ValueError (f"Could not load class { full_qualified_class_name } ." ) from e
1108
1083
1084
+ @staticmethod
1085
+ def _get_components_module_object (
1086
+ config : Config ,
1087
+ ) -> types .ModuleType :
1088
+ """Get a components module object based on the provided config.
1089
+
1090
+ If custom python components is provided, this will be loaded. Otherwise, we will
1091
+ attempt to load from the `components` module already imported.
1092
+ """
1093
+ INJECTED_COMPONENTS_PY = "__injected_components_py"
1094
+ COMPONENTS_MODULE_NAME = "components"
1095
+
1096
+ components_module : types .ModuleType
1097
+ if not INJECTED_COMPONENTS_PY in config :
1098
+ raise ValueError (
1099
+ "Custom components must be defined in a module named `components`. Please provide a custom components module."
1100
+ )
1101
+
1102
+ # Create a new module object and execute the provided Python code text within it
1103
+ components_module = types .ModuleType (name = COMPONENTS_MODULE_NAME )
1104
+ python_text = config [INJECTED_COMPONENTS_PY ]
1105
+ exec (python_text , components_module .__dict__ )
1106
+ sys .modules [COMPONENTS_MODULE_NAME ] = components_module
1107
+ return components_module
1108
+
1109
1109
@staticmethod
1110
1110
def _derive_component_type_from_type_hints (field_type : Any ) -> Optional [str ]:
1111
1111
interface = field_type
0 commit comments