Skip to content

Commit 3840d2d

Browse files
Fixed DeprecationWarning's (#211)
Signed-off-by: Andriy Kokhan <andriy.kokhan@plvision.eu>
1 parent f7641ee commit 3840d2d

5 files changed

Lines changed: 23 additions & 7 deletions

File tree

common/sai_client/sai_redis_client/sai_redis_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def cleanup(self):
5353
'''
5454
self.assert_process_running(self.port, self.server_ip, "Redis server has not started yet...")
5555
self.r.flushall()
56-
self.loglevel_db.hmset('syncd:syncd', {'LOGLEVEL':self.loglevel, 'LOGOUTPUT':'SYSLOG'})
56+
self.loglevel_db.hset('syncd:syncd', mapping={'LOGLEVEL':self.loglevel, 'LOGOUTPUT':'SYSLOG'})
5757
self.r.shutdown()
5858
time.sleep(1)
5959
self.assert_process_running(self.port, self.server_ip, "Redis server has not restarted yet...")

common/sai_dataplane/ptf/sai_ptf_dataplane.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import copy
77
import sys
8-
import imp
8+
import importlib
99
import random
1010
import time
1111
import signal
@@ -146,6 +146,11 @@ def __logging_setup(config):
146146

147147
ptf.open_logfile('main')
148148

149+
@staticmethod
150+
def __import_module(root_path, module_name):
151+
module_specs = importlib.util.find_spec(module_name, [root_path])
152+
return module_specs.loader.load_module()
153+
149154
def init(self):
150155
global ptf
151156
ptf.config.update(config_default)
@@ -178,7 +183,7 @@ def init(self):
178183

179184
platform_mod = None
180185
try:
181-
platform_mod = imp.load_module(platform_name, *imp.find_module(platform_name, [config["platform_dir"]]))
186+
platform_mod = self.__import_module(config["platform_dir"], platform_name)
182187
except:
183188
logging.warn("Failed to import " + platform_name + " platform module")
184189
raise

common/sai_testbed.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import imp
1+
import importlib
22
import os
33
import json
44
import glob
@@ -108,6 +108,11 @@ def __init__(self, base_dir, name, with_traffic, skip_dataplane=False):
108108
self.with_traffic = with_traffic
109109
self.skip_dataplane = skip_dataplane
110110

111+
@staticmethod
112+
def __import_module(root_path, module_name):
113+
module_specs = importlib.util.find_spec(module_name, [root_path])
114+
return module_specs.loader.load_module()
115+
111116
@staticmethod
112117
def spawn_asic(base_dir, cfg, asic_type="npu"):
113118
params = cfg.copy()
@@ -118,13 +123,13 @@ def spawn_asic(base_dir, cfg, asic_type="npu"):
118123
asic_mod = None
119124
module_name = f"sai_{asic_type}"
120125
try:
121-
asic_mod = imp.load_module(module_name, *imp.find_module(module_name, [asic_dir]))
126+
asic_mod = self.__import_module(asic_dir, module_name)
122127
except:
123128
logging.info("No {} specific module defined..".format(params["asic"]))
124129
try:
125-
asic_mod = imp.load_module(module_name, *imp.find_module(module_name, [asic_dir + "/../"]))
130+
asic_mod = self.__import_module(asic_dir + "/../", module_name)
126131
except:
127-
logging.warn("No NPU specific module defined.")
132+
logging.warning("No NPU specific module defined.")
128133

129134
asic = None
130135
if asic_mod is not None:

dockerfiles/bullseye/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ RUN apt-get install -y nlohmann-json3-dev
104104
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0
105105
RUN apt-get install -y python3-paramiko
106106

107+
# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
108+
RUN pip3 install --upgrade invoke>=2.2.0
109+
107110
# Deploy SAI Challenger
108111
COPY common /sai-challenger/common
109112
COPY cli /sai-challenger/cli

dockerfiles/bullseye/Dockerfile.client

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ RUN if [ "$NOSNAPPI" != "y" ]; then \
6565
pip3 install snappi==0.11.14 snappi_ixnetwork==0.9.1 ; \
6666
fi
6767

68+
# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
69+
RUN pip3 install --upgrade invoke>=2.2.0
70+
6871
# Install PTF dependencies
6972
RUN pip3 install scapy dpkt
7073

0 commit comments

Comments
 (0)