Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix geo ut #33441

Merged
merged 1 commit into from
Jun 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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