Skip to content

Commit 7e14ef7

Browse files
Fixed "DeprecationWarning: the load_module()" (#253)
Signed-off-by: Andriy Kokhan <andriy.kokhan@plvision.eu>
1 parent b323dd1 commit 7e14ef7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

common/sai_dataplane/ptf/sai_ptf_dataplane.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ def __logging_setup(config):
149149
@staticmethod
150150
def __import_module(root_path, module_name):
151151
module_specs = importlib.util.find_spec(module_name, [root_path])
152-
return module_specs.loader.load_module()
152+
module = importlib.util.module_from_spec(module_specs)
153+
sys.modules[module_name] = module
154+
module_specs.loader.exec_module(module)
155+
return module
153156

154157
def init(self):
155158
global ptf

common/sai_testbed.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import glob
55
import logging
6+
import sys
67

78
from saichallenger.common.sai_dut import SaiDut
89
from saichallenger.common.sai_npu import SaiNpu
@@ -111,7 +112,10 @@ def __init__(self, base_dir, name, with_traffic, skip_dataplane=False):
111112
@staticmethod
112113
def import_module(root_path, module_name):
113114
module_specs = importlib.util.spec_from_file_location(module_name, os.path.join(root_path, f"{module_name}.py"))
114-
return module_specs.loader.load_module()
115+
module = importlib.util.module_from_spec(module_specs)
116+
sys.modules[module_name] = module
117+
module_specs.loader.exec_module(module)
118+
return module
115119

116120
@staticmethod
117121
def spawn_asic(base_dir, cfg, asic_type="npu"):

0 commit comments

Comments
 (0)