Skip to content

Commit 7ceec40

Browse files
committed
hide more apis
1 parent f9f8fba commit 7ceec40

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

python/paddle/fluid/layers/io.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
from layer_function_generator import generate_layer_fn, templatedoc
2323

2424
__all__ = [
25-
'data', 'BlockGuardServ', 'ListenAndServ', 'Send', 'Recv',
26-
'open_recordio_file', 'open_files', 'read_file', 'shuffle', 'batch',
25+
'data', 'open_recordio_file', 'open_files', 'read_file', 'shuffle', 'batch',
2726
'double_buffer', 'random_data_generator', 'py_reader', 'Preprocessor',
2827
'load'
2928
]
@@ -802,7 +801,7 @@ def __init__(self, reader, name=None):
802801
self.sink_var_names = None
803802
self.status = Preprocessor.BEFORE_SUB_BLOCK
804803

805-
def is_completed(self):
804+
def _is_completed(self):
806805
return self.sub_block and self.source_var_names and self.sink_var_names
807806

808807
@contextlib.contextmanager
@@ -812,7 +811,7 @@ def block(self):
812811
yield
813812
self.main_prog.rollback()
814813
self.status = Preprocessor.AFTER_SUB_BLOCK
815-
if not self.is_completed():
814+
if not self._is_completed():
816815
raise RuntimeError(
817816
"The definition of preprocessor is incompleted! "
818817
"Please make sure that you have set input and output "

python/paddle/fluid/tests/unittests/test_dist_train.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
import paddle.fluid as fluid
2424
import paddle.fluid.layers as layers
25+
from paddle.fluid.layers.io import ListenAndServ
26+
from paddle.fluid.layers.io import Recv
27+
from paddle.fluid.layers.io import Send
2528

2629

2730
class TestSendOp(unittest.TestCase):
@@ -65,8 +68,7 @@ def init_serv(self, place):
6568
main = fluid.Program()
6669

6770
with fluid.program_guard(main):
68-
serv = layers.ListenAndServ(
69-
"127.0.0.1:0", ["X"], optimizer_mode=False)
71+
serv = ListenAndServ("127.0.0.1:0", ["X"], optimizer_mode=False)
7072
with serv.do():
7173
out_var = main.global_block().create_var(
7274
name="scale_0.tmp_0",
@@ -99,8 +101,8 @@ def init_client(self, place, port):
99101
persistable=False,
100102
shape=[32, 32])
101103
fluid.initializer.Constant(value=2.3)(get_var, main.global_block())
102-
layers.Send("127.0.0.1:%d" % port, [x])
103-
o = layers.Recv("127.0.0.1:%d" % port, [get_var])
104+
Send("127.0.0.1:%d" % port, [x])
105+
o = Recv("127.0.0.1:%d" % port, [get_var])
104106

105107
exe = fluid.Executor(place)
106108
self.dist_out = exe.run(main, fetch_list=o) # o is a list

0 commit comments

Comments
 (0)