提交 f56290a6 编写于 作者: Z zhiboniu 提交者: jzhang533

print_signatures: set callable checkrule along

上级 66c7a076
...@@ -103,13 +103,10 @@ def visit_all_module(mod): ...@@ -103,13 +103,10 @@ def visit_all_module(mod):
if inspect.ismodule(instance): if inspect.ismodule(instance):
visit_all_module(instance) visit_all_module(instance)
else: else:
doc_md5 = md5(instance.__doc__)
instance_id = id(instance) instance_id = id(instance)
if instance_id in IdSet: if instance_id in IdSet:
continue continue
IdSet.add(instance_id) IdSet.add(instance_id)
member_dict[cur_name] = "({}, ('document', '{}'))".format(
cur_name, doc_md5)
if hasattr(instance, if hasattr(instance,
'__name__') and member_name != instance.__name__: '__name__') and member_name != instance.__name__:
print( print(
...@@ -219,7 +216,83 @@ def process_module(m, attr="__all__"): ...@@ -219,7 +216,83 @@ def process_module(m, attr="__all__"):
return api_counter return api_counter
def get_all_api_from_modulelist(): def check_public_api():
import paddle
modulelist = [ #npqa
paddle,
paddle.amp,
paddle.nn,
paddle.nn.functional,
paddle.nn.initializer,
paddle.nn.utils,
paddle.static,
paddle.static.nn,
paddle.io,
paddle.jit,
paddle.metric,
paddle.distribution,
paddle.optimizer,
paddle.optimizer.lr,
paddle.regularizer,
paddle.text,
paddle.utils,
paddle.utils.download,
paddle.utils.profiler,
paddle.utils.cpp_extension,
paddle.sysconfig,
paddle.vision,
paddle.vision.datasets,
paddle.vision.models,
paddle.vision.transforms,
paddle.vision.ops,
paddle.distributed,
paddle.distributed.fleet,
paddle.distributed.fleet.utils,
paddle.distributed.parallel,
paddle.distributed.utils,
paddle.callbacks,
paddle.hub,
paddle.autograd,
paddle.incubate,
paddle.inference,
paddle.onnx,
paddle.device
]
apinum = 0
alldict = {}
for module in modulelist:
if hasattr(module, '__all__'):
old_all = module.__all__
else:
old_all = []
dirall = dir(module)
for item in dirall:
if item.startswith('__'):
continue
old_all.append(item)
apinum += len(old_all)
alldict.update({module.__name__: old_all})
old_all = []
dirall = dir(paddle.Tensor)
for item in dirall:
if item.startswith('_'):
continue
old_all.append(item)
apinum += len(old_all)
alldict.update({'paddle.Tensor': old_all})
for module, allapi in alldict.items():
for member_name in allapi:
cur_name = module + '.' + member_name
instance = eval(cur_name)
doc_md5 = md5(instance.__doc__)
member_dict[cur_name] = "({}, ('document', '{}'))".format(cur_name,
doc_md5)
def check_allmodule_callable():
import paddle import paddle
modulelist = [paddle] modulelist = [paddle]
for m in modulelist: for m in modulelist:
...@@ -255,9 +328,9 @@ def parse_args(): ...@@ -255,9 +328,9 @@ def parse_args():
if __name__ == '__main__': if __name__ == '__main__':
args = parse_args() args = parse_args()
check_allmodule_callable()
if args.method == 'from_modulelist': if args.method == 'from_modulelist':
get_all_api_from_modulelist() check_public_api()
for name in member_dict: for name in member_dict:
print(name, member_dict[name]) print(name, member_dict[name])
elif args.method == 'get_all_api': elif args.method == 'get_all_api':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册