MCPcopy Create free account
hub / github.com/alibaba/GraphScope / _parse_user_app

Function _parse_user_app

python/graphscope/analytical/app/java_app.py:61–120  ·  view source on GitHub ↗
(java_app_class: str, java_jar_full_path: str)

Source from the content-addressed store, hash-verified

59
60
61def _parse_user_app(java_app_class: str, java_jar_full_path: str):
62 _java_app_type = ""
63 _frag_param_str = ""
64 _java_inner_context_type = ""
65 _java_executable = "java"
66 if shutil.which("java") is None:
67 if os.environ.get("JAVA_HOME", None) is not None:
68 _java_executable = os.path.join(os.environ.get("JAVA_HOME"), "bin", "java")
69 if not os.path.isfile(_java_executable) or not os.access(
70 _java_executable, os.X_OK
71 ):
72 raise RuntimeError(
73 "Java executable not found, you shall install a java runtime."
74 )
75 parse_user_app_cmd = [
76 _java_executable,
77 "-cp",
78 "{}".format(java_jar_full_path),
79 "com.alibaba.graphscope.utils.AppBaseParser",
80 java_app_class,
81 ]
82 logger.info(" ".join(parse_user_app_cmd))
83 parse_user_app_process = subprocess.Popen(
84 parse_user_app_cmd,
85 env=os.environ.copy(),
86 encoding="utf-8",
87 errors="replace",
88 stdout=subprocess.PIPE,
89 stderr=subprocess.PIPE,
90 universal_newlines=True,
91 bufsize=1,
92 )
93 out, err = parse_user_app_process.communicate()
94 lines = out.split("\n") + err.split("\n")
95 for line in lines:
96 if len(line) == 0:
97 continue
98 if line.find("DefaultPropertyApp") != -1:
99 _java_app_type = "default_property"
100 elif line.find("ParallelPropertyApp") != -1:
101 _java_app_type = "parallel_property"
102 elif line.find("DefaultAppBase") != -1:
103 _java_app_type = "default_simple"
104 elif line.find("ParallelAppBase") != -1:
105 _java_app_type = "parallel_simple"
106 elif line.find("Error") != -1:
107 raise Exception("Error occured in verifying user app")
108 elif line.find("TypeParams") != -1:
109 _frag_param_str = line.split(":")[-1].strip()
110 elif line.find("ContextType") != -1:
111 _java_inner_context_type = line.split(":")[-1].strip()
112 logger.info(
113 "Java app type: %s, frag type str: %s, ctx type: %s",
114 _java_app_type,
115 _frag_param_str,
116 _java_inner_context_type,
117 )
118

Callers 1

__init__Method · 0.85

Calls 8

splitMethod · 0.80
findMethod · 0.80
getMethod · 0.65
copyMethod · 0.65
joinMethod · 0.45
accessMethod · 0.45
formatMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected