From f792d5f71b27d1da8042b59d6a282e891f332e7c Mon Sep 17 00:00:00 2001 From: zhangchunle Date: Thu, 9 Apr 2020 21:57:21 +0800 Subject: [PATCH] modify sampcd_processor.py (#23695) --- tools/sampcd_processor.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/tools/sampcd_processor.py b/tools/sampcd_processor.py index 040292f24a..c2dfecdfbb 100644 --- a/tools/sampcd_processor.py +++ b/tools/sampcd_processor.py @@ -457,7 +457,9 @@ def get_filenames(): ''' filenames = [] global methods + global whl_error methods = [] + whl_error = [] get_incrementapi() API_spec = 'dev_pr_diff_api.spec' with open(API_spec) as f: @@ -466,6 +468,7 @@ def get_filenames(): try: module = eval(api).__module__ except AttributeError: + whl_error.append(api) continue if len(module.split('.')) > 2: filename = '../python/' @@ -474,8 +477,9 @@ def get_filenames(): filename = filename + '%s/' % module.split('.')[i] filename = filename + module_py else: + filename = '' print("\n----Exception in get api filename----\n") - print("\n" + api + 'module is ' + module + "\n") + print("\n" + api + ' module is ' + module + "\n") if filename not in filenames: filenames.append(filename) # get all methods @@ -577,7 +581,7 @@ else: os.mkdir("./samplecode_temp") cpus = multiprocessing.cpu_count() filenames = get_filenames() - if len(filenames) == 0: + if len(filenames) == 0 and len(whl_error) == 0: print("-----API_PR.spec is the same as API_DEV.spec-----") exit(0) elif '../python/paddle/fluid/core_avx.py' in filenames: @@ -605,8 +609,27 @@ else: os.rmdir("./samplecode_temp") print("----------------End of the Check--------------------") - for temp in result: - if not temp: - print("Mistakes found in sample codes") - exit(1) + if len(whl_error) != 0: + print("%s is not in whl." % whl_error) + print("") + print("Please check the whl package and API_PR.spec!") + print("You can follow these steps in order to generate API.spec:") + print("1. cd ${paddle_path}, compile paddle;") + print("2. pip install build/python/dist/(build whl package);") + print( + "3. run 'python tools/print_signatures.py paddle > paddle/fluid/API.spec'." + ) + for temp in result: + if not temp: + print("") + print("In addition, mistakes found in sample codes.") + print("Please check sample codes.") + print("----------------------------------------------------") + exit(1) + else: + for temp in result: + if not temp: + print("Mistakes found in sample codes.") + print("Please check sample codes.") + exit(1) print("Sample code check is successful!") -- GitLab