Skip to content

Commit fc43909

Browse files
authored
Cherry-pick #23907 & #24223 (#24465)
* remove print statement to make code clean(#23907) * Try to fix UT Random Fail (#24223)
1 parent 457cf82 commit fc43909

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

paddle/fluid/framework/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ if(WITH_PYTHON)
157157
#Generate an empty \
158158
#__init__.py to make framework_py_proto as a valid python module.
159159
add_custom_target(framework_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py)
160-
add_dependencies(framework_py_proto framework_py_proto_init)
160+
add_dependencies(framework_py_proto framework_py_proto_init trainer_py_proto)
161161
if (NOT WIN32)
162162
add_custom_command(TARGET framework_py_proto POST_BUILD
163163
COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_BINARY_DIR}/python/paddle/fluid/proto

python/paddle/fluid/trainer_desc.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,11 @@ def __init__(self):
3333
# Workaround for relative import in protobuf under python3
3434
# TODO: should be fixed
3535
cur_path = os.path.dirname(__file__)
36-
sys.path.append(cur_path)
37-
sys.path.append(cur_path + "/proto")
38-
39-
# Just for fix random UT fail, will be deleted soon
40-
print("cur_path: ", cur_path)
41-
print("sys.path: ", sys.path)
42-
if os.path.isdir(cur_path + "/proto"):
43-
print("[listdir]")
44-
print(os.listdir(cur_path + "/proto"))
36+
if cur_path not in sys.path:
37+
sys.path.append(cur_path)
38+
if cur_path + "/proto" not in sys.path:
39+
sys.path.append(cur_path + "/proto")
40+
4541
from proto import trainer_desc_pb2
4642
self.proto_desc = trainer_desc_pb2.TrainerDesc()
4743
import multiprocessing as mp

0 commit comments

Comments
 (0)