Skip to content

Commit

Permalink
Fixed DeprecationWarning's (#211)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Kokhan <[email protected]>
  • Loading branch information
andriy-kokhan authored Oct 4, 2023
1 parent f7641ee commit 3840d2d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/sai_client/sai_redis_client/sai_redis_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def cleanup(self):
'''
self.assert_process_running(self.port, self.server_ip, "Redis server has not started yet...")
self.r.flushall()
self.loglevel_db.hmset('syncd:syncd', {'LOGLEVEL':self.loglevel, 'LOGOUTPUT':'SYSLOG'})
self.loglevel_db.hset('syncd:syncd', mapping={'LOGLEVEL':self.loglevel, 'LOGOUTPUT':'SYSLOG'})
self.r.shutdown()
time.sleep(1)
self.assert_process_running(self.port, self.server_ip, "Redis server has not restarted yet...")
Expand Down
9 changes: 7 additions & 2 deletions common/sai_dataplane/ptf/sai_ptf_dataplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import copy
import sys
import imp
import importlib
import random
import time
import signal
Expand Down Expand Up @@ -146,6 +146,11 @@ def __logging_setup(config):

ptf.open_logfile('main')

@staticmethod
def __import_module(root_path, module_name):
module_specs = importlib.util.find_spec(module_name, [root_path])
return module_specs.loader.load_module()

def init(self):
global ptf
ptf.config.update(config_default)
Expand Down Expand Up @@ -178,7 +183,7 @@ def init(self):

platform_mod = None
try:
platform_mod = imp.load_module(platform_name, *imp.find_module(platform_name, [config["platform_dir"]]))
platform_mod = self.__import_module(config["platform_dir"], platform_name)
except:
logging.warn("Failed to import " + platform_name + " platform module")
raise
Expand Down
13 changes: 9 additions & 4 deletions common/sai_testbed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import imp
import importlib
import os
import json
import glob
Expand Down Expand Up @@ -108,6 +108,11 @@ def __init__(self, base_dir, name, with_traffic, skip_dataplane=False):
self.with_traffic = with_traffic
self.skip_dataplane = skip_dataplane

@staticmethod
def __import_module(root_path, module_name):
module_specs = importlib.util.find_spec(module_name, [root_path])
return module_specs.loader.load_module()

@staticmethod
def spawn_asic(base_dir, cfg, asic_type="npu"):
params = cfg.copy()
Expand All @@ -118,13 +123,13 @@ def spawn_asic(base_dir, cfg, asic_type="npu"):
asic_mod = None
module_name = f"sai_{asic_type}"
try:
asic_mod = imp.load_module(module_name, *imp.find_module(module_name, [asic_dir]))
asic_mod = self.__import_module(asic_dir, module_name)
except:
logging.info("No {} specific module defined..".format(params["asic"]))
try:
asic_mod = imp.load_module(module_name, *imp.find_module(module_name, [asic_dir + "/../"]))
asic_mod = self.__import_module(asic_dir + "/../", module_name)
except:
logging.warn("No NPU specific module defined.")
logging.warning("No NPU specific module defined.")

asic = None
if asic_mod is not None:
Expand Down
3 changes: 3 additions & 0 deletions dockerfiles/bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ RUN apt-get install -y nlohmann-json3-dev
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0
RUN apt-get install -y python3-paramiko

# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
RUN pip3 install --upgrade invoke>=2.2.0

# Deploy SAI Challenger
COPY common /sai-challenger/common
COPY cli /sai-challenger/cli
Expand Down
3 changes: 3 additions & 0 deletions dockerfiles/bullseye/Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ RUN if [ "$NOSNAPPI" != "y" ]; then \
pip3 install snappi==0.11.14 snappi_ixnetwork==0.9.1 ; \
fi

# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
RUN pip3 install --upgrade invoke>=2.2.0

# Install PTF dependencies
RUN pip3 install scapy dpkt

Expand Down

0 comments on commit 3840d2d

Please sign in to comment.