Skip to content

Commit

Permalink
Fix import asic module issue. (#240)
Browse files Browse the repository at this point in the history
Signed-off-by: xuyinhao <[email protected]>
  • Loading branch information
xuyinhao authored Oct 30, 2024
1 parent f249b33 commit 2c165e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/sai_testbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")

Expand Down

0 comments on commit 2c165e5

Please sign in to comment.