From aea92fda8deb302856e6435259b9b5011f59949d Mon Sep 17 00:00:00 2001 From: taoran1250 <543121890@qq.com> Date: Wed, 18 Dec 2024 16:08:16 +0800 Subject: [PATCH] Dev 1.10.0 webank merge udf register function (#686) * feat: Parse UDF function name interface submission * feat: Parse UDF function name interface submission --- .../admin/linkis_udf_get_python_methods.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 linkis-dist/package/admin/linkis_udf_get_python_methods.py diff --git a/linkis-dist/package/admin/linkis_udf_get_python_methods.py b/linkis-dist/package/admin/linkis_udf_get_python_methods.py new file mode 100644 index 0000000000..d3f8268141 --- /dev/null +++ b/linkis-dist/package/admin/linkis_udf_get_python_methods.py @@ -0,0 +1,18 @@ +import sys +import ast +import json + +def extract_method_names(file_path): + with open(file_path, 'r') as file: + code = file.read() + tree = ast.parse(code) + method_names = set() + + for node in ast.walk(tree): + if isinstance(node, ast.FunctionDef): + method_names.add(node.name) + + return json.dumps(list(method_names), indent=4) + +file_path = sys.argv[1] +print(extract_method_names(file_path))