Skip to content

Commit

Permalink
feat: Parse UDF function name interface submission
Browse files Browse the repository at this point in the history
  • Loading branch information
taoran1250 committed Dec 25, 2024
1 parent f937ef1 commit a71e674
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1440,23 +1440,26 @@ public Message pythonUpload(
}

@ApiImplicitParam(
name = "path",
dataType = "String",
value = "path",
example = "file:///test-dir/test-sub-dir/test1012_01.py")
name = "path",
dataType = "String",
value = "path",
example = "file:///test-dir/test-sub-dir/test1012_01.py")
@RequestMapping(path = "/get-register-functions", method = RequestMethod.GET)
public Message getRegisterFunctions(HttpServletRequest req, @RequestParam("path") String path) {
if (StringUtils.endsWithIgnoreCase(path, Constants.FILE_EXTENSION_PY)
|| StringUtils.endsWithIgnoreCase(path, Constants.FILE_EXTENSION_SCALA)) {
|| StringUtils.endsWithIgnoreCase(path, Constants.FILE_EXTENSION_SCALA)) {
if (StringUtils.startsWithIgnoreCase(path, StorageUtils$.MODULE$.FILE_SCHEMA())) {
try {
// 获取登录用户
String userName = ModuleUserUtils.getOperationUser(req, "get-register-functions");

FsPath fsPath = new FsPath(path);
// 获取文件系统实例
FileSystem fileSystem = (FileSystem) FSFactory.getFs(fsPath);
FileSystem fileSystem = (FileSystem) FSFactory.getFsByProxyUser(fsPath, userName);
fileSystem.init(null);
if (fileSystem.canRead(fsPath)) {
return Message.ok()
.data("functions", UdfUtils.getRegisterFunctions(fileSystem, fsPath, path));
.data("functions", UdfUtils.getRegisterFunctions(fileSystem, fsPath, path));
} else {
return Message.error("您没有权限访问该文件");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,14 @@ public static List<String> extractPythonMethodNames(String udfPath) throws Excep
String exec =
Utils.exec(
(new String[] {
"sudo",
Constants.PYTHON_COMMAND.getValue(),
Configuration.getLinkisHome() + "/admin/" + "linkis_udf_get_python_methods.py",
localPath
}));
logger.info(
"execute python script to get python method name...{} {} {}",
"execute python script to get python method name...{} {} {} {}",
"sudo",
Constants.PYTHON_COMMAND.getValue(),
Configuration.getLinkisHome() + "/admin/" + "linkis_udf_get_python_methods.py",
localPath);
Expand Down

0 comments on commit a71e674

Please sign in to comment.