未验证 提交 fc43909e 编写于 作者: H hutuxian 提交者: GitHub

Cherry-pick #23907 & #24223 (#24465)

* remove print statement to make code clean(#23907)
* Try to fix UT Random Fail (#24223)
上级 457cf826
...@@ -157,7 +157,7 @@ if(WITH_PYTHON) ...@@ -157,7 +157,7 @@ if(WITH_PYTHON)
#Generate an empty \ #Generate an empty \
#__init__.py to make framework_py_proto as a valid python module. #__init__.py to make framework_py_proto as a valid python module.
add_custom_target(framework_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py) add_custom_target(framework_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py)
add_dependencies(framework_py_proto framework_py_proto_init) add_dependencies(framework_py_proto framework_py_proto_init trainer_py_proto)
if (NOT WIN32) if (NOT WIN32)
add_custom_command(TARGET framework_py_proto POST_BUILD add_custom_command(TARGET framework_py_proto POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_BINARY_DIR}/python/paddle/fluid/proto COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_BINARY_DIR}/python/paddle/fluid/proto
......
...@@ -33,15 +33,11 @@ class TrainerDesc(object): ...@@ -33,15 +33,11 @@ class TrainerDesc(object):
# Workaround for relative import in protobuf under python3 # Workaround for relative import in protobuf under python3
# TODO: should be fixed # TODO: should be fixed
cur_path = os.path.dirname(__file__) cur_path = os.path.dirname(__file__)
sys.path.append(cur_path) if cur_path not in sys.path:
sys.path.append(cur_path + "/proto") sys.path.append(cur_path)
if cur_path + "/proto" not in sys.path:
# Just for fix random UT fail, will be deleted soon sys.path.append(cur_path + "/proto")
print("cur_path: ", cur_path)
print("sys.path: ", sys.path)
if os.path.isdir(cur_path + "/proto"):
print("[listdir]")
print(os.listdir(cur_path + "/proto"))
from proto import trainer_desc_pb2 from proto import trainer_desc_pb2
self.proto_desc = trainer_desc_pb2.TrainerDesc() self.proto_desc = trainer_desc_pb2.TrainerDesc()
import multiprocessing as mp import multiprocessing as mp
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册