Skip to content

Commit

Permalink
fix geo ut (#33441)
Browse files Browse the repository at this point in the history
Change-Id: I4e09e7710f6693bff5388983270781a4ef70519e
  • Loading branch information
seiriosPlus committed Jun 10, 2021
1 parent df4a978 commit 6ad1880
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions python/paddle/fluid/tests/unittests/test_communicator_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import paddle.distributed.fleet.base.role_maker as role_maker
import paddle.distributed.fleet as fleet

from paddle.distributed.utils import find_free_ports

paddle.enable_static()


Expand Down Expand Up @@ -101,12 +103,9 @@ def run_ut(self):

os.environ["PADDLE_PSERVER_NUMS"] = "1"
os.environ["PADDLE_TRAINERS_NUM"] = "1"
os.environ["POD_IP"] = "127.0.0.1"
os.environ["PADDLE_PORT"] = "36001"
os.environ["PADDLE_TRAINER_ID"] = "0"
os.environ["PADDLE_TRAINERS_NUM"] = "1"
os.environ["PADDLE_PSERVERS_IP_PORT_LIST"] = \
"127.0.0.1:36001"
os.environ["POD_IP"] = "127.0.0.1"

role = role_maker.PaddleCloudRoleMaker()

Expand Down Expand Up @@ -150,8 +149,6 @@ def runTest(self):
pass
os.environ["TRAINING_ROLE"] = "PSERVER"
os.environ["http_proxy"] = ""
os.environ["https_proxy"] = ""
half_run_server = RunServer()
half_run_server.run_ut()
Expand All @@ -160,9 +157,12 @@ def runTest(self):
server_file = "run_server_for_communicator_geo.py"
with open(server_file, "w") as wb:
wb.write(run_server_cmd)

port = find_free_ports(1).pop()

os.environ["TRAINING_ROLE"] = "PSERVER"
os.environ["http_proxy"] = ""
os.environ["https_proxy"] = ""
os.environ["PADDLE_PORT"] = str(port)
os.environ["PADDLE_PSERVERS_IP_PORT_LIST"] = "127.0.0.1:{}".format(port)

_python = sys.executable

Expand All @@ -173,17 +173,14 @@ def runTest(self):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

outs, errs = ps_proc.communicate(timeout=15)

time.sleep(1)
time.sleep(5)

os.environ["TRAINING_ROLE"] = "TRAINER"
os.environ["http_proxy"] = ""
os.environ["https_proxy"] = ""

self.run_ut()
ps_proc.kill()
ps_proc.wait()
outs, errs = ps_proc.communicate()

if os.path.exists(server_file):
os.remove(server_file)
Expand Down

0 comments on commit 6ad1880

Please sign in to comment.