提交 3b90e67e 编写于 作者: M malin10

test=develop, rm netifaces

上级 d20349b5
...@@ -207,7 +207,6 @@ RUN wget --no-check-certificate https://pslib.bj.bcebos.com/openmpi-1.4.5.tar.gz ...@@ -207,7 +207,6 @@ RUN wget --no-check-certificate https://pslib.bj.bcebos.com/openmpi-1.4.5.tar.gz
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH && export PATH=/usr/local/bin:$PATH && cd .. && \ export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH && export PATH=/usr/local/bin:$PATH && cd .. && \
rm -rf openmpi-1.4.5.tar.gz && pip --no-cache-dir install mpi4py && ln -fs /bin/bash /bin/sh && \ rm -rf openmpi-1.4.5.tar.gz && pip --no-cache-dir install mpi4py && ln -fs /bin/bash /bin/sh && \
apt-get install libprotobuf-dev -y apt-get install libprotobuf-dev -y
RUN pip --no-cache-dir install -U netifaces==0.10.9
# Older versions of patchelf limited the size of the files being processed and were fixed in this pr. # Older versions of patchelf limited the size of the files being processed and were fixed in this pr.
# https://github.com/NixOS/patchelf/commit/ba2695a8110abbc8cc6baf0eea819922ee5007fa # https://github.com/NixOS/patchelf/commit/ba2695a8110abbc8cc6baf0eea819922ee5007fa
......
...@@ -254,26 +254,33 @@ class Gloo(object): ...@@ -254,26 +254,33 @@ class Gloo(object):
""" """
get default physical interface get default physical interface
""" """
import netifaces res = os.popen("route -A inet").read().strip().split("\n")
gateways = netifaces.gateways()
if gateways.get(netifaces.AF_INET) != None: gateway_idx = None
gateway = gateways[netifaces.AF_INET] iface_idx = None
if len(gateway) > 0 and len(gateway[0]) > 1: for item in res:
return gateway[0][1] item = item.split()
if "Gateway" in item and "Iface" in item:
gateway_idx = item.index("Gateway")
iface_idx = item.index("Iface")
elif gateway_idx != None and iface_idx != None:
gateway = None
if len(item) > gateway_idx:
gateway = item[gateway_idx]
if gateway and gateway != '*' and gateway != "0.0.0.0" and len(
item) > iface_idx:
return item[iface_idx]
return "lo" return "lo"
def __get_default_iface_from_interfaces(self): def __get_default_iface_from_interfaces(self):
""" """
get default physical interface get default physical interface
""" """
import netifaces res = os.popen("ip -f inet addr | awk NR%3==1").read().strip().split(
for intf_name in netifaces.interfaces(): "\n")
addresses = netifaces.ifaddresses(intf_name) for item in res:
if netifaces.AF_INET in addresses: if "BROADCAST" in item:
ipv4_addresses = addresses[netifaces.AF_INET] return item.split(":")[1].strip()
for ipv4_address in ipv4_addresses:
if 'broadcast' in ipv4_address:
return intf_name
return "lo" return "lo"
def barrier(self, comm_world): def barrier(self, comm_world):
......
...@@ -955,26 +955,33 @@ class GeneralRoleMaker(RoleMakerBase): ...@@ -955,26 +955,33 @@ class GeneralRoleMaker(RoleMakerBase):
""" """
get default physical interface get default physical interface
""" """
import netifaces res = os.popen("route -A inet").read().strip().split("\n")
gateways = netifaces.gateways()
if gateways.get(netifaces.AF_INET) != None: gateway_idx = None
gateway = gateways[netifaces.AF_INET] iface_idx = None
if len(gateway) > 0 and len(gateway[0]) > 1: for item in res:
return gateway[0][1] item = item.split()
if "Gateway" in item and "Iface" in item:
gateway_idx = item.index("Gateway")
iface_idx = item.index("Iface")
elif gateway_idx != None and iface_idx != None:
gateway = None
if len(item) > gateway_idx:
gateway = item[gateway_idx]
if gateway and gateway != '*' and gateway != "0.0.0.0" and len(
item) > iface_idx:
return item[iface_idx]
return "lo" return "lo"
def __get_default_iface_from_interfaces(self): def __get_default_iface_from_interfaces(self):
""" """
get default physical interface get default physical interface
""" """
import netifaces res = os.popen("ip -f inet addr | awk NR%3==1").read().strip().split(
for intf_name in netifaces.interfaces(): "\n")
addresses = netifaces.ifaddresses(intf_name) for item in res:
if netifaces.AF_INET in addresses: if "BROADCAST" in item:
ipv4_addresses = addresses[netifaces.AF_INET] return item.split(":")[1].strip()
for ipv4_address in ipv4_addresses:
if 'broadcast' in ipv4_address:
return intf_name
return "lo" return "lo"
def __start_kv_server(self, http_server_d, size_d): def __start_kv_server(self, http_server_d, size_d):
......
...@@ -37,11 +37,7 @@ class TestFleet1(unittest.TestCase): ...@@ -37,11 +37,7 @@ class TestFleet1(unittest.TestCase):
from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet
from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib
from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker
try:
import netifaces
except:
print("warning: no netifaces, skip test_pslib_1")
return
os.environ["POD_IP"] = "127.0.0.1" os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001" os.environ["PADDLE_PORT"] = "36001"
os.environ["TRAINING_ROLE"] = "TRAINER" os.environ["TRAINING_ROLE"] = "TRAINER"
......
...@@ -36,11 +36,7 @@ class TestFleet1(unittest.TestCase): ...@@ -36,11 +36,7 @@ class TestFleet1(unittest.TestCase):
from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet
from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib
from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker
try:
import netifaces
except:
print("warning: no netifaces, skip test_pslib_1")
return
os.environ["POD_IP"] = "127.0.0.1" os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001" os.environ["PADDLE_PORT"] = "36001"
os.environ["TRAINING_ROLE"] = "TRAINER" os.environ["TRAINING_ROLE"] = "TRAINER"
......
...@@ -64,11 +64,7 @@ class TestCloudRoleMaker(unittest.TestCase): ...@@ -64,11 +64,7 @@ class TestCloudRoleMaker(unittest.TestCase):
from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet
from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib
from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker
try:
import netifaces
except:
print("warning: no netifaces, skip test_pslib_1")
return
os.environ["POD_IP"] = "127.0.0.1" os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001" os.environ["PADDLE_PORT"] = "36001"
os.environ["TRAINING_ROLE"] = "TRAINER" os.environ["TRAINING_ROLE"] = "TRAINER"
......
...@@ -36,11 +36,7 @@ class TestCloudRoleMaker2(unittest.TestCase): ...@@ -36,11 +36,7 @@ class TestCloudRoleMaker2(unittest.TestCase):
from paddle.fluid.incubate.fleet.parameter_server.distribute_transpiler import fleet from paddle.fluid.incubate.fleet.parameter_server.distribute_transpiler import fleet
from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker
from paddle.fluid.incubate.fleet.base.role_maker import RoleMakerBase from paddle.fluid.incubate.fleet.base.role_maker import RoleMakerBase
try:
import netifaces
except:
print("warning: no netifaces, skip test_pslib_2")
return
os.environ["POD_IP"] = "127.0.0.1" os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001" os.environ["PADDLE_PORT"] = "36001"
os.environ["TRAINING_ROLE"] = "TRAINER" os.environ["TRAINING_ROLE"] = "TRAINER"
......
...@@ -36,11 +36,7 @@ class TestCloudRoleMaker(unittest.TestCase): ...@@ -36,11 +36,7 @@ class TestCloudRoleMaker(unittest.TestCase):
from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet
from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib
from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker
try:
import netifaces
except:
print("warning: no netifaces, skip test_pslib_1")
return
os.environ["POD_IP"] = "127.0.0.1" os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001" os.environ["PADDLE_PORT"] = "36001"
os.environ["TRAINING_ROLE"] = "TRAINER" os.environ["TRAINING_ROLE"] = "TRAINER"
......
...@@ -47,12 +47,6 @@ class TestCloudRoleMaker(unittest.TestCase): ...@@ -47,12 +47,6 @@ class TestCloudRoleMaker(unittest.TestCase):
print("warning: no fleet, skip test_pslib_4") print("warning: no fleet, skip test_pslib_4")
return return
try:
import netifaces
except:
print("warning: no netifaces, skip test_pslib_4")
return
class FakeStream(): class FakeStream():
""" """
it is a fake stream only for test. it is a fake stream only for test.
......
...@@ -70,12 +70,6 @@ class TestCloudRoleMaker(unittest.TestCase): ...@@ -70,12 +70,6 @@ class TestCloudRoleMaker(unittest.TestCase):
os.environ["TRAINING_ROLE"] = "TRAINER" os.environ["TRAINING_ROLE"] = "TRAINER"
os.environ["PADDLE_TRAINER_ID"] = "0" os.environ["PADDLE_TRAINER_ID"] = "0"
try:
import netifaces
except:
print("warning: no netifaces, skip test_tr_rolemaker")
return
ro = role_maker.PaddleCloudRoleMaker(is_collective=False) ro = role_maker.PaddleCloudRoleMaker(is_collective=False)
self.assertTrue(ro._is_worker()) self.assertTrue(ro._is_worker())
ro = role_maker.PaddleCloudRoleMaker(is_collective=False) ro = role_maker.PaddleCloudRoleMaker(is_collective=False)
...@@ -110,12 +104,6 @@ class TestCloudRoleMaker(unittest.TestCase): ...@@ -110,12 +104,6 @@ class TestCloudRoleMaker(unittest.TestCase):
os.environ["POD_IP"] = "127.0.0.1" os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001" os.environ["PADDLE_PORT"] = "36001"
try:
import netifaces
except:
print("warning: no netifaces, skip test_ps_rolemaker")
return
ro = role_maker.PaddleCloudRoleMaker( ro = role_maker.PaddleCloudRoleMaker(
is_collective=False, init_gloo=False) is_collective=False, init_gloo=False)
self.assertEqual(ro._server_index(), 0) self.assertEqual(ro._server_index(), 0)
...@@ -131,11 +119,6 @@ class TestCloudRoleMaker(unittest.TestCase): ...@@ -131,11 +119,6 @@ class TestCloudRoleMaker(unittest.TestCase):
def test_traing_role(self): def test_traing_role(self):
"""Test training role.""" """Test training role."""
os.environ["TRAINING_ROLE"] = "TEST" os.environ["TRAINING_ROLE"] = "TEST"
try:
import netifaces
except:
print("warning: no netifaces, skip test_training_role")
return
ro = role_maker.PaddleCloudRoleMaker(is_collective=False) ro = role_maker.PaddleCloudRoleMaker(is_collective=False)
self.assertRaises(ValueError, ro._generate_role) self.assertRaises(ValueError, ro._generate_role)
...@@ -150,11 +133,6 @@ class TestUserDefinedRoleMaker(unittest.TestCase): ...@@ -150,11 +133,6 @@ class TestUserDefinedRoleMaker(unittest.TestCase):
pass pass
def test_ps_rolemaker(self): def test_ps_rolemaker(self):
try:
import netifaces
except:
print("warning: no netifaces, skip test_ps_rolemaker")
return
ro = role_maker.UserDefinedRoleMaker( ro = role_maker.UserDefinedRoleMaker(
is_collective=False, is_collective=False,
...@@ -169,12 +147,6 @@ class TestUserDefinedRoleMaker(unittest.TestCase): ...@@ -169,12 +147,6 @@ class TestUserDefinedRoleMaker(unittest.TestCase):
self.assertEqual(ro._role_id(), 0) self.assertEqual(ro._role_id(), 0)
def test_tr_rolemaker(self): def test_tr_rolemaker(self):
try:
import netifaces
except:
print("warning: no netifaces, skip test_tr_rolemaker")
return
ro = role_maker.UserDefinedRoleMaker( ro = role_maker.UserDefinedRoleMaker(
is_collective=False, is_collective=False,
init_gloo=False, init_gloo=False,
......
...@@ -36,11 +36,7 @@ class TestFleet1(unittest.TestCase): ...@@ -36,11 +36,7 @@ class TestFleet1(unittest.TestCase):
from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet from paddle.fluid.incubate.fleet.parameter_server.pslib import fleet
from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib from paddle.fluid.incubate.fleet.parameter_server.pslib import PSLib
from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker
try:
import netifaces
except:
print("warning: no netifaces, skip test_pslib_1")
return
os.environ["POD_IP"] = "127.0.0.1" os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001" os.environ["PADDLE_PORT"] = "36001"
os.environ["TRAINING_ROLE"] = "TRAINER" os.environ["TRAINING_ROLE"] = "TRAINER"
......
...@@ -100,11 +100,6 @@ class TestFleetUtil(unittest.TestCase): ...@@ -100,11 +100,6 @@ class TestFleetUtil(unittest.TestCase):
def test_get_file_shard(self): def test_get_file_shard(self):
import paddle.distributed.fleet as fleet import paddle.distributed.fleet as fleet
self.assertRaises(Exception, fleet.util.get_file_shard, "files") self.assertRaises(Exception, fleet.util.get_file_shard, "files")
try:
import netifaces
except:
print("warning: no netifaces, skip test_get_file_shard")
return
role = role_maker.UserDefinedRoleMaker( role = role_maker.UserDefinedRoleMaker(
is_collective=False, is_collective=False,
......
...@@ -17,5 +17,3 @@ decorator ...@@ -17,5 +17,3 @@ decorator
prettytable prettytable
astor astor
pathlib pathlib
netifaces ; platform_system != "Windows"
netifaces ; python_version>="3.5" and platform_system == "Windows"
...@@ -207,7 +207,6 @@ RUN wget -q https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/binutils/ ...@@ -207,7 +207,6 @@ RUN wget -q https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/binutils/
cd binutils-2.27 && \ cd binutils-2.27 && \
./configure && make -j && make install && cd .. && rm -rf binutils-2.27 binutils_2.27.orig.tar.gz ./configure && make -j && make install && cd .. && rm -rf binutils-2.27 binutils_2.27.orig.tar.gz
RUN pip --no-cache-dir install -U netifaces==0.10.9
# Older versions of patchelf limited the size of the files being processed and were fixed in this pr. # Older versions of patchelf limited the size of the files being processed and were fixed in this pr.
# https://github.com/NixOS/patchelf/commit/ba2695a8110abbc8cc6baf0eea819922ee5007fa # https://github.com/NixOS/patchelf/commit/ba2695a8110abbc8cc6baf0eea819922ee5007fa
......
...@@ -212,7 +212,6 @@ RUN wget --no-check-certificate https://pslib.bj.bcebos.com/openmpi-1.4.5.tar.gz ...@@ -212,7 +212,6 @@ RUN wget --no-check-certificate https://pslib.bj.bcebos.com/openmpi-1.4.5.tar.gz
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH && export PATH=/usr/local/bin:$PATH && cd .. && \ export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH && export PATH=/usr/local/bin:$PATH && cd .. && \
rm -rf openmpi-1.4.5.tar.gz && pip --no-cache-dir install mpi4py && ln -fs /bin/bash /bin/sh && \ rm -rf openmpi-1.4.5.tar.gz && pip --no-cache-dir install mpi4py && ln -fs /bin/bash /bin/sh && \
apt-get install libprotobuf-dev -y apt-get install libprotobuf-dev -y
RUN pip --no-cache-dir install -U netifaces==0.10.9
# ccache 3.7.9 # ccache 3.7.9
RUN wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \ RUN wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \
......
...@@ -221,7 +221,6 @@ RUN wget -q https://paddle-ci.gz.bcebos.com/binutils_2.27.orig.tar.gz && \ ...@@ -221,7 +221,6 @@ RUN wget -q https://paddle-ci.gz.bcebos.com/binutils_2.27.orig.tar.gz && \
./configure && make -j && make install && cd .. && rm -rf binutils-2.27 binutils_2.27.orig.tar.gz ./configure && make -j && make install && cd .. && rm -rf binutils-2.27 binutils_2.27.orig.tar.gz
RUN apt-get install libprotobuf-dev -y RUN apt-get install libprotobuf-dev -y
RUN pip --no-cache-dir install -U netifaces==0.10.9
# ccache 3.7.9 # ccache 3.7.9
RUN wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \ RUN wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册