diff --git a/common/sai_testbed.py b/common/sai_testbed.py index e2d27cab..c4aaac62 100644 --- a/common/sai_testbed.py +++ b/common/sai_testbed.py @@ -110,7 +110,7 @@ def __init__(self, base_dir, name, with_traffic, skip_dataplane=False): @staticmethod def __import_module(root_path, module_name): - module_specs = importlib.util.find_spec(module_name, [root_path]) + module_specs = importlib.util.spec_from_file_location(module_name, os.path.join(root_path, f"{module_name}.py")) return module_specs.loader.load_module() @staticmethod @@ -123,11 +123,11 @@ def spawn_asic(base_dir, cfg, asic_type="npu"): asic_mod = None module_name = f"sai_{asic_type}" try: - asic_mod = self.__import_module(asic_dir, module_name) + asic_mod = SaiTestbed.__import_module(asic_dir, module_name) except: logging.info("No {} specific module defined..".format(params["asic"])) try: - asic_mod = self.__import_module(asic_dir + "/../", module_name) + asic_mod = SaiTestbed.__import_module(asic_dir + "/../", module_name) except: logging.warning("No NPU specific module defined.")