From bd6222774edcec1608a6842d0b06a637a4acef59 Mon Sep 17 00:00:00 2001 From: One Date: Wed, 9 Jul 2025 10:13:51 +0800 Subject: Release --- utils/functions.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 utils/functions.py (limited to 'utils') diff --git a/utils/functions.py b/utils/functions.py new file mode 100644 index 0000000..b123636 --- /dev/null +++ b/utils/functions.py @@ -0,0 +1,19 @@ +import importlib +import inspect + + +def load_model_class(identifier: str, prefix: str = "models."): + module_path, class_name = identifier.split('@') + + # Import the module + module = importlib.import_module(prefix + module_path) + cls = getattr(module, class_name) + + return cls + + +def get_model_source_path(identifier: str, prefix: str = "models."): + module_path, class_name = identifier.split('@') + + module = importlib.import_module(prefix + module_path) + return inspect.getsourcefile(module) -- cgit v1.2.3