address pyright syntax errors
This commit is contained in:
parent
f467dc9b04
commit
5e2b3c2e59
1 changed files with 4 additions and 0 deletions
|
|
@ -29,6 +29,10 @@ def load_class(model_file, model_name):
|
||||||
"""Dynamically load a class from a file."""
|
"""Dynamically load a class from a file."""
|
||||||
model_file = os.path.abspath(model_file)
|
model_file = os.path.abspath(model_file)
|
||||||
spec = importlib.util.spec_from_file_location("graph_model", model_file)
|
spec = importlib.util.spec_from_file_location("graph_model", model_file)
|
||||||
|
if spec is None:
|
||||||
|
raise ValueError(f"Could not load specification for module from file: {model_file}")
|
||||||
|
if spec.loader is None:
|
||||||
|
raise ImportError(f"Spec loader is None for module file: {model_file}")
|
||||||
module = importlib.util.module_from_spec(spec)
|
module = importlib.util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(module)
|
spec.loader.exec_module(module)
|
||||||
model_class = getattr(module, model_name)
|
model_class = getattr(module, model_name)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue