Skip to content

Commit

Permalink
Fixed DeprecationWarning's
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Kokhan <andriy.kokhan@plvision.eu>
  • Loading branch information
andriy-kokhan committed Oct 4, 2023
1 parent 9fbc878 commit 1d690c9
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 13 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
4 changes: 2 additions & 2 deletions dockerfiles/buster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
supervisor

# Add support for supervisord to handle startup dependencies
RUN pip3 install supervisord-dependent-startup==1.4.0
RUN pip3 install supervisord-dependent-startup==1.4.0 redis>=3.5.0

# Install dependencies
RUN apt-get install -y redis-server libhiredis0.14 python3-redis libc-ares2
RUN apt-get install -y redis-server libhiredis0.14 libc-ares2

# Install sonic-swss-common & sonic-sairedis building dependencies
RUN apt-get install -y \
Expand Down
3 changes: 1 addition & 2 deletions dockerfiles/buster/Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
build-essential \
python3 \
python3-pip \
python3-redis \
iproute2 \
rsyslog \
supervisor \
Expand Down Expand Up @@ -64,7 +63,7 @@ RUN git clone https://github.com/opencomputeproject/SAI.git \
&& rm -rf /sai/SAI

# Install SAI-C dependencies
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0 redis>=3.5.0

ARG NOSNAPPI
RUN if [ "$NOSNAPPI" != "y" ]; then \
Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/buster/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
supervisor

# Add support for supervisord to handle startup dependencies
RUN pip3 install supervisord-dependent-startup==1.4.0
RUN pip3 install supervisord-dependent-startup==1.4.0 redis>=3.5.0

# Install dependencies
RUN apt-get install -y redis-server libhiredis0.14 python3-redis libc-ares2
RUN apt-get install -y redis-server libhiredis0.14 libc-ares2

# Install sonic-swss-common & sonic-sairedis building dependencies
RUN apt-get install -y \
Expand Down

0 comments on commit 1d690c9

Please sign in to comment.